Skip to content

Instantly share code, notes, and snippets.

import (
"database/sql"
"database/sql/driver"
"errors"
"fmt"
"github.com/lib/pq"
_ "github.com/lib/pq"
"math/rand"
"net/url"
"strings"
Pry.config.editor = "vim --noplugin"
if defined?(PryByebug)
Pry.commands.alias_command 'c', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.commands.alias_command 'f', 'finish'
Pry.commands.alias_command 'b', 'break'
Pry.commands.alias_command 'bda', 'break --disable-all'
end
@marciol
marciol / postgres_queries_and_commands.sql
Created October 21, 2016 17:03 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@marciol
marciol / with.exs
Created April 15, 2016 14:25 — forked from nsomar/with.exs
Handling errors with `with`
res =
with {:ok} <- validate_request(request),
{:ok, user} <- get_user(request),
{:ok} <- update_db(user),
{:ok} <- send_email(user) do
return_http_message
end
case res do
{:error, x} -> IO.inspect("Error: " <> x)
@marciol
marciol / p2p-list.md
Created February 3, 2016 19:45 — forked from moshest/p2p-list.md
A collection of peer-to-peer decentralized projects.
// Example of how to use stdlib in go, leveraging the simplicity of solutions without dependencies
// based on https://www.youtube.com/watch?v=yi5A3cK1LNA&feature=youtu.be&t=11m45s
func productHandler(w http.ResponseWriter, r *http.Request) {
key := r.URL.PATH[len("/products/"):]
switch r.Method {
case "GET":
// do get stuff
case "POST":
// do post stuff
@marciol
marciol / build.sh
Last active August 29, 2015 14:25 — forked from cevaris/build.sh
Debugging golang in GDB
go build -gcflags '-N'
package controllers
import env.Env
import play.api.libs.json.JsArray
import play.api.mvc._
import play.api.libs.concurrent.Execution.Implicits._
// here's where the injection takes place
class Application(env: Env) extends Controller {
import env._ // to avoid writing something like env.WS.url() or env.configuration.get...
@marciol
marciol / init.el
Last active August 29, 2015 14:11
(require 'cask "~/.cask/cask.el")
(cask-initialize)
(require 'pallet)
(pallet-mode t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; APPEARANCE CUSTOMIZATIONS ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Startup
@marciol
marciol / Cask
Last active August 29, 2015 14:11
(source "melpa" "http://melpa.milkbox.net/packages/")
(source gnu)
(source marmalade)
(depends-on "auctex")
(depends-on "auto-complete")
(depends-on "cask")
(depends-on "clojure-mode")
(depends-on "coffee-mode")
(depends-on "color-theme")