Skip to content

Instantly share code, notes, and snippets.

@saetia
saetia / post-commit
Last active December 20, 2015 03:29
optimize files after git push
#!/bin/sh
files="$(find -L . -name "*.js" -type f)"
echo "Scripts to minify: $(echo -n "$files" | wc -l)"
echo "$files" | while read file; do
uglifyjs "$file" -o "$file" -c -m
done
files="$(find -L . -name "*.css" -type f)"
echo "Stylesheets to minify: $(echo -n "$files" | wc -l)"
echo "$files" | while read file; do
<? $lines = explode("\n",shell_exec("find ~/vhosts -name '*.md' -type f -print0 | xargs -0 fgrep ".escapeshellarg(params('search'))));?>
found <?=pluralize(count($lines),'results')?> for “<?=h(params('search'))?>”
<? foreach ($lines as $l){
$e = explode('.md:',$l);
$path = basename(reset($e));
$excerpt = end($e); ?>
<li><?=highlight(h(strip_tags(markdown($excerpt))),params('search'))?> – <a href="/doc/<?=$path?>"><?=humanize($path)?></a></li>
<? } ?>
@saetia
saetia / google-analytics-0.1.js
Created June 26, 2012 18:19
Google analytics
function initializeGoogleAnalytics(){
GoogleAnalytics.init();
}
var GoogleAnalytics = {
accountId: null,
accessToken: null,
getAccountId: function(){
return (this.accountId) ? 'ga:'+this.accountId : null;
@saetia
saetia / .zshrc
Last active November 23, 2022 09:50
Zsh settings
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="kphoen"
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;246m' # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m' # end underline
@saetia
saetia / .vimrc
Created May 21, 2012 19:01
vim Config
set nocompatible
syntax enable
set number " Show line numbers.
set ruler " Show cursor position.
set showcmd " Display incomplete commands.
set showmode " Display the mode you're in.
set incsearch " Highlight matches as you type.
@saetia
saetia / dashboard.js
Created May 9, 2012 20:00
Dashboard Examples
var BrowsersByDate = new Widget({
dimensions:'ga:browser',
columns:['ga:browser'],
period:'weekly',
chart:'area',
sort:'-ga:pageviews'
});
var Browsers = new Widget({
@saetia
saetia / parse.rb
Last active June 26, 2017 16:59
Parse MySQL dumps
ruby -e "$(curl -fsSkL https://gist.githubusercontent.com/saetia/2369908/raw/4bf9a6d36060582e69f02c314f66449971a7bb11/parse.rb)" /Users/Joel/site.db.121010.dump
ruby parse.rb site.120411.dump
@saetia
saetia / gist:1623487
Last active May 1, 2024 19:55
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@saetia
saetia / gist:1525301
Created December 27, 2011 22:05
per user SSH

replace {{placeholders}} with your own values

On local machine

Generate a key

ssh-keygen -f {{identification}} -t rsa -q
ssh-add -K {{identification}}
@saetia
saetia / post-receive.md
Created December 21, 2011 17:16
Remote Git

On remote server as user

git init --bare ~/private/deploy.git
echo '#!/bin/sh
echo 'updating website'
GIT_WORK_TREE=/var/www/vhosts/site.diedrick.net/httpdocs/ git checkout -f' > /var/www/vhosts/site.diedrick.net/private/deploy.git/hooks/post-receive &&
chmod 755 /var/www/vhosts/site.diedrick.net/private/deploy.git/hooks/post-receive