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
import os | |
import crc32 | |
import strformat | |
import strutils | |
import nre except toSeq | |
import ../lib/die | |
let pat = re(r".*\[([0-9A-Fa-f]{8})\].*") |
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
interface UserAgentInfoPart { | |
name: string; | |
version?: string; | |
detail?: string[]; | |
} | |
type UserAgentInfo = UserAgentInfoPart[]; | |
const re = /(\w+)(\/([0-9.]+))?( \((.*)\))?/g; |
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
# a - alphabet | |
# n - sequence length | |
# | |
# Example | |
# | |
# cartperm([0, 1], 3) | |
# # => [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]] | |
# | |
def cartperm(a, n) | |
a.product(* [a] * (n - 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
class Hash | |
def iloc(i, *rest, set: nil) | |
if rest.empty? | |
self[i] = set if set | |
self[i] | |
else | |
self[i] = Hash.new if not self[i] | |
self[i].iloc(*rest, set: set) | |
end | |
end |
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 roll(probs) | |
r = rand | |
cum = 0 | |
outcome = probs.keys.first | |
outcome_prob = 0 | |
probs.each do |key, prob| | |
cum += prob | |
if cum >= r | |
outcome = key | |
outcome_prob = prob |
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
:root { | |
/*--z-color-accent: #F0360D;*/ | |
--z-color-accent: #E25821; | |
--z-color-background-dark: #212121; | |
--z-color-background-light: #424242; | |
} | |
/* colors */ | |
html#main-window { |
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 pickle_load(filename): | |
return pickle.load(open(filename, "rb")) | |
def pickle_dump(data, filename): | |
return pickle.dump(data, open(filename, "wb")) | |
def pickle_get(filename, fn, *args, fresh=False, verbose=False): | |
"""Try to load data from a pickle file. Compute it with `fn` and save it if it doesn't exist.""" | |
if not fresh and file_exists(filename): | |
if verbose: |
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
.bar { | |
border: solid 1px rgba(0, 0, 0, 0.3); | |
} |
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 re = /(\w+)(\/([0-9.]+))?( \((.*)\))?/g; | |
/** | |
* Parse a user agent string into logical parts. | |
* | |
* @param {string} userAgentStr - The user agent string to parse | |
* @return {object[]} The information parsed from the user agent string | |
*/ | |
function parseUserAgent(userAgentStr) { | |
const parsed = []; |
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
#include <stdlib.h> | |
#include "ll.h" | |
struct ll* ll_create() { | |
struct ll* list = (struct ll*) malloc(sizeof(struct ll)); | |
list->head = NULL; | |
list->length = 0; | |
return list; | |
} |