Skip to content

Instantly share code, notes, and snippets.

harrytallbelt

Block or report user

Report or block harrytallbelt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@harrytallbelt
harrytallbelt / create-bare-git-repo.sh
Last active Nov 8, 2017
Create a local bare repo, you can (put in Dropbox folder) use like remote.
View create-bare-git-repo.sh
# Create a new bare repo.
cd origin-parh
mkdir repo.git
cd repo.git
git --bare init
# Make an already existing repo bare.
cd origin-parh
mkdir repo
cd repo
@harrytallbelt
harrytallbelt / commands.sh
Created Oct 31, 2017
helpful bash commands
View commands.sh
# count lines in all inner js files of a project
cat `find . | grep -v 'node_modules' | grep '.*.js$'` | wc -l
# list all the js files that contain a word
grep -v 'node_modules' | grep '.*.js$' | xargs grep 'SEARCHWORD' -l
@harrytallbelt
harrytallbelt / matrix.js
Created Oct 25, 2017
A satisfying Matrix effect with Node.JS.
View matrix.js
const LINE_WIDTH = 80 // 150
const CONTINUATION_PROBABILITY = 0.9
const FRAMERATE = 100
console.log('\x1b[32m') // green text
console.log('\x1b[40m') // black bg
let line = []
for (let i = 0; i < LINE_WIDTH / 2; ++i) {
line.push(false)
@harrytallbelt
harrytallbelt / format-simplify.js
Created Oct 6, 2017
A bit of code for pretty formatting Simplify predicates. It can be used to parse and format s-lists if you throw a few lines out
View format-simplify.js
// Indentation unit: predicate components are indented with this string,
// repeated several times, depending on their nesting level.
// Use '' for no identation.
const DEFAULT_INDENT_STR = ' '
// All lines end with this string; predicates on the top level
// are separated with twice this string.
// Use ' ' for a one-line output ('' won't lead to valid predicates).
const DEFAULT_LINE_ENDING = '\n'
// An s-list shorter than this would be a one-liner.
// This number is not exact, though (see `estimatedLength`).
@harrytallbelt
harrytallbelt / convert-to-grayscale.sh
Created Mar 20, 2017
Bash script to convert coloured photos to (much smaller) grayscale using imagemagick package.
View convert-to-grayscale.sh
#!/bin/bash
mkdir results
for image in *.jpg
do
convert -colorspace Gray -interlace Plane -gaussian-blur 0.05 -quality 50% $image ./results/$image
done
@harrytallbelt
harrytallbelt / waterCapacity.fs
Created May 18, 2016
F# solution for water on land problem
View waterCapacity.fs
let oneWayCapacity a =
let mutable max = 0
a |> List.map (fun e -> if e > max then max <- e; 0 else max - e)
let totalCapacity a =
let aL = a |> oneWayCapacity
let aR = a |> List.rev |> oneWayCapacity |> List.rev
List.map2 min aL aR |> List.sum
You can’t perform that action at this time.