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 flatten(arr){ | |
var output = []; | |
for (var i = 0; i < arr.length; i++) { | |
if(arr[i] instanceof Array){ | |
output = output.concat(flatten(arr[i])) | |
} else { | |
output.push(arr[i]); | |
} | |
}; | |
return output; |
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 inPlaceFlatten(arr){ | |
for (var i = 0; i < arr.length; i++) { | |
if(arr[i] instanceof Array){ | |
var temp = inPlaceFlatten(arr[i]); | |
arr = arr.slice(0, i).concat(temp, arr.slice(i + 1)); | |
i += temp.length - 1; | |
} | |
}; | |
return arr; | |
} |
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
### Quick Diff | |
### A bash function that lets you see a diff without tabbing through all of your project folders | |
### | |
### Imagine you changed some number of files in your project and wanted to view the git diff of one of them | |
### but your project is deepy nested, so you have to type in the first letters and tab through each folder | |
### eg: folder_a/folder_b/folder_c/folder_d/my_file.js | |
### | |
### Instead of doing all that, just use `$ qdif my_file` to search your modified folders and show a diff of the first result | |
function qdif() { |
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
# Love running tests but hate having to check and see if they're finished? | |
# Add rspek to your .bash_profile to get a desktop notification (plus optional sound) when your tests are done! | |
# Before using, make sure to grab the dependency with `brew install terminal-notifier` or `gem install terminal-notifier` | |
# | |
# USE: | |
# rspek -f // run all tests in /spec. `--fail-fast` is set by default, `-f` disables it | |
# rspek /spec/features -q // run all features, no audio notification | |
# rspek some_file_spec.rb:50 // run one test | |
function rspek() { |
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
# Git Push Upstream | |
# A quick command for people that create a lot of feature branches | |
# | |
# Whereas `git push` will return an error if you haven't set the upstream branch | |
# `gpu` will automatically push to the correct upstream branch | |
# so you don't have to type `git push --set-upstream origin my_branch` for each new branch | |
function gpu() { | |
local RESPONSE=$( git push 2>&1 ) | |
local UPSTREAM=$( echo "$RESPONSE" | grep -o "git push --set-upstream origin.*" ) |
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 tensorflow as tf | |
from tensorflow.contrib.layers import flatten | |
# TODO: pull outs weights from individual functions, make them globally accessible | |
CLASSES_LEN = 43 | |
DEBUG = False | |
def get_depth(input_tensor): | |
if(input_tensor.get_shape): |
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
# All Imports | |
import pickle | |
import csv | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import cv2 | |
from math import floor, ceil | |
from sklearn.model_selection import ShuffleSplit | |
from sklearn.utils import shuffle |
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
class SudokuValidator { | |
constructor(board) { | |
if (board.length !== board[0].length) { | |
throw new Error('Board must be square'); | |
} | |
if (Math.sqrt(board.length) !== Math.floor(Math.sqrt(board.length))) { | |
throw new Error('Board size must be a square number') | |
} | |
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
find . -iname '*.mkv' -o -iname '*.avi' -o -iname '*.mp4' -o -iname '*.mov' | xargs -d '\n' du -sh | sort -hr |
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 itertools | |
""" | |
The following math problem illustrates the essence of hacking: | |
Use each of the numbers 1, 3, 4, and 6 exactly once with any of the four basic math operations (addition, subtraction, multiplication, and division) to total 24. Each number must be used once and only once, and you may define the order of operations; for example, 3 * (4 + 6) + 1 = 31 is valid, however incorrect, since it doesn’t total 24. | |
The rules for this problem are well defined and simple, yet the answer eludes many. Like the solution to this problem (shown on the last page of this book), hacked solutions follow the rules of the system, but they use those rules in counterintuitive ways. | |
""" | |
nums = ['1','3','4','6'] |
OlderNewer