Skip to content

Instantly share code, notes, and snippets.

View moretea's full-sized avatar

Maarten Hoogendoorn moretea

View GitHub Profile
@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
@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;
}
# 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
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
require 'capybara/dsl'
require 'capybara-webkit'
include Capybara::DSL
Capybara.current_driver = :webkit
Capybara.app_host = "http://vunet.vu.nl"
module Runner
extend self
#! /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
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().
commit e69b947e134420e1a538220de5bf5501390a6e43
Author: Maarten Hoogendoorn <maarten@moretea.nl>
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
@moretea
moretea / doesnotwork.cpp
Last active December 24, 2015 02:09
We would expect both programs to print something like ``` <x> execute <x> snoop <x+1> execute <x+1> snoop .... ``` However, this is not the case when using multiple threads within one ``SC_MODULE``` (see output of doesnotwork.cpp)
#include "aca2013.h"
#include <systemc.h>
#include <iostream>
using namespace std;
SC_MODULE(Thing) {
public:
sc_in<bool> clk;
SC_CTOR(Thing) {
maarten@maarten-laptop:~/vu/ms/pcs/heat/omp$ make heat_test
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I./../src -DTESTS_ENABLED -g3 -O0 -g -O2 -Wall -fopenmp -MT heat_test-heat_test.o -MD -MP -MF .deps/heat_test-heat_test.Tpo -c -o heat_test-heat_test.o `test -f 'heat_test.c' || echo './'`heat_test.c
heat_test.c: In function ‘test_self_weight_simple’:
heat_test.c:185:18: warning: assignment from incompatible pointer type [enabled by default]
heat_test.c:190:3: warning: passing argument 1 of ‘free’ discards ‘volatile’ qualifier from pointer target type [enabled by default]
/usr/include/stdlib.h:488:13: note: expected ‘void *’ but argument is of type ‘volatile double * volatile’
heat_test.c:191:3: warning: passing argument 1 of ‘free’ discards ‘volatile’ qualifier from pointer target type [enabled by default]
/usr/include/stdlib.h:488:13: note: expected ‘void *’ but argument is of type ‘volatile double * volatile’
heat_test.c:176:16: warning: unused variable ‘expect’ [-Wunused-variable]
mv -f .deps/heat_test-heat_t