Skip to content

Instantly share code, notes, and snippets.

@poeticninja
poeticninja / shuffle-array.js
Last active December 24, 2015 22:03
Shuffle Array
var list = [1,2,3,4,5,6,7,8,9];
list = list.sort(function() {
return Math.random() - 0.5;
});
console.log(list); // prints something like: 4,3,1,2,9,5,6,7,8
// For a raffle and 1 person to win.
@poeticninja
poeticninja / index.html
Created February 19, 2016 01:40
Footer stick to bottom of page.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div class="wrapper">
<main>Main content here.</main>
</div>
@poeticninja
poeticninja / .bash_profile
Last active March 22, 2016 17:53
Bash Profile Base
# Easier navigation: .., ..., ~ and -
alias ..="cd .."
alias cd..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias -- -="cd -"
## Use a long listing format ##
alias ll='ls -la'
@poeticninja
poeticninja / keymap.cson
Created July 17, 2016 02:39
Atom JSX Emmet Support. Escape if autocomplete shows up and then tab for emmet.
# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
@poeticninja
poeticninja / docker-cache-experimental.sh
Created October 7, 2016 18:54
docker cache experimental semaphore
#!/usr/bin/env bash
image_archive="image-archive.tar"
image_metadata="docker-image-metadata.tar.gz"
function cache_images() {
images_to_cache=$(docker images | awk '{print $3}' | grep -v '<none>' | tail -n +2 | while read line; do docker history -q $line | grep -v '<missing>'; done | uniq)
if [ -n "$images_to_cache" ]; then
printf "Saving the following images:\n$images_to_cache\n\n"
@poeticninja
poeticninja / .bash_profile
Created October 11, 2016 19:10
Bash Profile - 10/11/2016
# Easier navigation: .., ..., ~ and -
alias ..="cd .."
alias cd..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias -- -="cd -"
## Use a long listing format ##
alias ll='ls -la'
@poeticninja
poeticninja / generate-uuid.js
Last active June 5, 2019 20:09
GenerateUUID
function generateUUID(n) {
return n ? (n ^ 16 * Math.random() >> n / 4).toString(16) : ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, generateUUID)
}
@poeticninja
poeticninja / _spacing.scss
Last active February 24, 2017 22:55
Spacing for styles
@mixin spacing($prop: padding, $dir: top, $value: 1) {
#{$prop}-#{$dir}: $value;
}
@function initial($string) {
@return str-slice($string, 0, 1);
}
$properties: (
margin,
@poeticninja
poeticninja / ComponentWidth.js
Last active March 21, 2017 23:44
React component width decorator.
import React from "react";
import elementResizeEvent from "element-resize-event";
export default (Component) => {
class ComponentWidth extends React.Component {
state = {
width: 0,
};
componentDidMount() {
const element = this.targetElement;
@poeticninja
poeticninja / promise.serial.waterfall.js
Created May 10, 2017 20:00
Example serial promises with error to handle individual cases.
const delay = require("delay");
const people = [
{
id: 0,
name: "Stewie",
delay: 200
},
{
id: 1,