Skip to content

Instantly share code, notes, and snippets.

💭
git push -f #yolo

Tim Kennedy stretchkennedy

💭
git push -f #yolo
Block or report user

Report or block stretchkennedy

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
@stretchkennedy
stretchkennedy / check_source_age.sh
Created May 10, 2018
Check the age of all your js files before committing (using husky)
View check_source_age.sh
#!/bin/bash
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd)"
FILES="$(find "$DIR"/src -type f -name '*.js' -not -name '*.test.js')"
IS_OLDER=false
for f in $FILES; do
if [[ "$f" -nt bundle.js ]]; then
echo "$f is newer than bundle.js"
IS_OLDER=true
@stretchkennedy
stretchkennedy / connect.js
Last active Jul 26, 2017
react state management idea
View connect.js
const schema = {
view: {
selectedUser: null
},
data: {
users: {
$id: ({ id }, state, path) => fetch(`/api/users/${id}`).then(res => res.json())
}
}
};
@stretchkennedy
stretchkennedy / persist-turbolinks.js
Last active Mar 25, 2018
persist turbolinks position in vanilla js
View persist-turbolinks.js
View problems.md

Using python:

  • Find 4096 divided by 4.
  • Write a program that
    • takes a number from the command line and divides it by 4.
    • solves a thing called "FizzBuzz" up to the number 20. (hint: to get the remainder of a division, you need a thing called the modulo operator)
    • takes a number and runs through the steps of the Collatz conjecture.
    • takes a number, or numbers, and applies a formula that's actually useful to them. (if you're stuck for ideas, the quadratic formula could be interesting)
    • takes a list of numbers and adds them together. (hint: first use a for loop, then look at map from https://docs.python.org/2/tutorial/datastructures.html#functional-programming-tools)
    • takes a list of names and outputs something like Hello Ted, John, Alice, and Jane!.
View bash_http_server.sh
# bash one-liner to run a simple (and possibly non-compliant) http server
ncat -l 2000 -k -c '/bin/echo -e "HTTP/1.0 200 OK\r\n\r\n<html><body><h1>Test page</h1></body></html>"'
# more comprehensive version that sets Content-Type and Content-Length
CONTENT='<html><body><h1>Test page</h1></body></html>'; ncat -l 2000 -k -c '/bin/echo -e "HTTP/1.0 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: '${#CONTENT}'\r\n\r\n'$CONTENT'"'
View output.html
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- This file was created with the aha Ansi HTML Adapter. http://ziz.delphigl.com/tool_aha.php -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xml+xhtml; charset=UTF-8" />
<title>stdin</title>
</head>
<body style="color:white; background-color:black">
<pre>
@stretchkennedy
stretchkennedy / README.md
Last active Jun 28, 2016
Coding challenge
View README.md

Coding challenge

Mockup

Mockup of a google maps view

Requirements

View export_git_history_as_csv.sh
function escape_chars {
sed 's/"/""/g'
}
function format {
date=$(git log -n1 --pretty=format:%cD "$1" | escape_chars)
author=$(git log -n1 --pretty=format:'%aN <%aE>' "$1" | escape_chars)
sha=$(git log -n1 --pretty=format:%h "$1" | escape_chars)
message=$(git log -n1 --pretty=format:%B "$1" | escape_chars)
echo "\"$date\",\"$author\",\"$sha\",\"$message\""
}
@stretchkennedy
stretchkennedy / parallel.sh
Created Feb 24, 2016
Run bash commands in parallel
View parallel.sh
function mycommand {
sleep 1
}
PIDS=()
for i in $(seq 1 10); do
mycommand & PIDS+=($(echo $! | sed 's/^\[[0-9]*\]//'));
done
wait ${PIDS[*]}
View shipyard.bash
#!/bin/bash
if [ "$1" != "" ] && [ "$1" = "-h" ]; then
echo "Shipyard Deploy uses the following environment variables:"
echo " ACTION: this is the action to use (deploy, upgrade, node, remove)"
echo " DISCOVERY: discovery system used by Swarm"
echo " IMAGE: this overrides the default Shipyard image"
echo " PREFIX: prefix for container names"
echo " SHIPYARD_ARGS: these are passed to the Shipyard controller container as controller args"
echo " TLS_CERT_PATH: path to certs to enable TLS for Shipyard"
You can’t perform that action at this time.