Skip to content

Instantly share code, notes, and snippets.

Avatar

Josiah South Jhawins

  • Nebraska
View GitHub Profile
@Jhawins
Jhawins / ent.js
Created Sep 26, 2014
encodeHTMLEnt()
View ent.js
function encodeHTMLEnt (str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
}
return buf.join('');
};
View server.js
var http = require("http");
function start() {
function onRequest(request, response) {
console.log("Request received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
@Jhawins
Jhawins / multiplicationTable.js
Created Jun 27, 2014
Print multiplication table in console (for no reason)
View multiplicationTable.js
function multiplicationTab(times) {
var times = times||10;
var start, line = '';
for (var a = 1; a < times; a++) {
line = '';
start = a;
for (i=0; i<times; i++, line+=(i*start).toString()+' ' );
console.log(line);
}
}
View timezones.js
timezones = Array(
"Africa/Abidjan",
"Africa/Accra",
"Africa/Addis_Ababa",
"Africa/Algiers",
"Africa/Asmara",
"Africa/Bamako",
"Africa/Bangui",
"Africa/Banjul",
"Africa/Bissau",
View gist:6a690ee13ccac669d375
var a=function(b){var c;0==b?c="PT09PSBBViBCbHVlSmF5IFBybzogTUVHQVRST04gRURJVElPTiA9PT09":1==b?c="TGljZW5zZSBlVzkxY2lCaWIyOWljeUJoY21VZ1pHVnNhV05wYjNWeg==":2==b?c="ClNDQU5OSU5HIENPTVBVVEVSIEZPUiBWSVJVU0VTLi4u":3==b?c="Cgo9PT0gU0NBTiBDT01QTEVURSA9PT0=":4==b?c="Q09NUFVURVIgQ0xFQU4=":5==b?c="VEhBTktTIEZPUiBVU0lORyBBViBCbHVlSmF5IFBybzogTUVHQVRST04gRURJVElPTg==":6==b?c="REVURUNURUQgJXMgVklSVVNFUw==":7==b?c="Q0xFQU5JTkcgQ09NUFVURVIuLi4=":8==b?c="CgpDTEVBTlVQIENPTVBMRVRF":9==b?c="REVMRVRFRCBBTEwgVklSVVNFUw==":
10==b&&(c="Li4u");console.log.apply(console,[atob(c)].concat([].slice.call(arguments,1)))};a(0);a(1);a(2);setTimeout(function(){a(3);if(0.5>Math.random())a(4),a(5);else{var b=Math.floor(42*Math.random());a(6,b);a(7);setTimeout(function(){a(8);a(9);a(5)},aDots(4*b))}},aDots(60));function aDots(b){b=1E3*(Math.floor(4*Math.random())+b);var c=Date.now()+b,d=setInterval(function(){Date.now()>=c?clearInterval(d):a(10)},5E3);return b};
@Jhawins
Jhawins / starDeath.js
Last active Aug 29, 2015
Mwahahahahahaha
View starDeath.js
function fireAj(id) {
$.ajax({
type: 'POST',
url: "http://chat.stackoverflow.com/messages/" + id + "/unstar",
data : {fkey: fkey().fkey},
}).done(function(json) {
console.info('unstarred :'+ id);
});
}
@Jhawins
Jhawins / colors.js
Last active Aug 29, 2015
Supports `-g` flag and strips all others (I expect people to try other flags even though they don't exist)
View colors.js
'use strict';
module.exports = function(bot, IO) {
function color ( args ) {
var outType, base, param;
if ( args.match( /-g/ ) ) { //the only flag for this is g(gradient)
outType = 'gradient=';
} else outType = 'color=';
base = 'http://jhawins.tk/colors.php?';
View toolTip.css
div.tooltip { //Hey it works
background-color: #3D6199;
color: White;
position: absolute;
left: 100px;
top: 0px;
z-index: 1000000;
width: auto;
height:auto;
border-radius: 5px;
View colors.php
<?php
//This script generates a color palette or gradient based on [hexadecimal, short-hex, rgb, color name] values sent through _GET['color'] or _GET['gradient]
$colors = $_GET['color'];
$gradient = $_GET['gradient'];
if (isset($colors)) { //added these to avoid sending a blank page with image headers.
header('Content-Type: image/png');
$type = 'color';
} else if (isset($gradient)) {
header('Content-Type: image/png');
View balls.js
controls = function () {
this.phi = Math.random() * 10;
this.ballSize = Math.random() * 10;
};
var fps = 60;
var frameStart = 1;
var frameEnd = 5500;
var frame = frameStart;
You can’t perform that action at this time.