Länk - A very simple tree implementation in python
Using Python's built-in defaultdict we can easily define a tree data structure: def tree(): return defaultdict(tree)
Read more: one-line tree in python — Gist
Using Python's built-in defaultdict we can easily define a tree data structure: def tree(): return defaultdict(tree)
Read more: one-line tree in python — Gist
I wrote a custom logging handler that pushes JSON-encoded log record data to a redis pub/sub channel. I then have an IRC bot that subscribes to this channel and when it receives a message generates a paste of the traceback and pings me with a link to the traceback.
Read more: charles leifer | Using Redis Pub/Sub and IRC for Error Logging with Python
I dataspel kan man ibland låta datorn hjälpa en på ett otillbörligt sätt med t ex en aimbot. Man kan då försöka detektera vem som fuskar och straffa/avstänga dom.
Men en intressant strategi är att inte på ett uppenbart avslöja att fusk detekteras, genom att ge ett straff som är svårt att detektera för fuskaren. Då fördröjer man motmedelsutvecklingen på fuskarsidan. Två sätt som nämns i en tråd på reddit är:
It's worth calling out how Valve handled this in Team Fortress 2. They secretly recorded everyone who used a cheat program, then gave everyone else a hat.
Install the "MP3 Diags" application, and apply the "Repair VBR Data" action.
When encoding mp3s with variable bit rate, teh resulting file will sometimes confuse media players such as Rhythmbox. In my case the problem was solved by installing the MP3 Diags program and applying the "Repair VBR Data" transformation (see screenshot below).
Kivy is an open source software library for rapid development of applications equipped with novel user interfaces, such as multi-touch apps. You are probably wondering why you’d be interested in using Kivy. There is a document outlining our Philosophy that we encourage you to read.
find |xargs perl -pi -e 's/searchpat/replacepat/g'
Examples:
find -name "*.py"|xargs perl -pi -e 's/searchpat/replacepat/g'
find -name "*.pt"|xargs perl -pi -e 's/searchpat/replacepat/g'
find|perl -nl -e '$o= $_;rename($o,$_) if s/searchpat/replacepat/'
I am in the process of testing it right now:
Run a free website speed test from multiple locations around the globe using real browsers (IE and Chrome) and at real consumer connection speeds. You can run simple tests or perform advanced testing including multi-step transactions, video capture, content blocking and much more. Your results will provide rich diagnostic information including resource loading waterfall charts, Page Speed optimization checks and suggestions for improvements.
Read more: WebPagetest - Website Performance and Optimization Test
There is also a sister site, blaze.io, that seems to do about the same thing for mobile devices:
A module that makes "Jörgen" into "Jorgen" and "mañana" into "manana". And so on.
Note that this module generally produces better results than simply stripping accents from characters (which can be done in Python with built-in functions). It is based on hand-tuned character mappings that for example also contain ASCII approximations for symbols and non-Latin alphabets.
Read more: Unidecode 0.04.9 : Python Package Index
Right-click the menu bar, select "Customize...", and then when the dialog comes up, you can drag and drop the existing reload button on the bar to go to the left of the url field.
That is, you are not limited to the selction of buttons shown in the dialog, you are free to move the already placed out buttons in the browser as well.
I moved mine .. I think it was right click on the navigation bar, click customize .. then drag and drop it where you want.
Ett antal människor i bl a Sverige och Finland har fått narkolepsi efter vaccinering mot svininfluensa. Om man läser mediebevakningen om detta så finns det i stort sett inte- i alla fall i det jag läst - någon analys eller spekulation om vad det är i vaccinet som kan ha medverkat till narkolepsin.
Det vore väldigt illa om folkopinionen vände sig mot vaccin i största allmänhet då de gör stor nytta med i stort sett inga biverkningar.
För de svenska doserna hade man inte nog med vaccin i form av avdödade virus. Man har då använt ett tillsatsmedel - en adjuvant - i varje dos, för att reta immunförsvaret.
Adjuvanten retar immunförsvaret i största allmänhet såvitt jag begriper dess funktion, och det tycker jag låter som en hemskt dålig idé att göra, eftersom många av våra svåraste sjukdomar just är autoimmuna. Min spekulation är att problemet finns just här.
Adjuvanten som använts tror jag är hajolja.
I have found a new favorite for this task. It is called AviDemux. However if you just import a video file with incomplete frames with key frames in between, you cannot scrub properly, since AviDemux does not convert the film to have only key frames. Having incomplete frames that are re-created on playback is a common technique to save storage space. Scrubbing will jump between the key frames, at least for the file formats I have tried.
You can solve that by using ffmpeg to add key frames so every frame becomes a key frame, before you open the video in AviDemux.
For e.g. an flv file you can do it like this:
ffmpeg -keyint_min 0 -i video.flv video_all_keyframes.flv
Before finding AviDeMux. the LIVES video editor was the best one I had found for extracting short video clips from a video.
My use case was extracting individual moves from salsa dance performances. I have now tried four Linux based video editors for this. The other two I have tested are cinelerra and PiTiVi.
My needs were very well defined. I want to watch through a video and extract short sequences that illustrate different dance moves.
Scrubbing
Moving back and forth through a video by dragging the pointer sideways, turning a wheel or something similar is called scrubbing.
With globstar set, bash recurses all the directories. Note that this will recurse all directory levels, not just one level. You can see if globstar is set by issuing the shopt command without any arguments:
Read more: Globstar: New Bash Globbing Option | Linux Journal
Might come in handy one day.
For fun, you can see the temporary file created by the process: dir <( sort A | tr [:lower:] [:upper:] ) lr-x------ 1 crash daily 64 Mar 5 23:17 /dev/fd/63 -> pipe:[21483501]
Read more: Diff two stdout streams « crashingdaily
I did not understand how the form worked at the below site (see comments below), so the static page linked to shows plots for a number of computer languages with regards to speed and compactness.
If you draw a line from left to right in it, sloping, you can make out Javascript, Pascal and Fortran as the winners in the size/speed trade off, given the criteria and scaling used.
However the language that seems to have the smallest sizes for complexity performed, is Ruby. I better take a look at that.
From concise at the left to less-concise at the right, from slower at the top to faster at the bottom.
Read more: Code-used Time-used Shapes | Computer Language Benchmarks Game
Eller noise cancelling headphones som de säger på engelska. David Pogue anser att pionjären Bose fortfarande är bäst:
Even they can’t touch the Bose ($300) for noise cancellation, though. Bose’s technology is still a couple of years ahead of the competition.
Read more: Finding Headphones to Shut Out the World - State of the Art - NYTimes.com
Computer languages, that is.
Thrift allows you to define data types and service interfaces in a simple definition file. Taking that file as input, the compiler generates code to be used to easily build RPC clients and servers that communicate seamlessly across programming languages
Read more: Apache Thrift
Tumblr Architecture - 15 Billion Page Views a Month and Harder to Scale than Twitter
Summary:
windmill -m test=./tests/test_1.py http://example.com
Windmill allows you to run tests against a web site through real browsers, including using Ajax technology. For example, you can operate a browser and windmills records everything you do as python code, which can the be run again, and altered.
Windmill can be used in large testing frameworks such as niteoweb.windmill (for Plone), but how do you just run a simple script with the code that has been generated by one's browsing about? Well, you canot easily do it from inside of python, down that path lies madness. While skirting madness, I realised that the simple way of running the python code was to have windmill run it for you:
windmill -m test=./tests/test_1.py http://example.com
The "-m" switch tells it to run Firefox. If you forget that switch it will run nothing while executing the code. The test sub command (I call it a sub command since it has no preceding dash) tells windmill where the python script is that was generated by windmill, and lastly the url is given as an argument to windmill. You need to set up a prefs.py file in the ~/.windmill directory (on Linux that is), with the following content:
MOZILLA_BINARY='/usr/bin/firefox'
MOZILLA_DEFAULT_PROFILE='~/.mozilla/firefox/'
Before resigning to runninng windmill from the command line, I tried to run my script it from within python, and here is an excerpt of that non functioning script with some explanations in it, important stuff in bold, using windmill 1.6, python 2.6 on Ubuntu 10.10:
import windmill
from windmill.authoring import setup_module, WindmillTestClient
from windmill.conf import global_settings
import sys
global_settings.START_FIREFOX = True # This makes it use Firefox
setup_module(sys.modules[__name__])
global_settings.TEST_URL ='http://example.com' #This does not work. Instead
# use ~./.windmill/prefs.py and add the line:
# TEST_URL ='http://example.com'
# (without the # in front)
client = WindmillTestClient(__name__)
client.waits.forPageLoad(timeout=u'20000')
client.click(xpath=u"//div[@id='content']/table/tbody/tr[1]/td/a/img")
# Click does not work, according to the debugger it does not exist. MouseUp does.
# Bailing out, avoiding madness
On Linux, using ffmpeg with lame installed:
ffmpeg -i video.flv -acodec libmp3lame -aq 2 audio.mp3
I decided to install Rockbox on my Sansa Clipp tonight, but after trying it out went back to the factory firmware. Reasons:
From what I could see in the user interface in Rockbox on my Sansa Clipp, it expects all playlists to reside in a playlists folder. I have dozens of playlists, manually made in Rhythmbox and more automatically generated from a python script. None of them reside in a playlists folder, yet all are picked up by the Sansa standard firmware. While Rockbox picked up none. It seems you should be able to navigate with the file browser to each playlist, but that is too much work.
And if I would make new playlists with Rhythmbox, Rhythmbox on my Ubuntu would probably continue to just store them in different places, so even if I converted my old playlists, the problem would remain with new ones.
The playlists problem above was the deal breaker, but I also did not care for the miniscule fonts in the user interface. Once it's playing you can get very large fonts indeed, through installable themes, but they do not cover the navigation and settings part of the ui. Update: According to "scorche" in the comments section below, there are themes that also cover the navigation and settings. The theme I selected - "FEP" - did not however.
The main reason for installing Rockbox was to see if it could play a couple of aac files that I originally stripped out of Youtube videos. Rockbox did however not find them. This could very well be a problem with the files. Still, Rhythmbox on my Ubuntu computer plays them without problems
Ok, here I am really stretching when it comes to putting demands on Rockbox. According to its documentation it does not list the TBPM tag in its database. It would have been nice to sort and group on beats per minute. But I guess there is not an overwhelming demand for that feature,
I could not uninstall Rockbox through the Rockbox utility, so I went to Sandisk:
http://forums.sandisk.com/t5/Clip-Clip/Sansa-Clip-Firmware-Update-01-02-16/td-p/150227
and followed the instructions.
After having installed Rockbox, and then uninstalled the extras: Mounting the player with USB failed despite rebooting the Clip many times, and when booting into Windows it reported the Clipp as a faulty USB device. I booted into the stock OS by holding the menu button while booting. Switching the Clipp off for a couple of minuted fixed the problem. After that it was in a state where I could reflash it with the stock firmware.