Skip to content

Instantly share code, notes, and snippets.

View jesperronn's full-sized avatar

Jesper Rønn-Jensen jesperronn

View GitHub Profile
@trcook
trcook / rakefile.md
Last active February 18, 2018 10:34
Advanced Rake Rules and Conditional Rake Rules

rules matching by regex

Occassionally we want to make a rule that matches on something more complex than file extensions. If, for example files that will be prefixed with pandoc_ depend on files that do not contain the prefix.

Ex: pandoc_slides=>slides.rmd. we can make a rule that will capture this, but we need to use a lambda function to do so:

rule (%r{pandoc_.*\.md}) => lambda{|objfile| potential_source_files.find{objfile.pathmap("%{pandoc_,}n")}} do |t|
	puts "This rule gets #{t.name} from #{t.source}"
end
#!/bin/bash
git --no-pager grep "$@"
git --no-pager submodule --quiet foreach 'git grep --full-name -n ' "$@" '; true'
@borgand
borgand / git-merge-svn
Last active January 7, 2019 06:44
A helper script to set *svn:mergeinfo* property when using `git svn dcommit` on merged git branches.This makes it possible to merge two SVN branches using **git-svn**.NB! the merged-from branch **MUST** be pushed to SVN.USAGE: git merge-svn <branch name>EDIT: added exit condition when mergeinfo calculation fails to avoid pushing incomplete merge…
#!/bin/bash
function usage {
echo "USAGE: git merge-svn <from> [<to>]"
echo ""
echo " from The branch name to be merged FROM"
echo " to Optional branch name to be merged onto. Default: HEAD"
echo ""
}
@KyleJamesWalker
KyleJamesWalker / VagrantSSHAngentForwardingWithAnsible.md
Last active December 10, 2019 01:37
Vagrant SSH Agent Forwarding Working 1.4.3

This was working on Vagrant 1.4.3 (Mac).

#HOST#

File: ~/.ssh/config

Host vagrant.*
ForwardAgent yes

File: Vagrantfile

@benedikt
benedikt / rails.rb
Created July 30, 2011 13:16
Capistrano task to open a rails console on a remote server. Require this file in your deploy.rb and run "cap rails:console"
# encoding: UTF-8
Capistrano::Configuration.instance(:must_exist).load do
namespace :rails do
desc "Open the rails console on one of the remote servers"
task :console, :roles => :app do
hostname = find_servers_for_task(current_task).first
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'"
end
end
@jesperronn
jesperronn / git-global-config.sh
Last active November 28, 2020 05:04
Standard Git Config global options
#!/bin/bash
# Standard shortcuts for my usual git configuration
#
# http://www.arthurkoziel.com/2008/05/02/git-configuration/
#
#
# SVN-like shortcuts for often used commands:
git config --global alias.st status -bs
@sabman
sabman / dockerize-app.production.sh
Last active March 16, 2021 14:01
Running Rails 5.0.1 + PostGIS + puma + nginx in production using docker-compose 2 blog for this: https://medium.com/@sabman/running-rails-5-0-1-postgis-puma-nginx-in-production-using-docker-compose-2-d8d98cbef33c#.z9a3qqjar
APP_NAME=dockerized-rails
RAILS_ROOT=/usr/app/${APP_NAME}
RAILS_ENV=production
cd $APP_NAME
# Before we start we'll make sure that we have a scaffolded app just to make sure we can test everything is working.
docker-compose up
docker-compose run app bundle exec rails generate scaffold post title body:text published:boolean RAILS_ENV=development
@benjchristensen
benjchristensen / index.html
Created August 9, 2011 05:38
Simple Sparkline using SVG Path and d3.js
<html>
<head>
<title>Simple Sparkline using SVG Path and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;
# Blog post for this: https://medium.com/@sabman/running-rails-5-0-1-postgis-using-docker-compose-2-a0ce5e5fbaba#.j6scfvmw6
APP_NAME=dockerized-rails
rails _5.0.1_ new $APP_NAME -d postgresql
cd $APP_NAME
mkdir -p containers/development
RAILS_ENV=development
# 1. create a Dockerfile for development
cat > ./containers/development/Dockerfile <<EOF
/**
* Caches the return value of get accessors and methods.
*
* Notes:
* - Doesn't really make sense to put this on a method with parameters.
* - Creates an obscure non-enumerable property on the instance to store the memoized value.
* - Could use a WeakMap, but this way has support in old environments.
*/
export function Memoize(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) {
if (descriptor.value != null) {