Skip to content

Instantly share code, notes, and snippets.

я котик пур-пур mvasilkov

Block or report user

Report or block mvasilkov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View jsjs.js
function foo() {
this.a = function () { return 96 }
this.b = function () { return this.a() * 10101 }
}
function bar() {}
bar.prototype = new foo
b = new bar
b.a() // 96
@mvasilkov
mvasilkov / _sin.sjs
Created Aug 19, 2014
Math.sin macro
View _sin.sjs
macro _sin {
case { _($x:lit) } =>
{
var res = Math.sin(unwrapSyntax(#{ $x }))
return [makeValue(res, #{ $x })]
}
case { _($x) } =>
{
return #{ Math.sin($x) }
@mvasilkov
mvasilkov / load.js
Created Aug 28, 2014
Image loader for canvas, suitable for JS13K
View load.js
function load(images, done) {
var toLoad = images.length
var res = Array(toLoad)
var loaded = 0
images.forEach(function (url, i) {
var image = new Image
image.onload = function () {
res[i] = this
if (++loaded == toLoad)
View antialias-test.py
# Tests for antialiasing a high-frequency image in various ways
# Nathan Reed, July 2014
# Written for Python 3.4; requires numpy and Pillow to be installed
import concurrent.futures
import math
import multiprocessing
import numpy as np
import optparse
import random
View install_ensurepip.py
import os
import sys
import io
import tarfile
import urllib.request
ARCHIVE_URL = 'http://d.pr/f/YqS5+'
@mvasilkov
mvasilkov / bash jmp
Created Feb 21, 2015
Bash jmp script
View bash jmp
function jmp { cd -P "$JMP_PATH/$1" 2>/dev/null || echo Not found; }
function setjmp { ln -s "`pwd`" "$JMP_PATH/$1"; }
function deljmp { rm -i "$JMP_PATH/$1"; }
export JMP_PATH="$HOME/.jmp"
View content_script.js
var res = []
parse(document.documentElement)
chrome.runtime.sendMessage(res)
function parse(node) {
var i, a, name = node.tagName.toLowerCase()
res.push({type: 'o', name: name})
for (i = 0; i < node.attributes.length; ++i) {
View gfm.py
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5(matchobj.group(0)).hexdigest()
extractions[digest] = matchobj.group(0)
return "{gfm-extraction-%s}" % digest
@mvasilkov
mvasilkov / power.py
Created Nov 20, 2011
Tail recursive power function
View power.py
from functools import partial, wraps
def power_tail(x, a, n):
assert n >= 0
if n == 0:
return x
elif n & 1:
return partial(power_tail, x * a, a, n - 1)
else:
return partial(power_tail, x, a * a, n >> 1)
@mvasilkov
mvasilkov / p2i.pl
Created Jan 19, 2012 — forked from Ky6uk/i2p.pl
postfix to infix
View p2i.pl
#!/usr/bin/env perl
use 5.01;
do { say "USAGE: $0 <postfix.txt>"; exit 0 }
unless $ARGV[0];
# --------------- main -----------------
my (@data, $char, $result, @stack);
You can’t perform that action at this time.