Skip to content

Instantly share code, notes, and snippets.

@elentok
elentok / profiling.zsh
Created October 10, 2013 20:34
Profiling zshrc (to find slow scripts)
typeset -F SECONDS=0
export START_TIME=$SECONDS
if [ -e ~/.profiling ]; then
echo "zshrc started"
source() {
local before=$SECONDS
. $*
local duration=$((($SECONDS - $before) * 1000))
@elentok
elentok / fl
Created August 13, 2013 07:47
Open forklift from terminal
#!/bin/bash
# Open current directory in forklift
echo -n $PWD | pbcopy
(cat<<EOF
tell application "Forklift"
activate
tell application "System Events"
@elentok
elentok / nginx.conf
Created June 24, 2013 11:07
Redirect favicon.ico, robots.txt, 500/404/422.html to public
server {
listen 80;
server_name subdomain.domain.com;
location ~* ^/(favicon.ico|robots.txt|500.html|404.html|422.html)$ {
root /home/rails/website/current/public;
try_files $uri =404;
}
}
@elentok
elentok / script_dir.sh
Created May 9, 2013 11:33
Current script directory (works in bash and zsh)
SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}`
SCRIPT_DIR=`cd $SCRIPT_DIR && pwd`
@elentok
elentok / retina.scss
Last active December 17, 2015 03:09
mixins for retina support
@mixin retina-image($image) {
background-image: url(image-path("#{$image}.png"));
@media (-webkit-min-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-device-pixel-ratio: 1.5) {
background-image: url(image-path("#{$image}@2x.png"));
}
}
@mixin retina-inline-image($image) {
background-image: inline-image("#{$image}.png");
@media (-webkit-min-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-device-pixel-ratio: 1.5) {
@elentok
elentok / rivets-test.js
Created April 21, 2013 13:29
For future reference
//= require components/rivets/lib/rivets
// ----------------------------------
attributes: {},
set: function (key, value) {
if (this.attributes[key] !== value) {
this.attributes[key] = value;
this.events.triggerEvent("change:" + key, {key: key, value: value});
}
#!/bin/bash
# uses memstats.rb from https://gist.github.com/elentok/5412060
master_pid=`ps aux | grep 'unicorn master' | grep -v 'grep' | awk '{print $2}'`
worker_pids=`ps aux | grep 'unicorn worker' | grep -v 'grep' | awk '{print $2}'`
stats() {
./memstats.rb $1 | grep -E '(rss|percentage)'
}
@elentok
elentok / memstats.rb
Last active December 16, 2015 09:19 — forked from kenn/memstats.rb
#!/usr/bin/env ruby
#------------------------------------------------------------------------------
# Aggregate Print useful information from /proc/[pid]/smaps
#
# pss - Roughly the amount of memory that is "really" being used by the pid
# swap - Amount of swap this process is currently using
#
# Reference:
# http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt#361
@elentok
elentok / gem-licenses.zsh
Created April 14, 2013 12:44
Returns a list of your gems and their licenses
#!/bin/zsh
get_gems() {
cat Gemfile |
sed 's/^ *//' |
sed -E '/^(group|end|source|#)/d' |
sed '/^ *$/d' |
sed "s/^gem ['\"]//" |
sed "s/['\"].*$//" |
@elentok
elentok / 8tracks.applescript
Last active December 15, 2015 13:39
Play/Pause 8tracks
tell application "8tracks"
activate
tell application "System Events"
keystroke " "
keystroke tab using {command down}
end tell
end tell