Skip to content

Instantly share code, notes, and snippets.

View moretea's full-sized avatar

Maarten Hoogendoorn moretea

View GitHub Profile
commit e69b947e134420e1a538220de5bf5501390a6e43
Author: Maarten Hoogendoorn <[email protected]>
Date: Thu Sep 12 10:12:56 2013 +0200
Adapt Makefile so that it runs both on my machine as the UvA machines
diff --git a/Makefile b/Makefile
index 49430e4..71b0200 100644
--- a/Makefile
+++ b/Makefile
h$ erl -pa ebin/
Erlang R16B01 (erts-5.10.2) [source-bdf5300] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V5.10.2 (abort with ^G)
1> c(simple_search_server).
simple_search_server.erl:none: no such file or directory
error
2> l(simple_search_server).
{module,simple_search_server}
3> simple_search_server:start_link().
#! /usr/bin/env ruby
def get_env_or_fail(name)
if ENV.has_key?(name)
ENV[name]
else
$stderr.puts "Missing variable: #{name}"
exit 1
end
end
require 'capybara/dsl'
require 'capybara-webkit'
include Capybara::DSL
Capybara.current_driver = :webkit
Capybara.app_host = "http://vunet.vu.nl"
module Runner
extend self
class Person
include Webhook
end
module Webhook
included do
before_save :store_changes
after_save :execute_webhook_after_save
after_destroy :execute_webhook_after_destroy
end
# service nginx configtest
Testing nginx configuration: nginx: [emerg] unknown directive " " in /etc/nginx/sites-enabled/paagrank:5
nginx: configuration file /etc/nginx/nginx.conf test failed
@moretea
moretea / signal.c
Created December 6, 2012 22:16
Tip: Use a signal handler to be able to run valgrind on a server program
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
static char keep_running;
void handler(int signal) {
printf("Got signal %i, closing down soon!\n", signal);
keep_running = 0;
}
@moretea
moretea / i18n_gem.rb
Created October 11, 2012 09:55
Idea about I18n edit in websites
class I18n
method_alias_chain :translate, :helper
DEFAULTMEHOPTIONS= {helper: true}
def translate_with_helper key, options
options = DEFAULTMEHOPTIONS.merge(options)
txt = translate_without_helper key, options
# routes.rb is the same
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
include ApplicationHelper # Force it to be present in all controllers
before_filter :find_login_and_account
end
# app/helpers/application_helper.rb
module ApplicationHelper
# routes.rb
TestApp::Application.routes.draw do
resources :logins
resource :session
resources :accounts do
resources :things
end
end