Skip to content

Instantly share code, notes, and snippets.

@macieksk
macieksk / download_reddit_saved_links.py
Created June 6, 2014 20:26
Download csv, json with your reddit saved links.
@macieksk
macieksk / click_onclick_elem_extract_data.js
Created June 6, 2014 16:52
jquery onclick click, data extraction, replace, join, map
$('a').filter(function(){
return $(this).text() === 'Display Full Polymer Details';
})
.click()
$("span.se_key").filter(function(){ return $(this).text().match(' Gene Name[s]* ');})
.parent().siblings("td.mdauData")
.map(function(){return $(this).parents("tbody.query").find("a.qrb_structid").text()
+","
+$(this).text().trim().replace(/\s+/g,",");})
@macieksk
macieksk / 0_reuse_code.js
Created June 6, 2014 14:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@macieksk
macieksk / uniquequeue.py
Last active August 5, 2023 02:54
Unique Priority Queue based on the PriorityQueue class. These priority queues accept tuples as input, where first component is a priority, second component is a key, which is used to identify unique values, third and all further component(s) is an (optional) value.
# -*- coding: utf-8 -*-
#Unique priority queues in Python
#@author: "Maciek Sykulski"<[email protected]>
#@blog: http://breakthecircles.blogspot.com/2013/10/unique-priority-queues-in-python.html
from Queue import PriorityQueue
import heapq
class UniquePriorityQueue(PriorityQueue):
@macieksk
macieksk / fixpaths.sh
Created January 17, 2012 15:45
Fix paths for Sage 4.7.2 binary build so that one can install new packages in R
# To be run inside main sage-4.7.2 dir or alike
# Files TOFIX are usually those:
# local/bin/R local/lib/R/bin/libtool local/lib/R/bin/R local/lib/R/etc/ldpaths local/lib/R/etc/Makeconf local/lib/R/etc/Renviron
#Change here for different versions of sage
ORGPATH="/mnt/usb1/scratch/buildbot/sage/sage-1/sage_binary/build/sage-4.7.2"
DIR=`pwd`
SED="s|$ORGPATH|$DIR|g"
TOFIX=`grep -lI $ORGPATH -R local/ | grep /R`
@macieksk
macieksk / dmesg_time.sh
Created July 26, 2011 12:38
dmesg messages time retrieval (hours or minutes ago)
#!/bin/bash
#Usage: dmesg | grep eth3 | dmesg_time.sh
for time in $(egrep -o '[0-9]+\.[0-9]+')
do
TIME="`echo "($(awk '{print $1}' /proc/uptime) - $time) / 60 / 60" | bc`h" # Hours
TIME="$TIME or `echo "($(awk '{print $1}' /proc/uptime) - $time) / 60" | bc`m" # Minutes
echo "$TIME ago"
done
@macieksk
macieksk / parallelListDB.py
Created March 16, 2011 03:52
multiprocessing, threading, pool, with access to db, web2py, parallel list process with example
#import threading
from multiprocessing import Process,Queue,Pool
from gluon.shell import exec_environment
def parallelListDB(fun, lst, nthreads=2, request=None,
timeout=10, aggregate = lambda lst: it.chain(*lst)):
assert request!=None
q=Queue()