Skip to content

Instantly share code, notes, and snippets.

View fanaugen's full-sized avatar
🙂
always learning

Alex Jahraus fanaugen

🙂
always learning
  • Berlin
View GitHub Profile

It’s the one whitespace character between the </div> and the next <div!

Because of that whitespace, and because our boxes are displayed as inline-block, the browser renders an actual whitespace in the current font and size between them, and so the smaller box once again breaks to the next "line".

@fanaugen
fanaugen / comment.md
Created June 26, 2013 14:41
previous content

echo "Please pick up the following from the store: $groceries[0]";

This isn't going to work by the way: inserting a variable's value into a string "like $x this" only works with a simple variable such as $x – for array elements you have two other options:

  1. String concatenation:

    echo "buy ".$groceries[0]." at the store";
    
  2. save in a variable beforehand:

@fanaugen
fanaugen / steamroller.js
Created January 12, 2016 23:05
recursive function to flatten a js Array
function steamroller(arr) {
for (var i = 0; i < arr.length; i++) {
if(Array.isArray(arr[i])) {
// recurse: replace this array with all its elements
// for instance, if arr is [1, [2, 3], 4]
// then we want to return [1, 2, 3, 4]
var left = arr.slice(0, i);
var right = arr.slice(i + 1);
return steamroller(
@fanaugen
fanaugen / export-tasks.sh
Last active June 8, 2017 14:20
rake tasks to wiki
#!/bin/bash
# Run `rake -D` and format the task descriptions as a
# GitHub-Markdown table (for our Wiki)
# Write the output to tasks.md
touch tasks.md
echo '<dl>' > tasks.md
bundle exec rake -D |
@fanaugen
fanaugen / config.fish
Created July 26, 2017 23:51
fish abbreviation for each git alias
# for each git alias of the form XX, create fish abbreviation gXX
function git_alias --desc "Add a git abbreviation"
abbr -a g$argv[1] git $argv[2]
end
for _alias in (git config --global --get-regexp '^alias\.*' | sed s/alias.//)
git_alias (string split -m1 ' ' "$_alias")
end
@fanaugen
fanaugen / images to TIFF.scpt
Last active October 25, 2018 06:39
Batch-convert images to TIFF (AppleScript, Mac OS X)
# this script converts all PDFs and images selected in Finder
# to the TIFF format and appends .tif to the file name
set t to (time of (current date))
tell application "Finder" to set sel to selection
set errors to {}
tell application "Image Events"
repeat with img_file in sel
try
set img_file to img_file as text
@fanaugen
fanaugen / date string parser.scpt
Last active October 25, 2018 06:41
simple date parser
(*
* Example of a simple string-to-date parser.
* Uses AppleScript's text item delimiters to split the input string
*)
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"-", "T", ":", "Z"}
set dateString to "2011-12-23T08:00:00Z" -- what's Z for?
@fanaugen
fanaugen / podcasts.md
Last active January 9, 2019 12:45
dev podcasts

📻 My Favourite Podcasts

developer podcasts I’ve listened to

Some of these I still subscribe to, others are no longer in my subsctiption list to make time for non-dev related podcasts