Skip to content

Instantly share code, notes, and snippets.

View HansCz's full-sized avatar

Hans Czajkowski Jørgensen HansCz

  • The Danish Board of Technology Foundation
View GitHub Profile
I've wrapped your code in a plugin. Hope it's useful.
Usage:
In your HTML, an element that you want to act as footer (ex. #footer), an element to act as trigger (ex. #trigger) are assumed.
apart from this html file, you'll need to include my snippet somehow, and also bind it to your footer element.
Here is an example illustrating the interdependent code bits:
@HansCz
HansCz / get_vars.bash
Created October 30, 2011 02:52
Bash - Source a file and find out what variables it set
# found here:
# http://stackoverflow.com/questions/1305237/how-to-list-variables-declared-in-script-in-bash/1305273#1305273
# # Todo
# - instead of echoing all vars out on one line separated by spaces, find a way to separate them, so they are one line each
# can be run in command line
( VARS="`set -o posix ; set`"; source repos/backup/test/conf/sync.conf; SCRIPT_VARS="`grep -vFe "$VARS" <<<"$(set -o posix ; set)" | grep -v ^VARS=`"; unset VARS; echo $SCRIPT_VARS; unset SCRIPT_VARS )
@HansCz
HansCz / lscolor.bash
Created April 13, 2012 11:28
Bash - Colorised ls
# ================
# = Colorised ls =
# ================
# color-ls is now part of the standard ls command. To get colorized directory listings, simply issue the command (in bash):
alias ls='ls --color=tty'
@HansCz
HansCz / list_apache2_vhosts.bash
Created April 13, 2012 11:30
Apache (Bash) - List apache2 virtualhosts
# List apache2 virtualhosts
# Lists virtualhosts currently enabled for apache2,
# showing the ServerName:port, conf file and DocumentRoot
/usr/sbin/apache2ctl -S 2>&1 | perl -ne 'm@.*port\s+([0-9]+)\s+\w+\s+(\S+)\s+\((.+):.*@ && do { print "$2:$1\n\t$3\n"; $root = qx{grep DocumentRoot $3}; $root =~ s/^\s+//; print "\t$root\n" };'
@HansCz
HansCz / do2lists.bash
Created April 13, 2012 11:38
Bash - read two files and insert their lines in a bash command
# read two files and insert their lines in a bash command
# http://www.linuxquestions.org/questions/programming-9/help-with-bash-script-rename-multiple-files-347062/
#
# usage example:
#
# $ do2lists filelist_originalnames.txt filelist_newnames.txt | bash
ARGV[1] == FILENAME{
getline out2 < ARGV[2]
@HansCz
HansCz / cherry-pick-range.bash
Created April 13, 2012 11:41
Git - cherry-pick range
# http://stackoverflow.com/questions/1670970/how-to-cherry-pick-multiple-commits
# 1. checkout the branch you want to cherry-pick to
# 2. in bash do:
git rev-list --reverse [first sha1 hash in range]..[last sha1 hash in range] | xargs -n 1 git cherry-pick
@HansCz
HansCz / zip-repo.bash
Created April 13, 2012 11:43
Git - zip a git repo root folder while ignoring git files and copying it somewhere
# zip a git repo root folder while ignoring git files and copying it somewhere
cd my_git_repo
git archive HEAD --format=zip --output=somewhere/in/the/fie/system/my_zipped_git_repo.zip
@HansCz
HansCz / ignore-indexed.bash
Last active October 3, 2015 02:48
Git - Ignoring changes to files already in the index
# Adding files to .gitignore that are already tracked does not work. (and it’s actually pretty well documented). Instead, it’s possible to use this command:
git update-index --assume-unchanged [filename(s)]
@HansCz
HansCz / add-ssh-key-to-agent.bash
Created April 13, 2012 17:06
SSH (Bash) - adding key to ssh-agent
# Linux
eval `ssh-agent`
ssh-add ~/.ssh/some_key_rsa
ssh user@server
# Mac
## As of the Leopard release of OS X, ssh-agent is more tightly integrated with Keychain. It is possible to store the passphrases of all of your SSH keys securely in Keychain, from which ssh-agent will read them on startup. The bottom line is that it is simple to secure your keys with passphrases, but never have to type the passphrase to use them! Here is how:
## Add the pass phrase to each ssh key to keychain:
@HansCz
HansCz / filter-branch.bash
Created April 13, 2012 21:09
Git (Bash) - Filter branch
# Ref.: http://stackoverflow.com/a/359759/173679
git remote rm origin
git tag -l | xargs git tag -d
git filter-branch --tag-name-filter cat --prune-empty --subdirectory-filter ABC HEAD
git reset --hard
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all
git gc --aggressive --prune=now