Skip to content

Instantly share code, notes, and snippets.

View davidhq's full-sized avatar
🎯
Focusing

davidhq

🎯
Focusing
View GitHub Profile
@davidhq
davidhq / ssh_forward_setup.md
Last active August 29, 2015 14:07
Showcase websites from your local machine easily

Showcase websites from your local machine easily

We want to make yourdomain.com (could be subdomain like showcase.yourdomain.com as well, of course) open whatever webapp (Rails, Sinatra etc.) is running on port 3000 on your development machine.

Create ~/bin/ssh_forward with this contents:

#!/usr/bin/env bash
domain=yourdomain.com
echo "http://$domain" | pbcopy

python -mwebbrowser http://$domain &

@davidhq
davidhq / devise.sl.yml
Last active August 29, 2015 14:13
devise 3.4.1, slovenian translations
# Based on https://gist.github.com/samotarnik/4337418 (Devise 2.1.2) by @samotarnik
sl:
devise:
confirmations:
confirmed: 'Vaš uporabniški račun je bil uspešno potrjen. Sedaj ste prijavljeni.'
send_instructions: 'V nekaj minutah boste prejeli elektronsko sporočilo z navodili za potrditev vašega uporabniškega računa.'
send_paranoid_instructions: 'Če je vaš elektronski naslov v naši bazi podatkov, boste na ta naslov v nekaj minutah prejeli navodila za potrditev vašega uporabniškega računa.'
failure:
already_authenticated: 'Ste že prijavljeni.'
inactive: 'Vaš uporabniški račun še ni bil aktiviran.'
@davidhq
davidhq / aliases.bash
Last active August 29, 2015 14:15
Ultimate web server
function serve {
if [ -f ./server ]; then
./server
elif [ -f ./server.js ]; then
node server.js
elif [ -f ./package.json ]; then
npm run start
else
# npm install http-server -g
http-server -p 3000
@davidhq
davidhq / server.js
Last active August 29, 2015 14:15
Ethereum dapp server with reverse proxy for eth RPC (solves CORS issues)
// use: web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8888/client'));
// eth has to run on 8090:
// eth -j -f -m 10 -n off --json-rpc-port 8090
// static server based on: https://gist.github.com/ryanflorence/701407
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
_request = require("request"),
@davidhq
davidhq / contract.html
Last active August 29, 2015 14:16
go-ethereum example
<html>
<head>
<script type="text/javascript" src="dist/bignumber.min.js"></script>
<script type="text/javascript" src="dist/ethereum.js"></script>
<script type="text/javascript">
var web3 = require('web3');
web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8090'));
// use: web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8888/client'));
// eth has to run on 8090:
// eth -j -m 10 -n off --json-rpc-port 8090
// GO: ethereum -rpcport=8090 -rpc=true -mine=true
// static server based on: https://gist.github.com/ryanflorence/701407
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
@davidhq
davidhq / cd_projects.sh
Last active August 29, 2015 14:17
cd_projects
# p proj -> cd ~/Projects/project
# works best (fastest) if your projects are lower-case and you refer to them as such
# if not, then for best performance (no lag) you have to call "p Proj" (if ~/Projects/Project exists)
function p {
cd ~/Projects
local match
if [ -n "$1" ]; then
local min_size=1000
# first try only directories that start exactly with our input
for d in $1*/ ; do
@davidhq
davidhq / rspec.bash
Created March 26, 2015 21:36
RSpec++
function rspec {
command rspec $@
if [ $? -ne 0 ]; then
afplay ~/Misc/dumb.mp3 -v 0.3
fi
}
# swiss knife
function c {
local dir
dir=`pwd`
if [ -z "$1" ]; then
cd - > /dev/null
else
if [ -d "$1" ]; then
cd "$1"
elif [ -f "$1" ]; then
@davidhq
davidhq / grab.sh
Last active September 11, 2015 22:44
# Example:
#
# $ find . | grep core_ext
# ./config/initializers/core_ext.rb
# ./spec/lib/core_ext_spec.rb
#
# $ grab 2
# ./spec/lib/core_ext_spec.rb ===> (also copied on clipboard)
#
# Without arguments the default is to grab the first line