Skip to content

Instantly share code, notes, and snippets.

View rcanepa's full-sized avatar

Renzo Canepa rcanepa

  • Santiago, Chile
View GitHub Profile
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto
@rcanepa
rcanepa / mit_scheme_on_osx.md
Last active December 19, 2015 15:51
Installing MIT Scheme on OSX

#Instructions to install MIT Scheme on OSX

  1. Download either the 32-bit or 64-bit dmg file for Scheme from http://ftp.gnu.org/gnu/mit-scheme/stable.pkg/.

  2. Double click the .dmg file, and you'll get this window, in which you should drag the "MIT/GNU Scheme" file into the Applications folder.

  3. Execute the following commands depending on the package version and OSX version:

##OSX pre El Capitan##

####For the 32-bit version####

@rcanepa
rcanepa / CREATE_DATABASE.sql
Created December 16, 2015 15:11
Basic setup for a dev and test database on PostgreSQL
CREATE DATABASE auth;
CREATE DATABASE auth_test;
\c auth;
CREATE EXTENSION citext;
\c auth_test;
CREATE EXTENSION citext;
CREATE ROLE auth_user LOGIN;
ALTER ROLE auth_user WITH PASSWORD 'password1';
GRANT ALL PRIVILEGES ON DATABASE auth to auth_user;
GRANT ALL PRIVILEGES ON DATABASE auth_test to auth_user;
@rcanepa
rcanepa / pre_post_cond_example.clj
Created December 15, 2015 14:57
Improve feedback from Clojure function pre/post conditions.
(defn string-to-string [s1]
{:pre [(or (string? s1)
(throw (Exception. (format "Pre-condition failed; %s is not a string." s1))))]
:post [(or (string? %)
(throw (Exception. (format "Post-condition failed; %s is not a string." %))))]}
s1)
@rcanepa
rcanepa / gist:535163dc249539912c25
Last active May 2, 2024 07:08
Activate pg_stat_statements on PostgreSQL
1) Edit file postgresql.conf and add the next 3 lines (any where):
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.max = 10000
pg_stat_statements.track = all
2) Restart PostgreSQL
3) Execute the next command on psql, pgAdmin or similar:
@rcanepa
rcanepa / components.clj
Created December 7, 2015 03:24 — forked from Deraen/components.clj
Compojure-api with Component
(ns foobar.components
(:require [com.stuartsierra.component :as component]
[compojure.api.sweet :refer :all]))
(defmethod compojure.api.meta/restructure-param :components
[_ components acc]
(update-in acc [:letks] into [components `(::components ~'+compojure-api-request+)]))
(defn wrap-components [handler components]
(fn [req]
@rcanepa
rcanepa / richhickey.md
Created November 1, 2015 12:41 — forked from prakhar1989/richhickey.md
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@rcanepa
rcanepa / gist:229bc46957778629521f
Last active August 16, 2019 00:59
C++ Snippets
/*
Short list of macros and templates from
http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=standardTemplateLibrary
*/
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#defile all(c) (c).begin(),(c).end()
@rcanepa
rcanepa / gist:767040cb76491463287d
Created February 19, 2015 16:49
c++ Quick Sort (random pivot)
#include <iostream>
#include <stdlib.h>
void quick_sort(int *list, int p, int r);
int main(int argc, char const *argv[])
{
int n = 11;
int list[n];
srand(time(NULL));
@rcanepa
rcanepa / gist:923e04598390a8863033
Created February 19, 2015 01:35
C++ Merge Sort
#include <iostream>
#include <stdlib.h>
/*
This implementation could be improved using
sentinels.
*/
void merge_sort(int *list, int p, int r);