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
| import * as rx from '@thi.ng/rstream'; | |
| import * as tx from '@thi.ng/transducers'; | |
| // Random string function | |
| const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
| const randstr = (length: number, ret: string = ''): string => | |
| length <= 0 | |
| ? ret | |
| : randstr(length - 1, ret + chars[Math.floor(Math.random() * chars.length)]); |
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
| vim -u NONE -c 'argdo source cmd.vim | w' -c 'qa' foo.txt bar.txt qux.txt |
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> | |
| // Generic closure that you may want to replace with some sort of typed version | |
| // for your own needs and safety. | |
| typedef struct { | |
| void (*call)(void *data); | |
| void *data; | |
| } closure; | |
| closure *closure_init() { return (closure *)malloc(sizeof(closure)); } |
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
| snip = [[time: `!v strftime("%Y-%m-%dT%H:%M:%S%z")` | |
| category: ${1:Category} | |
| note: ${2:Note}]] | |
| print(vim.fn['UltiSnips#AddSnippetWithPriority']('note', snip, 'datetime, category, and note', 'b', 'yaml', 50)) |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width" /> | |
| <title>Client Side Routing Example</title> | |
| <script charset="utf-8"> | |
| const route = (path) => { | |
| const navbar = `<div> | |
| <a href="/" onclick="return route(event.target.pathname)">Home</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
| /* gcc -o out main.c && ./out */ | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <time.h> | |
| typedef struct { | |
| int x; | |
| int y; | |
| } Point; |
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
| let | |
| flatkeys = cur: | |
| if builtins.isAttrs cur then | |
| (builtins.concatMap | |
| (k: builtins.map (x: [ k ] ++ x) (flatkeys cur."${k}")) | |
| (builtins.attrNames cur)) | |
| else if builtins.isList cur then | |
| builtins.concatLists (builtins.genList | |
| (i: builtins.map (x: [ i ] ++ x) (flatkeys (builtins.elemAt cur i))) | |
| (builtins.length cur)) |
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
| WITH q1 AS ( | |
| SELECT | |
| mp.id, | |
| mp.origin_id, | |
| mp.site_name, | |
| mp.title, | |
| mp.url, | |
| mp.visit_count | |
| FROM | |
| moz_places mp |
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
| /* | |
| * diag iterates based on a number of rows in columns across diagonals of a | |
| * 2 dimensions. Iteration starts at the first row and column. For each | |
| * diagonal we go to the dth column and start decrementing the column by 1 | |
| * and incrementing the row by 1 until we reach a boundary. Once we have | |
| * exchausted column we will start at row `d-rows` and continue the | |
| * algorithm. | |
| * | |
| * Fig 1: | |
| * 0 1 2 3 4 |
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
| package main | |
| // This program is an implementation of a gcounter CRDT. A gcounter is a counter | |
| // that is a distributed across nodes and is eventually consistent. Each node | |
| // has it's own local counter and an estimate of the interal states of the other | |
| // nodes. | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| ) |