Skip to content

Instantly share code, notes, and snippets.

View towerofnix's full-sized avatar
🏳️‍⚧️
𝄞‍ — keeping busy's more fun in good company

(quasar) nebula towerofnix

🏳️‍⚧️
𝄞‍ — keeping busy's more fun in good company
View GitHub Profile
@towerofnix
towerofnix / detectplugins.js
Created July 13, 2015 14:41
Detect some plugins
var plugins = navigator.plugins;
var hasUnity = false;
var hasJavaApplet = false;
var hasFlash = false;
var hasSilverlight = false;
for (var i = 0; i < plugins.length; i++) {
//console.log("%c"+plugins[i].name+"%c "+plugins[i].description, "font-weight: 800", "font-weight: default");
if(plugins[i].name==="Unity Player") hasUnity = true;
if(plugins[i].name==="Java Applet Plug-in") hasJavaApplet = true;
if(plugins[i].name==="Shockwave Flash") hasFlash = true;
@towerofnix
towerofnix / loottables.java
Last active October 22, 2015 18:21
Tad bit of hacking around Minecraft led me to this
import com.google.common.base.Charsets;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.io.Files;
import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import java.io.File;
@towerofnix
towerofnix / syntacticsugar.js
Created November 5, 2015 23:49
Faking JavaScript syntactic sugar
/*\
| Faking JavaScript syntactic sugar
|
| Feel free to fork this to add more information!
|
| Remember to utilize ES6 things, because why not?
| It's standardized!
\_
| Contents:
|
// ==UserScript==
// @name Comment Sentiment
// @namespace http://joshuapullen.com/
// @version 0.1
// @description Colors comments based on whether they are mostly positive of negative
// @author Josh Pullen
// @match https://scratch.mit.edu/projects/*
// @match https://scratch.mit.edu/users/*
// @match http://scratch.mit.edu/projects/*
// @match http://scratch.mit.edu/users/*
[img]http://i.cubeupload.com/yeITn7.png[/img]
[url=http://liam4.github.io/programming-language-thing/codemirror/]Use it online[/url] [b]if on Firefox Nightly[/b] (or some other great ES6+ browser)
[url=https://github.com/liam4/programming-language-thing]Learn more[/url] about [big]P[/big]rogramming [big]L[/big]anguage [big]T[/big]hing!
Please give input :P
It's really, really in-development. Expect lots to change. :)
/* Notes: **READ ALL OF THESE**
Original source of the program is here:
https://scratch.mit.edu/discuss/post/1868091/
I've slightly modified the code (pretty-printed, renamed a couple variables,
etc. - don't forget to read these notes! - but the old code is still intact
here. If you're curious about what the original entirely non-modified code
was though don't hesitate to open that link. :P
@towerofnix
towerofnix / annotationdata.js
Last active March 27, 2016 20:51
don't increase limit in doTheThing over like 5 because youtube will probs ban your IP
var urls = {
proxy: (u) => `//crossorigin.me/${u}`,
proxy: (u) => u,
annotations: (id) => urls.proxy(`https://www.youtube.com/annotations_invideo?video_id=${id}`),
isYouTube: (u) => !!u.match('https://www.youtube.com/'),
getYouTubeID(u) {
var res = u.match(/\?v=([^$&]+)/);
return res ? res[1] : '';
}
};
// str should be a great big binary string, e.g. '01101010'
// the string gets split into 8 bits of ascii codes, and then
// the characters are gotten from those
str = str.split('').filter(c => c === '0' || c === '1').join('')
new Array(str.length / 8)
.fill('')
.map((_,i) => str.slice(i*8,i*8+8))
.map((s) => String.fromCharCode(parseInt(s, 2)))
var fcc=String.fromCharCode;var a=(([] + [])/([]/[])).toString() + "\x61\x6C\x61\x6E\x27";var b=!([] + ![])[!{}/[]/{}] + "\x20\x68\x34\x78\x6F\x72\x73";var c=(typeof [[(([] + [])/([]/[]))-2][0]][undefined]);var out=fcc(c[0].charCodeAt(0)-11).toUpperCase()+c[0]+fcc(c[1].charCodeAt(0)+5)+b[0];out=out+b[4]+a[1].toLowerCase()+a[0].toLowerCase()+b[8]+fcc(c[4].charCodeAt(0)+14)+b[5]+c[3]+b[9],out=out+b[4]+fcc(c[0].charCodeAt(0)-11).toUpperCase()+a[1]+fcc(Math.pow(10,2)+18)+a[1]+b[10].toUpperCase()+fcc(Math.pow(9,2)+18)+b[9]+c[5]+fcc(Math.pow(12,2)-32)+b[0],out=out+b[4]+b[5]+b[6]+b[7]+b[8]+b[9],alert(out);
@towerofnix
towerofnix / datatagserialize.js
Last active August 7, 2016 01:24
A handy function to convert your JS data to data tags.
const dataTagSerialize = function(data) {
if (typeof data === 'object') {
if (Array.isArray(data)) {
const elements = data.map(x => dataTagSerialize(x))
return `[${elements.join(',')}]`
} else {
const keyValues = []
for (let prop of Object.getOwnPropertyNames(data)) {
keyValues.push([prop, dataTagSerialize(data[prop])])
}