Skip to content

Instantly share code, notes, and snippets.

View vanjacosic's full-sized avatar
💭
Available for freelance work 😊

Vanja Cosic vanjacosic

💭
Available for freelance work 😊
View GitHub Profile
@Integralist
Integralist / git reset explained.md
Last active March 14, 2022 10:25
git reset --soft/--mixed/--hard

UPDATE

Every time I accidentally git commit --amend instead of a normal git commit I have to google git reset --soft HEAD@{1} to save the day.


Imagine you have a file called foo.txt and your Git history looked like this:

A -> B -> C (HEAD)
@remy
remy / easy-list.md
Last active January 4, 2016 06:19
Markdown pro tip: long numbered list made easier
  1. One
  • Two
  • Three
  • Four
  • Five

But really easy to re-sort because the items aren't really numbered:

1. one
#!/usr/bin/osascript
# vim: set syntax=applescript
(*
Launch multiple commands in iTerm2 split views
inspired by github.com/xgdlm/iterm2-cssh.
Usage:
@jeremyckahn
jeremyckahn / inherit-by-proxy.js
Created May 10, 2013 04:25
Proxy-based inheritance pattern in JavaScript.
function inherit (child, parent) {
function proxy () {};
proxy.prototype = parent.prototype;
child.prototype = new proxy();
};
function Parent () {}
function Child () {}
inherit(Child, Parent);
@jiaaro
jiaaro / script.bash
Created April 24, 2013 14:45
Embed Python in a bash script
#!/bin/bash
export FOO=100
python - <<END
import os
print "foo:", os.environ['FOO']
END
@nixme
nixme / acr122u.rb
Created May 17, 2012 08:00
Read NFC tag IDs from a Tagstand ACR122U USB reader
# Quick and dirty script to read unique IDs from NFC tags using the ACR122U USB
# reader.
#
# PC/SC-based API details for the ACR122U available at
# http://acs.com.hk/drivers/eng/API_ACR122U_v2.01.pdf
#
# Assumes ruby >= 1.9.2
# `gem install smartcard` first
#
@benjchristensen
benjchristensen / index.html
Created August 16, 2011 03:21
Animated Line Graphs / Sparklines using SVG Path and d3.js
<html>
<head>
<title>Animated Sparkline using SVG Path and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;
@henrik
henrik / .bashrc
Created December 3, 2008 17:56
Git branch and dirty state in Bash prompt.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"