Skip to content

Instantly share code, notes, and snippets.

View munen's full-sized avatar

Zen Monk Alain M. Lafon munen

View GitHub Profile
@munen
munen / FindTranslation.vim
Last active December 22, 2015 01:59
Vimscript / Ruby function to find a key in a nested yaml key/value pair (i.e. a Rails translation)
function! FindTranslation(pat)
let s = ""
ruby << EOF
pat = VIM::evaluate 'a:pat'
pat = pat.gsub("\.", ":\\\\\\n\ *")
s = "normal! gg/#{pat}/e+1\\<cr>"
VIM::command "let s = \"#{s}\""
VIM::command "execute s"
EOF
endfunction
# -*- coding: utf-8 -*-
from flask import Flask
from flask.helpers import url_for
from flask import request
import json
import re
app = Flask(__name__)
# helper method to extract parameters. reqest to api has the following format:
@munen
munen / hange_remote_origin.sh
Created March 9, 2013 12:31
Change github username from 'preek' to 'munen' in repository
echo "Showing old remote origin"
git remote -v
echo "--------"
NEW_REMOTE=$(git remote -v | head -n1 | awk '{print $2}' | sed -e 's/preek/munen/')
git remote set-url origin $NEW_REMOTE
if (( $? ));
then echo "failed to set new remote, please adjust manually";
else echo "succeeded in setting new remote";
fi
echo "--------"
@munen
munen / gist:4621454
Created January 24, 2013 13:16
hev strike-through demo
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<style>
//.fill {
// visibility: hidden;
//}
</style>
<script>
$(document).ready(function() {
@munen
munen / gist:3082037
Created July 10, 2012 08:30
fibonacci rekursiv/memoized (mit hash als cache)
var range = [];
for (var i = 1; i < 4000000; i++){
range.push(i);
}
var fib_cache = { 0 : 0, 1 : 1 }
function fib(n) {
if (fib_cache[n] == undefined) {
fib_cache[n] = fib(n-1) + fib(n-2);
@munen
munen / gist:3082038
Created July 10, 2012 08:31
fibonacci iterativ
var sum = 0
var y = 0
var z = 1
var buff = 0;
while( y<4000000 )
{
if(y%2)
sum+=y;
buff=y+z;
y=z;
# output bootstrap friendly markup
gem 'formtastic', :git => 'git://github.com/justinfrench/formtastic.git', :branch => '2.1-stable'
gem 'formtastic-bootstrap', :git => 'https://github.com/cgunther/formtastic-bootstrap.git', :branch => 'bootstrap2-rails3-2-formtastic-2-1'
# twitter bootstrap
gem 'anjlab-bootstrap-rails', '2.0.1.1', :require => 'bootstrap-rails'
@munen
munen / config.ru
Created January 30, 2012 09:14
ruby one line http directory server using rack
run Rack::Directory.new ('.')
# --- NEW FILE: users_controller_spec.rb
describe UsersController do
context 'with required parameters' do
it 'creates a new entry' do
post :create, :user => { :name => "foo" }
User.first.name.should eq("foo")
end
end
end