Python programming - debugging.
Second video recording.
wallacepolsom

oozey mess
let's talk about Bridgerton tea, my ask is open
AnasAbdin
will byers stan first human second

pixel skylines

祝日 / Permanent Vacation
Acquired Stardust
noise dept.

izzy's playlists!
Monterey Bay Aquarium
sheepfilms

JVL
we're not kids anymore.
$LAYYYTER
hello vonnie
cherry valley forever

ellievsbear

JBB: An Artblog!
seen from United States

seen from Egypt

seen from Singapore
seen from China
seen from Philippines
seen from United States
seen from Sweden

seen from Netherlands

seen from United States
seen from United States

seen from Australia
seen from United Kingdom
seen from Brazil
seen from United Kingdom
seen from Brazil
seen from United States
seen from Germany
seen from United States
seen from United States
seen from United States
@fnielsen
Python programming - debugging.
Second video recording.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Python programming - scripting
From DTU 02819 (Technical University of Denmark, course 02819, Data Mining using Python).
First attempt on publishing a YouTube video from a recording made in the new building 324 at the Technical University of Denmark during the “Data Mining using Python” course.
What does virality look like? Ylvis Wikipedia viewing statistics
Norwegian Ylvis (which I am happy to say has recorded a video called My name is Finn) is infesting the globe with the viral YouTube hit The Fox, likely to reach 100 million views in a week or so.
Ylvis has articles across 11 different Wikipedia language versions: Russian, English, etc. Henrik's excellent webservice allows for easy access to Wikipedia viewing statistics.
I wrote a small Python script that would query Henrik's webservice to get an overview of of the temporal evolution across languages for this viral hit. The plot displays the Wikipedia viewing statistics for the past 90 days with lines colored according to Wikipedia language, for example "en" being English and "no" being Norweigian bokmĂĄl. Note the logarithmic y-axis!
The video was released on 3 September 2013. Before that day the Ylvis articles usually had well below 100 views a day. Already the next day the number of views rises dramatically on the English Wikipedia, probably spawned by a Reddit post, that was posted "Sep 4 15:21:53 2013 UTC" for the morning Americans. On 6 September the number of Wikipedia views reaches a peaking level and has since been reasonably constant at around 20.000 views per day. The Norwegian and Swedish views lack around a day after the English, while the Finnish views one day extra. German and French are a whole week after the English and Russian and Czech even one and half week after. The Japanese article was first created 30 September and it is difficult to say how they whould have responded if it was created before.
There is a few interesting things to note when you compare the viewing statistics across languages:
Usually there is a sudden increase in views lasting 1 to 2 days.
Once the peak is attained there is usually a so far flat plateau where the number of views per day stays reasonably constant. The number of YouTube views for the video does also displays a constant viewing rate of around 3 million per day, - give or take a million.
The sudden increase may be delayed across language versions. French and German -- and Russian even more so -- show resistence to infection from the English world, but once infected with the Ylvis virality it immediately catches on.
Is that how virality looks like?
Wordpress blog suspended!?
So I am managing some blog posts on my Wordpress.com blog and suddenly I was suspended, meaning I had no access (beyond backup) to my blog posts and others could not read... Why? Jeff Mayernik has had a similar experience documented on his blog Automattic idiocy – Why WordPress suspended my blog. What on earth happen?
With the NeurofeedbackWindow smartphone brainscanner application, hook up the emotiv to the smartphone, start the application press "Rec. Baseline". After 5 minutes the phone has recorded some data from the electrodes and it is now available from a directory under "/sdcard".
Hook the phone to a development computer with Necessitas and look for the file with
$ /opt/NecessitasQtSDK/android-sdk/platform-tools/adb shell
And copy the file with:
$ /opt/NecessitasQtSDK/android-sdk/platform-tools/adb pull
"/sdcard/smartphonebrainscanner2_readings/" .
I then got two files: sbs2data_2013_09_11_13_47_59_.raw and sbs2data_2013_09_11_13_47_59_.meta. I am unaware of the format.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
NTLDR is missing after pycuda installation
Yesterday I installed pycuda, but did not try it out. I noticed that during installation it did some manipulation of the kernel, - so perhaps the booting was changed.
This morning when booting the Ubuntu computer I got the message "NTLDR is missing" with some Press Ctrl+Al+Del to restart. So my boot was destroyed. Information on the web told be that it could be a sign of a floppy disk or a USB stick in the computer, - but surely I did not have a USB stick in my computer.
I had a few USB sticks I then tried to boot from. In one case the message changed, in another case I was able to boot into Ubuntu 10.10 on the USB stick. As I got the the desktop up and running I noticed that a USB harddrive showing up on the desktop, and I then move my eyes a few degrees to my left to find the USB harddrive I had attached yesterday. After removing this drive the boot was successful.
Apparently >>> import pycuda also works.
PsychoPy import error
I suddenly experienced a problem with psychopy that I did not have before:
>>> import psychopy Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/fnielsen/python/psychopy.py", line 3, in <module> ImportError: cannot import name visual
I did not put sufficient attention to the details of the error message, and I tried sudo aptitude purge psychopy followed by sudo aptitude install psychopy, that did not help.
I then understood that I had a file named with a similar name, - and a directory too, and locate psychopy.py told me that I had a /home/fnielsen/python/psychopy.py. My PYTHONPATH in .pam_environment have the directory with this file. However, when I erased that file and renamed the directly I still got the error!
I tried an update of the locate database: sudo updatedb. locate psychopy.py would then still report that I had the /home/fnielsen/python/psychopy.pyc file. After rm /home/fnielsen/python/psychopy.pyc I finally got ImportError: No module named psychopy and with sudo aptitude search psychopy I could finally import it.
Identi.ca/pump.io stream API?
I have been wondering how/if you can hook into pump.io API to get a stream. I can not find much good documentation about anything regarding this activity stream software and service.
Somewhere someone mentioned https://ofirehose.com/doc/subscribe that apparently has a JSON feed at https://ofirehose.com/feed.json with some kind of data coming out from time to time.
Here is a few first shot Python commands with this web service:
feeds = json.load(requests.get("https://ofirehose.com/feed.json").raw) pprint.pprint(feeds) for feed in feeds["items"]: print("========\n{}".format(feed['object'].get('content', ''))) for feed in feeds['items']: print("{}: {}".format(feed['published'], feed['verb'])) for feed in feeds['items']: print("{}: {:25} {}".format(feed['published'], feed['actor']['displayName'], feed['verb']))
One of the most frustrating aspects of this report is the role of “neutrality" — especially in light of the criticism MIT makes of the prosecutors reported in the post below.
"Neutrality" is one of those empty words that somehow has achieved sacred and context-free acceptance — like...
Still learning git I have now copied code programmed by our student programmer into a branch on GitHub. I first created a local branch called 'fake' (the code is generating faked data), then copied the relevant part of the code into the subdirectory of the branch and finally pushed the changes to GitHub.
In /smartphonebrainscanner2-core/ I did the following commands:
$ git branch * master $ git branch fake $ git push origin fake $ git checkout fake $ cd src/hardware $ cp -r /projects/riis/smartphonebrainscanner2-core/src/hardware/fake/ . $ git add fake/ $ git commit fake/ $ git push origin fake
Now we got a branch on GitHub for the "fake" tree.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Git: multiuser and multiple accounts
We are still struggling somewhat with Git for multiple developers development of the Smartphone Brainscanner code. It may well be a RTFM-problem. We presumably have the Github Smartphone Brain Scanner code setup.
However, we also have a private department git accounts working with gitolite which brings some problems.
If you got multiple computers each with a different public key then you need extra tricks to be able to clone, push and pull from all computers. Here are the steps that got me working:
I send one of my public keys to our department system administrators who then sets up an account with there specially developed script.
With the account setup I can clone my gitolite-admin repository. git clone <git username>@<department git server>:gitolite-admin.
The keydir at gitolite-admin/keydir/<git username>.pub is supposed to contain my public key from one of the computers. In a subdirectory I can put my public key from another computer, e.g., cp id_rsa.pub gitolite-admin/keydir/<name of other computer>/<git username>.pub
Followed by the git commands git add, git commit and git push.
Specify in the ~/.ssh/config the username of the git server. Under Host <department git server> put User <git username>.
To have other users access the repository I create I have tried:
In gitolite-admin/conf/gitolite.conf added the a line such as @sbs2 = <my git username> <another user's git username> <a third user> and then under repo sbs2-Brain3D I added RW+ = @sbs2.
One user has reported that it now allows him to read and write in the repository, while cloning still is a problem for another user...
Hear The Incredible Rise Of Climate Change Played On The Cello (via Co.Exist: World changing ideas and innovation)
Salva LĂłpez
Deserted swimming pool.
Docopt demonstration
For parsing command-line input argument in a script Python has the old argparse, optparse, and getopt modules. A new development is the docopt module that I have been using a bit for scripts related to Responsible Business Base.
The docopt module is a doctest-like approach where the command-line input specification is simply specified in the documentation (i.e., the docstring) of the script, just as you write the ordinary documentation. The simplicity in the approach may best be described by citing a YouTube comment: "holy shit".
Vladimir Keleshev has made his code available at https://github.com/docopt/docopt. It also installable via pip install docopt and http://docopt.org/ shows example.
Here is a small example which uses docopt in a program that fits a polynomium.
#!/usr/bin/env python """ mydocopter. Usage: mydocopter [options] <filename> Options: -v --verbose Log messages -o OUTPUT --output=OUTPUT Output file -a <a> Initial coefficient for second order term [default: 1.] -b <b> Initial coefficient for first order term [default: 1.] -c <c> Initial coefficient for constant term [default: 1.] Example: $ echo -e "1 4\\n2 5\\n6 8\\n3 3.2" > datafile.txt $ ./mydocopter --verbose datafile.txt 0.315471154631 -1.51271481921 5.64476836068 $ ./mydocopter -o p.txt datafile.txt $ ipython --pylab --c="m=loadtxt('datafile.txt'); p=loadtxt('p.txt'); x=linspace(1,6); plot(m[:,0], m[:,1], 'o', x, p[0]*x**2+p[1]*x+p[2], '-'); raw_input()" Description: Fit a polynomial to data. The datafile should have x y values in each row """ import docopt, logging, scipy.optimize args = docopt.docopt(__doc__, version=1.0) if args['--verbose']: logging.getLogger().setLevel(logging.INFO) a, b, c = (float(args['-' + coef]) for coef in ['a', 'b', 'c']) logging.info("Setting 'a' to %f" % a) logging.info('Reading data from ' + args['<filename>']) data = [ map(float, line.split()) for line in open(args['<filename>']).readlines()] def cost_function((a, b, c), data): return sum(map(lambda (x, y): (a*x**2 + b*x + c - y)**2, data)) parameters = scipy.optimize.fmin(cost_function, [a, b, c], args=(data,), disp=False) if args['--output'] is None: print(" ".join(map(str, parameters))) else: with open(args['--output'], 'w') as f: f.write(" ".join(map(str, parameters)))
Reply to "NSA scandal delivers record numbers of internet users to DuckDuckGo"
Internet search engine DuckDuckGo have received further attention after Edward Snowden's disclosures. Guardian has written a positive article titled NSA scandal delivers record numbers of internet users to DuckDuckGo.
Here is my critical comment:
Apart from the issues mentioned by others (e.g., "apolitical_paddy": that US authorities can gain access to the servers and monitor queries) then traffic analysis between users and DuckDuckGo (DDG) and DDG and sources can be used by intelligence agencies.
DDG federates results from Yahoo!, Yandex, WolframAlpha and Bing among the over 100 sources. See http://help.dukgo.com/customer/portal/articles/216399-sources
So when you search DDG you AFAIU also search, e.g., Yandex. This probably means that, e.g., FSB will have the ability--with a certain probability--to determine based on timing analysis what a Russia-based user searching DDG are searching for, -- provided that FSB has access to Yandex and does Tempora-like monitoring. From co-occurence analysis they as well as NSA might also gain insights: E.g., if I search "Finn Ă…rup Nielsen Sheremetyevo" my name and Sheremetyevo will be linked.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
AFINN scoring on different dimensions
My AFINN word list with words associated with a score for valence may be used for sentiment analysis. Usually when presented with a text - a sequence of words - I would look up the valence of each individual word and either average, sum or take the sum and divide by the square root of the number of words to get a combined value for the valence/sentiment of the text.
In some cases I compute further numbers beyond the valence/sentiment: arousal, ambivalence, positive and negative. The arousal I compute as the sum of the absolute values of the valence of each word. The ambivalence is computed as the difference between the arousal and the absolute of the valence. 'Positive' is the sum of all the positive valence, while 'negative' is the absolute sum of all the negative valences.
These values are really not optimal, but I guess the best one can get when each word is only labeled with a single value. An example of a problematic word is 'surprised' that I would say should have an arousal value, but since the word could indicate both be a negative and a positive surprise I have not added to my word list.
Below in the table is a scoring of a micropost from http://rainbowdash.net/notice/2764341
WordValenceArousalPositiveNegativeAmbivalence zeldatra0.00.00.00.0 I0.00.00.00.0 m0.00.00.00.0 surprised0.00.00.00.0 you0.00.00.00.0 got0.00.00.00.0 my0.00.00.00.0 hair0.00.00.00.0 spot0.00.00.00.0 on0.00.00.00.0 though0.00.00.00.0 considering0.00.00.00.0 how0.00.00.00.0 I0.00.00.00.0 exaggerate-2.02.00.02.0 it0.00.00.00.0 so0.00.00.00.0 much0.00.00.00.0 Thanks2.02.02.00.0 Although0.00.00.00.0 I0.00.00.00.0 dunno0.00.00.00.0 why0.00.00.00.0 Total0.04.02.02.04.0
Here the sum is the result. If the average (over words) should be the result then I would normalized with 23, e.g., 4/23=0.17 or if I report with the square root normalization, e.g., 4/sqrt(23)=0.83.
Code: https://gist.github.com/fnielsen/5949814
Getting started with tools on Wikimedia Tool Labs
Direct Wikipedia database access has been possible through toolserver handled by Wikimedia Deutschland. Now Wikimedia Foundation has setup the Wikimedia Tool Labs with database access. There are lengthy setup instructions and I managed to gain an account and begun experimenting.
Rather that ssh mosh tools-login.wmflabs.org is suggested for logging in.
After become <toolname> (in my case become wikiment) helloworlding can be done by placing a file with .py or .php extension in the /public_html directory of the project home directory:
$ cat public_html/helloworld.py #!/usr/bin/python print("Content-type: text/plain\n") print("Hello, World! From Python")
and then the webservice is available from http://tools.wmflabs.org/wikiment/helloworld.py.
From the shell the databases can be accessed by, e.g.:
$ mysql --defaults-file=~/replica.my.cnf -h enwiki.labsdb enwiki_p > SHOW TABLES;
To my surprise I did not find the 'text' table. According to the MediaWiki 1.20 database schema it is the one with the text data (AFAIU). It is not available at the toolserver, but I thought that I had easy access with Wikimedia Tool Labs for sentiment analysis... Perhaps I am not understanding the system correctly?
I have now written a hellodatabase.py webservice (Note "[1:-1]" which got me confused for quite a bit):
#!/usr/bin/python import cgitb cgitb.enable(format='text') import ConfigParser import MySQLdb as dbapi2 FILENAME_MYSQLCONFIG = '/data/project/wikiment/replica.my.cnf' class MySQLConfig(ConfigParser.ConfigParser): def __init__(self): ConfigParser.ConfigParser.__init__(self) self.filename = FILENAME_MYSQLCONFIG self.read(self.filename) print("Content-type: text/plain\n") print("Hello, Database! From Python") # Database configuration mysql_config = MySQLConfig() db_user = mysql_config.get('client', 'user')[1:-1] db_password = mysql_config.get('client', 'password')[1:-1] # Connect and query database connection = dbapi2.connect('dawiki.labsdb', db_user, db_password, 'dawiki_p') cursor = connection.cursor(dbapi2.cursors.DictCursor) cursor.execute('SELECT * FROM revision LIMIT 1;') # Show results for row in cursor: for key, value in row.items(): print("%s: %s" % (key, value))
Debugging is a bit difficult because there is no access to the Apache error.log.