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
// preamble: public domain; no warranty | |
// | |
// this is a toy -- it is slow, cannot handle unicode, keys w/ | |
// spaces, nested keys, natural ordering, etc. | |
// orderBy('key1 [asc|1|desc|-1][, key2 [asc|1|desc|-1]][, etc]') | |
// | |
// write sql-like sort orders for arrays of objects, e.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
# original C code from https://ch-st.de/its-ray-marching-march/ | |
# retrieved, roughly ported, and refactored a little on 2021-03-08 | |
from __future__ import print_function | |
import math | |
import time | |
import sys | |
class Vec3: |
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
/* | |
* returns true/false on "is this string a valid date/datetime string" | |
* | |
* any credit for coolness goes to https://stackoverflow.com/a/44198641, | |
* and any blame for wrongness goes to me. :) | |
* | |
*/ | |
const isValidDate = dateString => { | |
let date = new Date(dateString); // we're gonna use both :0 | |
return ( |
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 ordering_arr = ["primary", "home", "business", "camp", "outhouse", "mars", "pluto"]; | |
const to_sort = [ | |
{ | |
"address": "1", | |
"type": "primary" | |
}, | |
{ | |
"address": "2", | |
"type": "home" |
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 sys | |
import random | |
from collections import defaultdict | |
# some utility classes for nicer printing + default-ints | |
class PrettyDefaultDict(defaultdict): | |
def pprint(self): | |
lines = [] |
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
2016-07-26T15:33:51-04:00 "POST /auth/oauth/token?client_id=<your id>&client_secret=<your secret>&code=b6f682f2518671329bb73a815949fab59ac01e19ac2105cc8bee2718e64b0892&grant_type=authorization_code&redirect_uri=<yours> HTTP/1.0" 200 | |
2016-07-26T15:34:05-04:00 "POST /auth/oauth/token?client_id=<your id>&client_secret=<your secret>&code=b6f682f2518671329bb73a815949fab59ac01e19ac2105cc8bee2718e64b0892&grant_type=authorization_code&redirect_uri=<yours> HTTP/1.0" 401 | |
2016-07-26T15:38:02-04:00 "POST /auth/oauth/token?client_id=<your id>&client_secret=<your secret>&code=f497768aac61e961c74e488e0768a01337134dd7ff8b6177320a1af476a4934c&grant_type=authorization_code&redirect_uri=<yours> HTTP/1.0" 200 | |
2016-07-26T15:38:24-04:00 "POST /auth/oauth/token?client_id=<your id>&client_secret=<your secret>&code=f497768aac61e961c74e488e0768a01337134dd7ff8b6177320a1af476a4934c&grant_type=authorization_code&redirect_uri=<yours> HTTP/1.0" 401 | |
2016-07-26T15:38:31-04:00 "POST /auth/oauth/token?client_id=<your id>&client_secret=<your se |
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<stdio.h> | |
int main() { | |
int SIZE = 10; | |
int head = 0; | |
int tail = 0; | |
head = 3; | |
tail = 5; |
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 get_list(resource, base_url = ''): | |
# hit db in real life | |
total_items = 45 | |
try: | |
page_number = int(request.args.get('page', 1)) | |
except ValueError, e: | |
# we want an int; if we can't make an int, assume page 1 | |
page_number = 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
def all_subsets(*args): | |
from collections import Iterable | |
from itertools import permutations as permute | |
if len(args) == 1: | |
if not isinstance(args[0], Iterable): | |
args = [args[0]] | |
else: | |
args = args[0] | |
output = [] |