Skip to content

Instantly share code, notes, and snippets.

View koenpunt's full-sized avatar
:octocat:
...

Koen Punt koenpunt

:octocat:
...
View GitHub Profile
@koenpunt
koenpunt / rename.sh
Last active December 12, 2015 08:39
Rename controllers, models, views ands tests in a rails project.
# List the files you need to rename you could run the following from the root of the project:
find . -name 'user*' | awk '{print $0; gsub(/user/, "system_user"); print $0}' | xargs -n2 echo "mv"
# actually move the files:
find . -name 'user*' | awk '{print $0; gsub(/user/, "system_user"); print $0}' | xargs -n2 mv
@koenpunt
koenpunt / deploy.rb
Last active December 11, 2015 16:48
Capistrano recipe for foreman in production
set :user, "deploy"
set :runner, "deploy"
set :application, "example.com"
set :deploy_to, "/var/apps/#{application}"
set :shared_children, %w(sockets)
set :scm, :git
set :repository, "git@github.com:example.git"
set :deploy_via, :remote_cache
@koenpunt
koenpunt / gist:3994501
Created November 1, 2012 15:51
iOS Media Queries
<!-- IPAD 3 -->
<link rel="stylesheet" href="/stylesheets/ipad3.css" type="text/css"
media="only screen and (min-device-width:768px) and (max-device-width:1024px) and (-webkit-min-device-pixel-ratio:1.5)" />
<!-- IPAD 2 -->
<link rel="stylesheet" href="/stylesheets/ipad2.css" type="text/css"
media="only screen and (min-device-width:768px) and (max-device-width:1024px) and (-webkit-max-device-pixel-ratio:1.5)" />
<!-- IPAD -->
<link rel="stylesheet" href="/stylesheets/ipad.css" type="text/css"
media="only screen and (min-device-width:768px) and (max-device-width:1024px)" />
<!-- IPHONE 4 -->
@koenpunt
koenpunt / basename.conf
Created October 29, 2012 16:38
Quick Server Setup
# Gets the basename of the original request
map $request_uri $request_basename {
~/(?<captured_request_basename>[^/?]*)(?:\?|$) $captured_request_basename;
}
# Gets the basename of the current uri
map $uri $basename {
~/(?<captured_basename>[^/]*)$ $captured_basename;
}
@koenpunt
koenpunt / default-ssl
Created October 4, 2012 16:44
Using Nginx as SSL Proxy for Name Based VirtualHosts in Apache
server {
listen 443 ssl;
server_name ~^(www\.)?(?<domain>.+)$;
# It's possible to configure Nginx to serve static files directly, and
# bypassing Apache but I won't describe that here.
root /var/apps/$domain/current/public;
ssl_certificate /etc/ssl/certs/cmpgns/STAR_cmpgns_nl.crt;
ssl_certificate_key /etc/ssl/private/STAR_cmpgns_nl.key;
<?php
function gfm($text){
# Extract pre blocks
$extractions = array();
$text = preg_replace_callback('/<pre>.*?<\/pre>/s', function($matches) use (&$extractions){
$match = $matches[0];
$md5 = md5($match);
$extractions[$md5] = $match;