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
function dbg(msg: any) { | |
const e = new Error(); | |
const regex = /\((.*):(\d+):(\d+)\)$/; | |
if (e.stack) { | |
const match = regex.exec(e.stack.split("\n")[2]); | |
if (match) { | |
const f = match[1].split("/") | |
console.log(`${f[f.length-1]}:${match[2]}: ${JSON.stringify(msg, null, 2)}`); | |
} | |
} |
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
// go mod init x && go get github.com/nfnt/resize | |
// go run main.go | |
package main | |
import ( | |
"image/jpeg" | |
"log" | |
"os" |
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 expect = @import("std").testing.expect; | |
const std = @import("std"); | |
pub fn main() !void { | |
// read numbers into an arraylist | |
var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | |
defer { | |
const l = gpa.deinit(); | |
} | |
var nums = std.ArrayList(i32).init(&gpa.allocator); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/env python3 | |
""" | |
File finding utility. | |
Usage: | |
# scan current directory for files with the regex foo | |
f foo | |
# scan /bar for regex foo, ignoring subdirectory baz | |
f --ignore baz --root /bar foo |
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
#!/usr/bin/env python3 | |
""" | |
Formats xml documents. | |
Usage: | |
xmlfmt docs/ | |
""" | |
import os | |
import argparse | |
import xml.dom.minidom |
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
package main | |
import ( | |
"fmt" | |
"os" | |
"text/tabwriter" | |
) | |
func c2f(c float64) float64 { | |
return float64(c*9/5 + 32) |
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
use itertools::Itertools; | |
use std::cmp::{Eq, PartialEq, PartialOrd}; | |
use std::collections::HashSet; | |
use std::env; | |
use std::fs::read_to_string; | |
use std::iter::FromIterator; | |
fn main() { | |
// read asteroid file | |
let f = env::args().nth(1).expect("missing filename"); |
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
package main | |
import "fmt" | |
// swap swaps elements in a slice | |
func swap(i, j int, slice []int) { | |
v1 := slice[i] | |
v2 := slice[j] | |
slice[i] = v2 | |
slice[j] = v1 |
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
[ | |
{ | |
"id": 9284, | |
"name": "brian", | |
"numbers": [ | |
1, | |
2, | |
3, | |
4, | |
5 |
NewerOlder