Skip to content

Instantly share code, notes, and snippets.

View Kreijstal's full-sized avatar
↗️

Kreijstal Kreijstal

↗️
View GitHub Profile
@Kreijstal
Kreijstal / tree.js
Last active October 30, 2017 12:05
Some general tree implementation
/* How to use
//Create a node:
var node=new Tree(5);
node.data==5//true
//add Children, accepts a value
node.addChild(10);
//or a tree itself
node.addChild(new Tree(6));
@Kreijstal
Kreijstal / getDups.js
Last active August 29, 2015 14:05
Some script to get filenames and images form threads on ponychans
function getDups(){
var outstring="";
for(var i=0;i<dups.length;i++){
console.log(g[dups[i]].post)
outstring+=Object.keys(g[dups[i]].dups).concat(g[dups[i]].post).map(function(a){return ">>"+a}).join('\n')+'\n\n';
}
return outstring
}
http://jsfiddle.net/z9b2m/44/show/ ?!?!?!??
http://jsfiddle.net/ztfv652d/3/
:D
Other jsfiddles:
http://jsfiddle.net/T7Srr/11/
http://jsfiddle.net/gvKtN/6/show
http://jsfiddle.net/HbhXY/6/show/
http://jsfiddle.net/upnMK/4/show/
@Kreijstal
Kreijstal / recurseloop.js
Last active August 29, 2015 14:05
Object recursive loop, detects infinite recursion
function objectLoop(obj, callback) {
if (!obj) return null;
var it, key, l, currobj = {
obj: obj,
keys: Object.keys(obj),
index: 0
},
nest = [];
mai: while (currobj) {
sec: while (currobj.index < currobj.keys.length) {
@Kreijstal
Kreijstal / getDrawURL.js
Created October 6, 2014 07:28
gets base64 uri of image
function getDrawURL(){
var img=document.createElement('img'),canvas=document.createElement('canvas'),context=canvas.getContext('2d');
img.src='http://fc05.deviantart.net/fs70/i/2013/357/c/8/my_teenage_pony_by_kilala97-d6z4jke.jpg';
canvas.height=img.height;
canvas.width=img.width;
context.drawImage(img,0,0)
return canvas.toDataURL('image/png');
}
function wakeUpMotherfucker(){
open("https://www.youtube.com/watch?v=2GaVRdEJGmM");
}
var wakeUpTime=new Date;
wakeUpTime.setHours(5);
wakeUpTime.setMinutes(25);
setTimeout(wakeUpMotherfucker,wakeUpTime-Date.now());
function agrupateBy3CharacterGroups(words){
var wordsAnswer=[],wordGroups=[],word;
for(var i=0;i<words.length;i++){
word=Word3Chars(words[i]);
for(var _i=0;;_i++){
if(!wordGroups[_i]){wordGroups[_i]=word;wordsAnswer[_i]=words[i];break}else{
if(wordsAnswer[_i].length<120&&!hasSharedChildren(wordGroups[_i],word)){
wordsAnswer[_i]+=" "+words[i];wordGroups[_i]=wordGroups[_i].concat(word);break
}
}
document.getElementsByTagName('textarea')[0].value.replace(/SHAPE=[^:]+:0/g,function(a){return a.substr(0,a.length-1)+(Math.floor(Math.random()*0xFFFFFF))}).replace(/\n/g,"\r\n")
@Kreijstal
Kreijstal / iterative stack based descent context-sensitive parser.js
Last active November 21, 2017 17:44
Parser that should parse most things.
//Helper functions
//Tree Implimentation from https://gist.github.com/RainbowDangerDash/e006151f60003487e208
function Tree(data) {
this.data = data;
this.children = [];
this.parent = null;
this.length = 0;
this.level=0//useful for debugging how deep a node is
}
Tree.fromJSON = function(jsonTree) {
@Kreijstal
Kreijstal / mat
Last active August 29, 2015 14:17
m=0:32
x=0:48
function x= pot(x)
x=(-x/4)+8;
end
function x=ric(x)
x=(-x/2)+24;
end
plot(m,pot(m),x,ric(x));