This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (!($ = window.jQuery)) { // typeof jQuery=='undefined' works too | |
| script = document.createElement('script'); | |
| script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'; | |
| script.onload = videodropper_bookmarklet; | |
| document.body.appendChild(script); | |
| } | |
| else { | |
| videodropper_bookmarklet(); | |
| } | |
| d = document; b = d.body; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # script for converting Google Spreadsheets .CSV file to JSON | |
| import csv | |
| import simplejson as json | |
| f = open('path/to/filename.csv', 'r') | |
| reader = csv.reader(f) | |
| keys = ('Name', 'Address') #replace/add keys here | |
| out = [] | |
| out = [dict(zip(keys, property)) for property in reader] | |
| out.remove(out[0]) # removing the first row- keys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <form name="guess"> | |
| <input type="text" name="num"> | |
| <input type="button" onclick="checkGuess()" value="Submit"> | |
| </form> | |
| <script type="text/javascript"> | |
| var answer = Math.floor(Math.random()*11); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def HCF(a,b): | |
| ''' Returns HCF(highest common factor) of a and b | |
| http://en.wikipedia.org/wiki/Euclidean_algorithm | |
| ''' | |
| great = max(a,b) | |
| less = min(a,b) | |
| great = great % less | |
| if great == 0: | |
| return less | |
| return HCF(great, less) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''Checks the state of AC adapter(online or offline) and suspends the computer if offline''' | |
| #while true ; do python2.7 loadsave.py ; sleep 5m; done | |
| import os | |
| comm = '''dbus-send --system --print-reply --dest="org.freedesktop.UPower" \ | |
| /org/freedesktop/UPower org.freedesktop.UPower.Suspend''' | |
| def loadsave(): | |
| os.system("acpi -a > powerinfo.txt") | |
| f = open('powerinfo.txt', 'r') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tf = 0 | |
| t = 1 | |
| (1..100).each do |num| | |
| if num % 3 == 0 and num % 5 == 0 | |
| tf += 1 | |
| else if num % 3 == 0 and num % 5 != 0 | |
| t += 1 | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''Verifies the Central Limit Theorem for a given Probability Mass Function(PMF) | |
| ''' | |
| import Cdf #http://greenteapress.com/thinkstats/Pmf.html | |
| import Pmf #http://greenteapress.com/thinkstats/Cdf.html | |
| from thinkstats import Mean #http://greenteapress.com/thinkstats/thinkstats.html | |
| from matplotlib import pyplot | |
| pmf = Pmf.MakePmfFromDict( {1:3, 3:7, 6:9, 10:4, 5:9, 10:4, 11:5, 12:8} ) | |
| cdf = Cdf.MakeCdfFromPmf(pmf) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import randint | |
| from matplotlib import pyplot | |
| def gen_mean(sample_size): | |
| sum = 0 | |
| for i in range(sample_size): | |
| sum += randint(1, 100) | |
| mean = ( float(sum) / sample_size ) | |
| return mean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import division | |
| def trapezium(f, n, a, b): | |
| ''' | |
| f- function [f(x)] | |
| n- number of trapeziums | |
| a- lower limit | |
| b- upper limit | |
| Returns definite integral of f(x) from range a to b | |
| ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function quicksort(a) { | |
| if (a.length == 0) return []; | |
| var great = [], less = [], pivot = a[0]; | |
| for (i=1; i<a.length; i++){ | |
| if (a[i]>pivot) | |
| great.push(a[i]); | |
| else { |