Skip to content

Instantly share code, notes, and snippets.

View dasgib's full-sized avatar

Dominik Weiss dasgib

View GitHub Profile
module ImagesHelper
# Acts as a thin wrapper for image_tag and generates an srcset attribute for regular image tags
# for usage with responsive images polyfills like picturefill.js, supports asset pipeline path helpers.
#
# image_set_tag 'pic_1980.jpg', { 'pic_640.jpg' => '640w', 'pic_1024.jpg' => '1024w', 'pic_1980.jpg' => '1980w' }, sizes: '100vw', class: 'my-image'
#
# => <img src="/assets/ants_1980.jpg" srcset="/assets/pic_640.jpg 640w, /assets/pic_1024.jpg 1024w, /assets/pic_1980.jpg 1980w" sizes="100vw" class="my-image">
#
def image_set_tag(source, srcset = {}, options = {})
srcset = srcset.map { |src, size| "#{asset_path(src)} #{size}" }.join(', ')
@dasgib
dasgib / mdb2sql.sh
Last active May 24, 2022 18:51 — forked from turicas/mdb2sql.sh
#!/bin/bash
# Convert a MDB file (Access) to SQL
# Needs mdbtools[http://mdbtools.sourceforge.net/]
# run 'aptitude install mdbtools' on Debian/Ubuntu
# Created by Álvaro Justen <https://github.com/turicas>
# License: GPLv2
mdb=$1
sql=$2
@dasgib
dasgib / todoist.userscript.js
Created April 30, 2014 12:55
Userscript for todoist.com (Non-Premium)
window.onload = function() {
// add "overview" button
var filters_list = document.getElementById('top_filters');
var home_filter = document.createElement('li');
home_filter.setAttribute('class', 'filter current');
home_filter.innerHTML = '<img src="https://d3ptyyxy2at9ui.cloudfront.net/76084e29cb2cf72b320e888edc583dfb.gif" width="20" height="18" class="cmp_filter_inbox" style="background-position: -2px -649px">Overview';
home_filter.onclick = function() { document.location.href = 'https://todoist.com' }
@dasgib
dasgib / todoist.userstyle.css
Last active August 29, 2015 14:00
Userstyle for todoist.com (Non-Premium)
/* hide useless stuff */
#td_logo,
#notifications_counter,
#completed_items {
display: none !important;
}
#top_filters {
padding-top: 0 !important;

Keybase proof

I hereby claim:

  • I am dasgib on github.
  • I am dasgib (https://keybase.io/dasgib) on keybase.
  • I have a public key whose fingerprint is 346D 4B2F D925 3F26 FE79 5A62 E476 C80C E0FC 2E65

To claim this, I am signing this object:

@dasgib
dasgib / gist:3782943
Created September 25, 2012 16:25
Copy all songs in a .m3u file exported via iTunes to a new directory
IFS=$'\n'; mkdir playlist; for FILE in `tr "\r" "\n" < playlist.m3u | grep -v "^#"`
do
SONG=`basename $FILE`
ALBUM=`basename ${FILE/$SONG//}`
ARTIST=`basename ${FILE/$ALBUM\/$SONG//}`
cp $FILE "./playlist/$ARTIST - $ALBUM - $SONG"
done
@dasgib
dasgib / compass-retina-sprites.scss
Created June 23, 2012 19:57 — forked from thulstrup/compass-retina-sprites.scss
Using Compass to generate normal and retina sprite maps
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
@dasgib
dasgib / svg2png
Created June 23, 2012 14:16
Use Imagemagick to convert .SVG to .PNG
#!/bin/bash
if [ -z "$1" ] || [ -z "$3" ] || [ -z "$3" ]
then
echo "Syntax: svg2png <source.svg> <dest.png> <16x16> [<negate>]"
else
if [ -z "$4" ]
then
convert -background none -resize $3 -gravity center -extent $3 $1 $2
else
@dasgib
dasgib / .zshrc
Created December 20, 2011 10:40
pathed_cd for zsh - start new shell in last used directory
pathed_cd () {
if [ x"$1" = x ]; then
cd
else
cd "$1"
fi
pwd > ~/.cdpath
}
@dasgib
dasgib / dasgib.zsh-theme
Created December 19, 2011 13:01
My zsh Theme
PROMPT='%{$fg[white]%} %{$fg[green]%}%2~ %{$fg[grey]%}$(git_prompt_info)%{$fg[yellow]%}→ %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_CLEAN=" "