Skip to content

Instantly share code, notes, and snippets.

View cjroth's full-sized avatar
😃
build mode

Chris Roth cjroth

😃
build mode
View GitHub Profile

Keybase proof

I hereby claim:

  • I am cjroth on github.
  • I am cjroth (https://keybase.io/cjroth) on keybase.
  • I have a public key ASAyE1BUnLMOqhxOSlbAoWzn5cwKj9mUwUBOuSnKFIDU_go

To claim this, I am signing this object:

@cjroth
cjroth / die.zsh
Created November 1, 2017 16:03
Shortcut command to kill a process by port: die <port>
function _die() {
local PID="$(lsof -t -i:$1 -sTCP:LISTEN)"
if [[ -z "$PID" ]]; then
echo >&2 "No process is listening on port $1"
return 2
fi
echo >&2 "You killed it!"
kill -9 "$PID"
}
@cjroth
cjroth / kill.sh
Created February 27, 2017 20:36
Kill process running on port
kill -9 $(lsof -t -i:6379 -sTCP:LISTEN)
@cjroth
cjroth / remove_dot_ds_store.sh
Created January 31, 2017 19:04
Remove stupid .DS_Store files
rm */**/.DS_Store
@cjroth
cjroth / qol-scores.gs.js
Created January 27, 2017 21:50
Functions for calculating quality-of-life subscores and calculating a weighted-average of them. Written for Google Sheets.
function QOL(steps, awake, sleep, alcohol, food, lifeSatisfaction) {
var scores = [
{
score: QOL_STEPS(steps),
weight: 1
},
{
score: QOL_AWAKE(awake),
weight: 1
},
@cjroth
cjroth / modulus-vs-math-dot-floor-performance-test.js
Created January 26, 2017 17:17
See if `Math.floor(a / b)` or `(a - a % b) / b` is faster
let startTime = Date.now()
let data = []
for (let i = 0; i < 1e6; i++) {
let value = Math.random() * 100
data.push(value)
}
let rounded1 = []
for (let i in data) {
ld: warning: ignoring file ./affdex-sdk/lib/libaffdex-native.so, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): ./affdex-sdk/lib/libaffdex-native.so
Undefined symbols for architecture x86_64:
  "affdex::FrameDetector::FrameDetector(int, float, unsigned int, affdex::FaceDetectorMode)", referenced from:
      _main in main-678014.o
  "affdex::FrameDetector::~FrameDetector()", referenced from:
      _main in main-678014.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@cjroth
cjroth / emojis.js
Created January 13, 2017 21:22
Experimenting with Javascript (ES6) unicode emojis + regenerate + punycode to fix problems with unicode surrogate pairs. Raw
// https://mathiasbynens.be/notes/javascript-unicode
const punycode = require('punycode')
const regenerate = require('regenerate')
let str1 = '☕️'
let str2 = '💩'
let regex = regenerate(str1).toString()
console.log('regex', regex, new RegExp(regex).test(str1))
function main() {
var t = parseInt(readLine());
for(var a0 = 0; a0 < t; a0++){
var R_temp = readLine().split(' ');
var R = parseInt(R_temp[0]);
var C = parseInt(R_temp[1]);
var G = [];
for(var G_i = 0; G_i < R; G_i++){
G[G_i] = readLine();
}
// https://projecteuler.net/problem=49
let isPrime = (num) => {
for (let i = 2; i < num; i++) {
if (num % i === 0) {
return false
}
}
return num > 1
}