This file contains hidden or 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
/* Simple WebSocket API. | |
* Dependencies: none. | |
* | |
* Message fields: | |
* msgid: server replies must match this | |
* data: the actual data | |
* | |
* Interface in a nutshell: | |
* - var sd = sock.open("ws://host:port", open_callback) | |
* - sock.send(sd, data, reply_callback); |
This file contains hidden or 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
#include <wchar.h> | |
typedef struct { | |
wchar_t cs; | |
wchar_t flags[8]; | |
wchar_t mod[3]; | |
int w; | |
int len; | |
} Printf; |
This file contains hidden or 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 fib() { | |
var a = 0, b = 1; | |
return function() { | |
var t = a; | |
a = b; | |
b = t + b; | |
return a; | |
}; | |
} |
This file contains hidden or 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 trackxhr() { | |
var oxhr = window.XMLHttpRequest.prototype.open; | |
window.XMLHttpRequest.prototype.open = function(method, url, async, usr, pwd) { | |
console.log("XHR OUT", url); | |
this.addEventListener("load", function() { | |
console.log("XHR IN", this.responseText); | |
}); | |
return oxhr.apply(this, arguments); | |
}; |
This file contains hidden or 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
/* Do not use code you have not read first. | |
* Original file: https://gist.github.com/clamiax/e1db98deaf94bb1ccf8556d993245afb */ | |
(() => { | |
"use strict"; | |
var eventsmap = []; /* on(), onevent(), off() */ | |
function $(sel, ctx = document) { | |
return ctx.querySelector(sel); | |
} |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
void onperm(char *s, int len); | |
unsigned powu(unsigned base, unsigned exp); | |
int srperm(char *s, int len, void (*fn)(char *, int)); | |
void | |
onperm(char *s, int len) { |
This file contains hidden or 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
#include <stdio.h> | |
#include <string.h> | |
void swap(char *a, char *b); | |
void onperm(char *s); | |
void sperm(char *s, int len, int cur, void (*fn)(char *s)); | |
void | |
onperm(char *s) { | |
printf("%s\n", s); |
This file contains hidden or 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
define("SESSION_FILE", "/tmp/session.txt"); | |
$session = []; | |
function sess($k, $v = NULL) { | |
global $session; | |
if($session == NULL) { | |
if(!file_exists(SESSION_FILE)) | |
touch(SESSION_FILE); | |
$session = file_get_contents(SESSION_FILE); |
This file contains hidden or 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
/* | |
* For example, the following code: | |
* | |
* table(["id", "word"], [ | |
* ["id" => 1, "word" => "Hello"], | |
* ["id" => 2, "word" => "world"] | |
* ]); | |
* | |
* prints this table: | |
* |
This file contains hidden or 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
/* Sample usage: html2zc(document.documentElement); */ | |
(function() { | |
"use strict"; | |
function parse(node, code) { | |
var chld = [], i, nc, c; | |
if(skipnode(node)) | |
return; | |
code += tozc(node); |