Skip to content

Instantly share code, notes, and snippets.

View atomicules's full-sized avatar

atomicules atomicules

View GitHub Profile
@atomicules
atomicules / libreimport.py
Created June 3, 2012 09:37
http://gitorious.org/fmthings/lasttolibre/blobs/master/libreimport.py Record of slight tweaks I've made to this to use the scrobble.log format
#!/usr/bin/python
#modified version of old import.py
# Lastscrape -- recovers data from libre.fm
# Copyright (C) 2009 Free Software Foundation, Inc
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@atomicules
atomicules / bad.R
Created November 20, 2011 14:05
R and data.table for loop bug/nuance. Code extract for embedding in a blog post
#Extract of R code
#This doesn't work properly
#Need to know how many levels
nl <- length(levels(datatable$Grouping))
#then how many per graph
ng = 8
#Can then loop
for (i in 1:ceiling(nl/ng)) {
@atomicules
atomicules / reference_for_pgfsweave-tikz_option.Rnw
Created November 20, 2011 13:45
Some Sweave file extracts for embedding in a blog post, showing different approaches for looping through Lattice plots for Sweave vs Tikz/pgfSweave
%Reference for pgfSweave / Tikz option
%Sweave file extract
\begin{figure}
<<fig=TRUE, tikz=T>>=
print(
xyplot(Y ~ Date | Grouping, datatable[levels(datatable$Grouping)[1:8]], layout=c(1,8), ylim=c(-100,100), xlim=as.Date(c("2011-01-01", "2011-07-01")) )
)
@
\end{figure}
@atomicules
atomicules / faster_use_of_data_table.r
Created October 9, 2011 13:27
Using data.table in R and taking the DT[J("a")] example at face value I ended up with a really slow function.
duplicates.step2$days.between <- sapply(
1:nrow(duplicates.step2),
function(q) {
step2id <- as.character(duplicates.step2.dt[,id][q]) #as.character is important bit!
temp <- min(
difftime(
duplicates.step2.dt[, Date][q],
step1.dt[step2id]$Date, #No need to crazily create another data.table
units=c("days")
)
@atomicules
atomicules / ip-specific-extract.vim
Created September 2, 2011 22:29
Extracts/examples from my .vimrc to make settings conditionally based on OS and network
"IP Address specific
"-------------------
"(i.e. Home or Work)
if ip == -1
"Set proxies, Python urllib2 (TwitVim, Simplenote.vim) will automatically pick
"these up
let $http_proxy = 'http://<username>:<password>@<proxy-url>:<proxy-port>'
let $https_proxy = 'http://<username>:<password>@<proxy-url>:<proxy-port>'
endif
import urllib
import urllib2
import base64
import json
snuser = ""
snpassword = ""
proxyurl = "<proxy url>:<proxy port>"
proxylogin = "<proxy username>:<proxy password>"
@atomicules
atomicules / Smile.coffee
Last active September 26, 2015 06:27
Coffeescript source code for a bookmarklet to generate QIF files for SMILE bank.
#Bookmarklet to generate QIF for Recent Item and Previous Statement pages on SMILE.co.uk bank
#Will (try to) open a new popup window where you will have to either:
#a) Copy text from and paste to text editor (Chrome)
#b) Save the page as a text file (Firefox)
#
#Written in Coffescript, but just use http://javascriptcompressor.com/ to compress the
#compiled javascript so you have a bookmarklet.
data = document.getElementsByClassName("summaryTable")[0].children[1].children
@atomicules
atomicules / bookmark-bar-icons.css
Created May 14, 2011 23:47
Firefox 4 Customisation Notes
/*
Bookmark bar icons, used on OSX and Windows XP
Because I do not understand why Firefox tries to emulate Safari on OSX.
I want the exact opposite: Icons and no text.
This also fixes the default circular hover.
*/
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
#personal-bookmarks toolbarbutton {
/*This for Windows*/
@atomicules
atomicules / gist:955471
Created May 4, 2011 16:01
An Applescript for Camino to Save Tabs to Pinboard. Doesn't work though because of Gecko 1.9 preflighting the request.
--Camino Pinboard save tabs
-- An Applescript to Save Open Tabs to Pinboard, using the Save Tabs functionality:
-- http://blog.pinboard.in/2011/04/new_save_tabs_feature/
-- Uses francois2metz fake html5-FormData since Gecko 1.9 doesn't have this
-- https://github.com/francois2metz/html5-formdata
-- BUT DOESN'T BLOODY WELL WORK BECAUSE OF A RESTRICTION IN GECKO 1.9
-- Gecko 1.9 preflights all requests except from text/plain which screws the whole thing up
-- (https://developer.mozilla.org/en/http_access_control#Preflighted_requests)
-- Oh well, it was a nice idea.
@atomicules
atomicules / pinboard2camino.rb
Created April 21, 2011 10:03
Pinboard to Camino bookmark importer DON'T USE THOUGH - IT'S RUBBISH!
# Pinboard to Camino
#
# A Ruby script to import/update Pinboard bookmarks into Camino
# This is a evolution of this Applescript: https://gist.github.com/835932 which simply deleted and
# replaced a bookmarks collection. This Ruby script attempts to update, rather than delete and replace,
# so Camino bookmark visit counts are preserved, etc.
#
# IT IS VERY SLOW!
#
# Really, it is. Took about 35 mins to run through a Camino bookmarks file with 2003 existing "pinboard"