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 sqlmap provides functions for querying directly into | |
// map[string]interface{}. | |
// | |
// In developing really simple api endpoints, I found the boilerplate needed | |
// to take the results of a database query and output them as JSON to be | |
// really fucking annoying; make a custom struct, scan into that struct, if | |
// there are multiple rows do the whole rows.Next() song and dance, and if | |
// anything changes update the three spots each column of the result is now | |
// dependent on. Even when using libraries like sqlx, there's still a lot of | |
// extraneous code that needs to be written. |
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
export default function History(initialState) { | |
this.reset(initialState); | |
} | |
History.prototype = { | |
reset: function(initialState) { | |
this.history = [initialState]; | |
this.pointer = 0; | |
this.tail = 0; |
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 python | |
# This script signs github for desktop powershell scripts. | |
# | |
# Powershell scripts are locked down here (via sysadmin decree), but the GitHub | |
# Desktop app uses powershell scripts when you right click > "Open in Git | |
# Shell". This is pretty much a requirement since the application can only | |
# handle fairly simple git operations. | |
# | |
# In order for these scripts to work they need to be signed. I don't remember |
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
// Pragmatic typed immutable.js records using typescript 2.1+ | |
// Comment with any suggestions/improvements! | |
import * as fs from 'fs' | |
import { Record, Map } from 'immutable' | |
type Stats = fs.Stats; | |
// Define the basic shape. All properties should be readonly. This model | |
// defines a folder because it seemed easy C: |
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
// __tests__/example.js | |
jest.mock('fs'); | |
it('should serve as a nice example', () => { | |
const fs = require('fs') | |
// fs can be set up at any point by calling __configureFs. | |
fs.__configureFs({ | |
'/test': { |
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 std::{env, fs, process}; | |
use std::error::Error; | |
use std::convert::{TryFrom,TryInto}; | |
use std::io::{Write,BufWriter}; | |
static HELP_TEXT: &str = "ico-join [<PNG>...] <DEST> | |
<PNG> Path to png files you want to combine. | |
<DEST> Path to the output file. | |
"; |
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
export default class WebStorage { | |
constructor(key, storageArea = window.localStorage) { | |
this.key = key; | |
this.storageArea = storageArea; | |
} | |
load(defaultValue) { | |
const serialized = this.storageArea.getItem(this.key); | |
return serialized === null ? defaultValue : this.deserialize(serialized); | |
} |
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 fs = require("fs"); | |
const crypto = require("crypto"); | |
const spawnSync = require("child_process").spawnSync; | |
// Load the environment using the same code react-scripts uses. | |
process.env.NODE_ENV = "production"; | |
const clientEnv = require("react-scripts/config/env")().raw; | |
const REACT_APP_RUNTIME = /^REACT_APP_RUNTIME_/i; |
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 subprocess as sp | |
import pyautogui | |
import time | |
child = sp.Popen(["write.exe"]) | |
time.sleep(1) | |
pyautogui.typewrite('Dae Choi is the best.\nGive me a job!', interval=0.1) | |
# Save |
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
// PromiseState provides primitives for representing a promise's "state" as a | |
// value. | |
// | |
// That's kinda abstract so let's think through it. At any given point in time | |
// a promise is either pending, resolved, or rejected. There's no real | |
// synchronous way to access this promise "state", promises only give us `then` | |
// and callbacks. | |
// | |
// In react we usually care about rendering _all_ of these possible states. For | |
// example, we want to show a spinner when it's loading, the results when it |
NewerOlder