This file contains 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
import argparse | |
import glob | |
import plistlib | |
import re | |
from os import path, mkdir | |
import yaml | |
''' |
This file contains 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 evil_gen(): | |
a = [0, 0, 0, 0, 0] | |
while 1: | |
for i in range(10): | |
for j in range(5): | |
a[i] = [i+1] | |
yield (a) | |
def good_gen(): | |
while 1: |
This file contains 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
// found from http://pastebin.com/jnEViBPz | |
// simple run in console on duolingo homepage | |
var $words = $('<table><thead><tr><th>Language</th><th>Category</th><th>Word</th><th>Strength</th></thead><table>'); | |
var ld=duo.user.attributes.language_data; | |
var count = 0; | |
var waiting = 0; | |
for(l in ld){ | |
waiting = ld[l].skills.models.length; | |
ld[l].skills.models.forEach(function(e){ | |
var t=e.attributes; |
This file contains 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
//react 0.14.7 | |
saveModel() { | |
this.downloadFile(JSON.stringify(this.props.data, null, ' ')); | |
}, | |
downloadFile(contents) { | |
var newFileContent = new Blob([contents], {type: 'application/octet-binary'}), | |
downloadURL = window.URL.createObjectURL(newFileContent), | |
downloadLink = document.getElementById('file-download-link'); |
This file contains 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
func == (left:UIColor, right:UIColor) -> Bool{ | |
let lref:CGColorRef = left.CGColor | |
let rref:CGColorRef = right.CGColor | |
let lComponents = CGColorGetComponents(lref) | |
let rComponents = CGColorGetComponents(rref) | |
if CGColorGetNumberOfComponents(lref) == CGColorGetNumberOfComponents(rref) { | |
return floor(lComponents[0]*255) == floor(rComponents[0]*255) && | |
floor(lComponents[1]*255) == floor(rComponents[1]*255) && |
This file contains 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
extension Array{ | |
func every(fn: (T)->Bool) -> Bool{ | |
var out = true | |
for i in self { | |
out = out && fn(i); | |
} | |
return out | |
} | |
func some(fn: (T) -> Bool) -> Bool{ | |
var out = false |
This file contains 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
Array.prototype.max = function(){ | |
return this.reduce(function(prev, current){ | |
if (current > prev){ | |
prev = current; | |
} | |
return prev; | |
}, 0); | |
} | |
Array.prototype.min = function(){ |
This file contains 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
//import stuff | |
public void sendPOST(final String url, final ArrayList<NameValuePair> params){ | |
Thread t = new Thread(new Runnable(){ | |
@Override | |
public void run(){ | |
try { | |
HttpClient client = new DefaultHttpClient(); | |
String postURL = url; | |
HttpPost post = new HttpPost(postURL); |
This file contains 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 toggleFullscreen(){ | |
if (!document.fullscreenElement && // alternative standard method | |
!document.mozFullScreenElement && | |
!document.webkitFullscreenElement && | |
!document.msFullscreenElement ) { // current working methods | |
if (document.documentElement.requestFullscreen) { | |
document.documentElement.requestFullscreen(); | |
} else if (document.documentElement.msRequestFullscreen) { | |
document.documentElement.msRequestFullscreen(); | |
} else if (document.documentElement.mozRequestFullScreen) { |
This file contains 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
void sortedInsert(vector<double> &v, double val){ | |
if (v.size() == 0){ | |
v.push_back(val); | |
return; | |
} | |
vector<double>::iterator start = v.begin(); | |
vector<double>::iterator end = v.end(); | |
while (true){ | |
end -= 1; | |
vector<double>::iterator middle = v.begin(); |
NewerOlder