Skip to content

Instantly share code, notes, and snippets.

@tanelpuhu
tanelpuhu / arp.sh
Last active August 29, 2015 13:56
phone-is-home
#!/bin/bash
# http://www.reddit.com/r/raspberry_pi/comments/1yrudi/a_simple_bash_script_for_detecting_the_presence/
MACS=`arp -an | awk '{print $4}'`
IFS='\n'
read -a MAC_ARRAY <<< "${MACS}"
for MAC in $MAC_ARRAY
do
$('#leftbar').remove();
$('#price').css({
'font-size': '50px',
'height': '60px',
'line-height': '60px'
});
@tanelpuhu
tanelpuhu / just-dice.com.js
Last active December 23, 2015 12:39
~/.js/just-dice.com.js (google "dotjs") with graphs... lil too much right?
/* jquery.sparkline 2.1.2 - http://omnipotent.net/jquery.sparkline/
** Licensed under the New BSD License - see above site for details */
(function(a,b,c){(function(a){typeof define=="function"&&define.amd?define(["jquery"],a):jQuery&&!jQuery.fn.sparkline&&a(jQuery)})(function(d){"use strict";var e={},f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L=0;f=function(){return{common:{type:"line",lineColor:"#00f",fillColor:"#cdf",defaultPixelsPerValue:3,width:"auto",height:"auto",composite:!1,tagValuesAttribute:"values",tagOptionsPrefix:"spark",enableTagOptions:!1,enableHighlight:!0,highlightLighten:1.4,tooltipSkipNull:!0,tooltipPrefix:"",tooltipSuffix:"",disableHiddenCheck:!1,numberFormatter:!1,numberDigitGroupCount:3,numberDigitGroupSep:",",numberDecimalMark:".",disableTooltips:!1,disableInteraction:!1},line:{spotColor:"#f80",highlightSpotColor:"#5f5",highlightLineColor:"#f22",spotRadius:1.5,minSpotColor:"#f80",maxSpotColor:"#f80",lineWidth:1,normalRangeMin:c,normalRangeMax:c,normalRangeColor:"#
@tanelpuhu
tanelpuhu / movs.py
Last active December 21, 2015 15:29
#!/usr/bin/env python
# coding=utf-8
import feedparser
import requests
import urlparse
import hashlib
import urllib
import time
import sys
import os
#!/usr/bin/env python
from dbus.mainloop.glib import DBusGMainLoop
import subprocess
import gobject
import dbus
appName = 'Spotify Media Keys'
@tanelpuhu
tanelpuhu / dotjs.py
Created February 26, 2013 17:59
~/.js (python)
#!/usr/bin/env python
# github.com/kasun/YapDi.git
import yapdi
from BaseHTTPServer import BaseHTTPRequestHandler
from BaseHTTPServer import HTTPServer
import ssl
import sys
import os
@tanelpuhu
tanelpuhu / prereindent.py
Created January 23, 2013 07:47
reindent.py replaces tabs in litterals
#!/usr/bin/env python
import sys
import os
if len(sys.argv) < 2:
print os.path.basename(sys.argv[0]), 'path'
sys.exit()
def handle_file(directory, file):
fullpath = os.path.join(directory, file)
gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"
@tanelpuhu
tanelpuhu / gist:1482536
Created December 15, 2011 19:46
has_falsy
def has_falsy(lst):
def is_falsy(val):
return not val
return not not len(filter(is_falsy, lst))
assert not has_falsy([])
assert not has_falsy([1,2,3])
assert not has_falsy(['0'])
assert not has_falsy(['None'])
assert has_falsy([None])
def render(view, data = None):
current_dir = os.path.dirname(__file__)
path = os.path.abspath(
os.path.join(current_dir, '..', 'views', '%s.html' % view)
)
if not os.path.exists(path):
return '404 - view not found!'
if data is None:
data = {}
return template.render(path, data)