Skip to content

Instantly share code, notes, and snippets.

function doubleInteger(i) {
// i will be an integer. Double it and return it.
return i + i;
}
@Zirak
Zirak / 1.cinderella.md
Last active December 23, 2015 22:09
Beauty and the knife.
1. Cinderella.

drip, drip, drip

What is that sound? Did someone leave the tap on? Is there a leak somewhere?

drip, drip, drip

Maybe it's raining. It hasn't rained in a long time. She remembers one rainy day in particular, from before she planted her wishing tree under which she weeps. She remembers the smell of sweat, clinging cloth to skin, streaming down a forehead. The all-too-red blush on cheeks. Wheezing and coughing and puffing, creaking planks and a leaky roof (her father will fix it, surely).

@Zirak
Zirak / calc.py
Created August 26, 2013 14:20
A Shunting Yard implementation in Python
#this program uses the Shunting Yard algorithm to transform infix expressions
# into postfix, and then an AST, which can then be easily evaluated.
#just run `python calc.py` and enjoy. enjoyment is optional and not included
# with the standard calc.py package, but for an extra $99.99 we can have a
# calc.py Premium Deluxe sent to you over the next 6-8 weeks, which may or may
# not increase your enjoyment of our calc.py product.
#for a list of operators supported and not supported (for isntance, the unary -
# is a ~) look below.
#TODO: handle parentheses.
@Zirak
Zirak / maggot-brain.md
Created August 6, 2013 21:42
Maggot brain. A snippet and a doodle of an image.

http://i.imgur.com/VweM73H.jpg

Maggot Brain

Lying to your right, she turned to face you, her right arm under her head, her left folded across her chest. Her hair fell over the sides of her head, lookig faintly almond-like in the scarcely moonlit room. You were half awake, in a daze, your head heavy. Between nearly shut eyes, you could see her lips moving. "Here, little maggot brain".

["here little maggot brain" repeated in several ways, over a rough sketch of a blank face]

It passed through your head. Over and over. "Here, little maggot brain". Was it inviting? Was it mocking? Was it a question, or a statement?

@Zirak
Zirak / obox.user.js
Created July 12, 2013 15:01
SO-Chat onebox utility and example
Array.some = function (arr) {
return [].some.apply(arr, [].slice.call(arguments, 1));
};
//not a good idea later on, but in dev, it's priceless when chaining
Object.defineProperty(Object.prototype, 'log', {
value : function log () {
console.log(this);
return this;
},
@Zirak
Zirak / gist:5753066
Last active December 18, 2015 08:19
A short story about a lost balloon
I had a balloon.
But I don't any more.
One day,
I got up,
and the balloon was gone.
I looked in the closet,
in the drawer,
in the other pocket,
But the balloon was just gone.
It was pretty sad.
@Zirak
Zirak / gist:5644118
Last active June 30, 2016 16:20
Permission system

Overview

Current situation: A small amount of users annoy the lot of us, we have no power to ban them, mods are annoyed.

Official solution: Go into Gallery mode, so all users can view, only users with explicit write permissions can write. This has the problem of approving users. We don't want to manually approve nearly everyone just to disapprove a small number.

Wayward solution: Use Gallery mode with the bot. When a user enters the room, the bot grants him write access automatically. As it's automatic, the transition is nearly seamless. An owner can then use the bot to ban a user. In that case, the user has his write privilege revoked, and will not be granted write access the next times he comes.

Bot interface

(For an explanation how it functions with the chat, see the file below)

@Zirak
Zirak / gist:5609568
Last active December 17, 2015 12:29
Fun with logic
Beginning of discussion:http://chat.stackoverflow.com/transcript/message/9502109#9502109
Beginning of exercises shown below: http://chat.stackoverflow.com/transcript/message/9502812#9502812
Assumption: ↑ (nand) is defined
not A = ¬A = A ↑ A
A and B = A ∧ B = ¬(A ↑ B)
A or B = A ∨ B = ¬(¬A ∧ ¬B)
@Zirak
Zirak / guid.test.js
Last active December 16, 2015 20:19
//once again, scroll to the bottom
var stat = {};
//the arithmetic mean. takes nargs or an array
//passing in 0 numbers is undefined behaviour
// μ = (x0 + x1 + ... + xn) / n
stat.mean = function (x) {
var nums = Array.isArray(x) ? x : arguments,
sum = 0;
@Zirak
Zirak / mk_awsm.js
Last active December 12, 2015 01:29
//ths fnctn tks sntnc nd trns t t awsm
//md fr jvscrpt rm
// http://chat.stackoverflow.com/transcript/message/7491494#7491494
var mk_awsm=function(sntnc){
return sntnc.split(' ').map(function(wrd){
return 1>=wrd.length?wrd:
2==wrd.length?wrd[0]:
/:.*(.)/.test(wrd)?wrd.replace(/:.*(.)/, '$1'):
wrd.split('').map(function(c,i){
return 0!=i&&('a'==c||'e'==c||'o'==c||'u'==c||'i'==c||(1!=i%2&&.15>Math.random()))