Skip to content

Instantly share code, notes, and snippets.

View PanJarda's full-sized avatar

Jaroslav Pernica PanJarda

  • Prague, Czech Republic
View GitHub Profile
@PanJarda
PanJarda / vm.js
Created February 19, 2017 18:13
Stack based JIT vm in JS
var c,i,s,p,opcodes
c = '10 20 add 5 sub'
i = 0
s = new Array(100)
p = -1
opcodes = {
'add': 's[p - 1] = s[p--]*1 + s[p]*1',
'sub': 's[p - 1] = s[p - 1]*1 - s[p--]*1;'
}
@PanJarda
PanJarda / self-modifying.js
Last active February 16, 2017 21:57
Self modyfiing js
/**
* Self modifying code
*/
function genF(x) {
return new Function('x', 'return x + ' + x)
}
function screw(f) {
var src = f.toString()
@PanJarda
PanJarda / telseznam.js
Created February 16, 2017 12:49
Tel. seznam trie
/**
* Tel seznam trie
*/
function trie(key, value) {
key += ''
var t = {}
key.length > 1 ? t[key[0]] = trie(key.substring(1), value) : t[key] = {val: value}
return t
}
@PanJarda
PanJarda / trie.js
Created February 16, 2017 11:10
Trie in js
/**
* Trie
*/
function trie(s) {
s += ''
var t = {}
s.length > 1 ? t[s[0]] = trie(s.substring(1)) : s.length ? t[s] = false : t = false
return t
}
function Tuple(car, cdr) {
this.car = car
this.cdr = cdr
}
function List(val) {
Tuple.call(this, val, null)
}
List.prototype = Object.create(Tuple.prototype)
#!/bin/bash
# Sleduje online prenos zapasu a pri zmene skore odesle sms pres script sms.sh.
source ~/shell/colors.sh
skoreOld=""
skore=""
yellow "\n SMS ONLINE SPORT CHECKER \n"
while [ 1=1 ]
do
wget -q http://www.onlajny.com/match/index/date/2014-04-27/id/102805
skore=`grep "hlavniSkore" 102805 | sed 's/item_102805_1//g;
#!/bin/sh
DATA=~/shell/todo.csv
h(){
echo 'h - help\np - print\nl - last\ni - insert\nd - delete\nw - write\nq - quit'
}
q(){
exit
}
p(){
printf '%2s %1s %-42s %-4s %-6s\n' 'id' 'p' 'polozka' 'doba' 'termin'
#!/bin/sh
DOMAIN='www.olomouc.eu'
date +%T
echo $DOMAIN > sitemap.txt
while read url
do
echo "nacitam adresu $url"
@PanJarda
PanJarda / fn.js
Last active August 24, 2016 20:39
// partially invoked function
function add(x, y) {
if (arguments.length == 1)
return function(y) {return x + y}
return x + y
}
// pipe function for chaining function calls
function pipe() {
/*
* zadani bylo neco jako vytvorit funkci ktera bude zamenovat znaky podle posunu o naky misto v abecede
*/
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char znak;
char sifra;
} zamena;