Skip to content

Instantly share code, notes, and snippets.

@rasshofer
rasshofer / tree.js
Created December 24, 2015 11:15
Merry Christmas!
var size = 20;
for (var i = 0; i < size; i += 2) {
var line = new Array((size - i) / 2 | 0).join(' ');
for (var y = 0; y <= i; y++) {
line += i ? (Math.random() * 10 % 10 | 0) === 0 ? ['🔴', '🔵'][y % 2] : '🍃' : '⭐️';
}
console.log(line);
}
@rasshofer
rasshofer / capture.sh
Created January 8, 2015 07:07
OS X: Take a screenshot, upload the screenshot to PicPig and copy the URL to your clipboard
#!/bin/bash
API_KEY="abc123"
API="https://picpig.com/api/$API_KEY"
FILE="screencapture-`date +%s`.png"
# Capture screen interactively by selection or window
screencapture -i $FILE
@rasshofer
rasshofer / picpig.sh
Created January 8, 2015 06:04
Upload a local image to PicPig via cURL using their API
#!/bin/bash
# Usage: bash picpig.sh {FILE} {API_KEY}
# Example: bash picpig.sh test.png abc123
API="https://picpig.com/api/$2"
MIME=$(file --mime-type $1 | awk '{print $2}')
if [ ${MIME:0:5} == "image" ]
@rasshofer
rasshofer / reset.css
Created November 17, 2014 20:42
Yet another super simple CSS reset
* {
margin: 0;
padding: 0;
background: none;
border: 0;
-webkit-text-size-adjust: 100%;
}
*,
*:before,
@rasshofer
rasshofer / PS1
Created November 6, 2014 16:05
My bash prompt (PS1)
export PS1="\[$(tput bold)\]\[$(tput setaf 6)\]\u\[$(tput setaf 7)\]@\[$(tput setaf 2)\]\h \[$(tput setaf 3)\]\w\[$(tput setaf 1)\]\$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/') \[$(tput setaf 7)\]\\$ \[$(tput sgr0)\]"
@rasshofer
rasshofer / cmyk.scss
Created October 16, 2014 16:23
Convert CMYK to RGB within SCSS
@function cmyk($c, $m, $y, $k) {
$c: $c / 100;
$m: $m / 100;
$y: $y / 100;
$k: $k / 100;
$r: 255 * (1 - $c) * (1 - $k);
$g: 255 * (1 - $m) * (1 - $k);
$b: 255 * (1 - $y) * (1 - $k);