Skip to content

Instantly share code, notes, and snippets.

@saetia
saetia / gist:9987966
Last active August 29, 2015 13:58
Create SSL

on the server

sudo openssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr

Country Name (2 letter code) [AU]:US

@saetia
saetia / gist:1447655
Created December 8, 2011 17:11
Virtual Hosts, Dnsmasq
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
brew install dnsmasq
mate /usr/local/etc/dnsmasq.conf
address=/dev/127.0.0.1
address=/build/127.0.0.1
address=/stage/192.168.10.200
listen-address=127.0.0.1
@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
@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 / 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 / .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 / gist:45f00ce3e03ddc2b24bf
Created April 1, 2015 22:22
Instagram Access Token
https://api.instagram.com/oauth/authorize/?client_id=[client_id]&redirect_uri=[redirect_uri]&response_type=code
curl -F 'client_id=[client_id]' -F 'client_secret=[client_secret]' -F 'grant_type=authorization_code' -F 'redirect_uri=[redirect_url]' -F 'code=[code]' https://api.instagram.com/oauth/access_token
<? $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 / 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
@saetia
saetia / helm.php
Created August 7, 2013 16:46
helm script
#!/usr/bin/php -q
<?
chdir(__DIR__);
define('VERSION','0.6.5');
define("SITES_PATH",reset(explode(basename(__DIR__),__DIR__)));
define("DB_PW",generate_pw());
define("FTP_PW",generate_pw());
define("EMAIL_PW",generate_pw());
define("FINGERPRINT",strtoupper(generate_pw(20)));
define("DEVELOPER",trim(get_current_user()));