Skip to content

Instantly share code, notes, and snippets.

View Veejay's full-sized avatar

Bertrand Chardon Veejay

View GitHub Profile
ClientDashboard::Application.routes.draw do
namespace :admin do
resources :brands
resources :email_messages
resources :users
resources :memberships do
post 'new_by_brand', :on => :collection
end
resources :clients do
#include <stdio.h>
#include <string.h>
char* reverse(char *s)
{
int i, placeholder;
int l = strlen(s) - 1;
for(i = 0; i < (l / 2); i++){
placeholder = *(s+i);
*(s+i) = *(s+l-i);
SELECT
date(created_at) as ordered_date,
sum(price) as total_price
FROM
orders
GROUP BY
date(created_at)
HAVING
sum(price) > 100
@Veejay
Veejay / matching.rb
Created April 19, 2012 18:38
Dumb and basic version of pattern matching construct in Ruby
class Array
def extract_options!
last.is_a?(::Hash) ? pop : {}
end
end
def match(*args)
rules = args.extract_options!
if rules.has_key?(*args)
rules[*args].call
def pmap &block
if size > 0
match self.shape,
head_tail: ->{ self.tail.pmap(&block).unshift yield(self.head) },
head: ->{ [ yield(self.head) ] }
else
self
end
end
end
class Array
def extract_options!
last.is_a?(::Hash) ? pop : {}
end
def tail
head, *tail = *self
tail
end
char* format_time(time_t t)
{
char formatted_time[64];
struct tm *ts;
strftime(formatted_time, sizeof formatted_time, "%Y-%m-%d %H:%M:%S", ts);
return formatted_time;
}
hash_table.c:165:3: error: expected ')'
assert(code == LL_DELETE_OK);
^
hash_table.c:165:18: note: instantiated from:
assert(code == LL_DELETE_OK);
^
hash_table.c:7:23: note: instantiated from:
#define LL_DELETE_OK 0;
^
hash_table.c:165:3: note: to match this '('
Undefined symbols for architecture x86_64:
"_linked_list_put", referenced from:
_main in ccUFU1uN.o
"_print_linked_list", referenced from:
_main in ccUFU1uN.o
"_key_position", referenced from:
_main in ccUFU1uN.o
"_linked_list_get", referenced from:
_main in ccUFU1uN.o
"_linked_list_delete", referenced from:
def work_weeks_for_date_range(date_range)
{}.tap do |result|
date_range.each do |date|
result.store(date, WorkWeek.where(user_id: id, cweek: date.cweek, year: date.year, project_id: projects.for_company(current_company_id).map(&:id)))
end
end
end