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
var p = Math.log(20)/Math.log(2) - 1; | |
function binarise(x) | |
{ | |
if(x === 0) | |
{ | |
return 0; | |
} | |
if(x === 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
// ==UserScript== | |
// @name Chat Commands | |
// @namespace StackScripts | |
// @description commands that can be executed in chat | |
// @version 1 | |
// @grant none | |
// @include http://chat.stackexchange.com/rooms/1/sandbox | |
// @include http://chat.stackexchange.com/rooms/35/the-bridge | |
// @author http://english.stackexchange.com/users/3559/matt-%D0%AD%D0%BB%D0%BB%D0%B5%D0%BD | |
// ==/UserScript== |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>sandpile</title> | |
</head> | |
<body> | |
<canvas id="canv" width="300" height="300"></canvas> | |
<script src="js/sandpile.js" type="text/javascript"></script> | |
</body> | |
</html> |
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 string_distance(s1, s2): | |
allchars = ''.join(sorted(set(s1+s2))) | |
s1vals = [allchars.index(c) for c in s1] | |
s2vals = [allchars.index(c) for c in s2] | |
diffs = [abs(x-y) for x,y in zip(s1vals,s2vals)] | |
lengthdiff = abs(len(s1)-len(s2)) | |
return sum(diffs)+lengthdiff |
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
#! python | |
import os | |
import shutil | |
import argparse | |
import json | |
parser = argparse.ArgumentParser(description='Creates a report about the distribution over folders of disk use.') | |
parser.add_argument('drive_letter', nargs=1, metavar='drive letter', help='The drive that should be analysed.') |
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
const NORMAL = 0; | |
const FOUNDAMP = 1; | |
const FOUNDHASH = 2; | |
const FOUNDX = 3; | |
const FOUNDHEX = 4; | |
const GOTENTITY = 5; | |
const FOUNDDEC = 6; | |
function replaceNumericEntities(input) | |
{ |
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 Processor(instructions) | |
{ | |
this.instructions = instructions.map(i => i); | |
this.instructionPointer = 0; | |
this.input = []; | |
this.inputPointer = 0; | |
this.output = null; | |
this.running = false; | |
this.sendOutput = null; | |
this.relativebase = 0; |
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 Asteroid(position) | |
{ | |
this.position = position; | |
this.slopes = new Map(); | |
} | |
Asteroid.prototype.slopeAndDistance = function(other) | |
{ | |
let xdiff = (other.position.x - this.position.x); | |
let ydiff = (other.position.y - this.position.y); |
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
VALUE_ORDER = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] | |
class PokerHand: | |
def __init__(self, cards): | |
self.cards = [] | |
self.rankName = '' | |
self.original = cards | |
for card_str in cards: | |
self.cards.append(Card(card_str.upper())) | |
self.highest = self.cards[0] |
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
#! /usr/bin/env python | |
from urllib.request import urlopen, Request | |
import urllib | |
import base64 | |
from bs4 import BeautifulSoup | |
import os.path | |
import time | |
import smtplib | |
def main(): |
OlderNewer