Skip to content

Instantly share code, notes, and snippets.

/*
go ftm postgresql_api.go
go build postgresql_api.go
install:
go get github.com/lib/pq
CREATE DATABASE "social_network" WITH ENCODING 'UTF8';
GRANT ALL ON DATABASE "social_network" TO santo;
CREATE SEQUENCE users_id_seq
START WITH 1
@hectorgool
hectorgool / mongo_script.js
Created March 11, 2016 16:23
An insert example
db.offert.remove({})
db.offert.insert(
{
"_id" : ObjectId().str,
"name" : "Nombre de la Oferta 1",
"cost" : "5000",
"course" : {
"name" : "Nombre del Curso 1",
@hectorgool
hectorgool / elastigo_example.go
Created March 31, 2016 21:53
Elastigo Example
/*
curl -X PUT "http://localhost:9200/mx2/postal_code/1" -d "
{
\"cp\" : \"20000\",
\"colonia\" : \"Zona Centro\",
\"ciudad\" : \"Aguascalientes\",
\"delegacion\" : \"Aguascalientes\",
\"location\": {
\"lat\": \"22.0074\",
@hectorgool
hectorgool / main.go
Created August 31, 2016 22:56
Go Kit example
/*
go get -t
curl -XPOST -d'{"s":"hello, world"}' localhost:8080/uppercase
curl -XPOST -d'{"s":"hello, world"}' localhost:8080/count
*/
package main
import (
"encoding/json"
"errors"
@hectorgool
hectorgool / postgres.go
Created September 12, 2016 18:04
CRUD postgreSQL
/*
https://astaxie.gitbooks.io/build-web-application-with-golang/content/en/05.4.html
CREATE DATABASE "prueba" WITH ENCODING 'UTF8';
CREATE USER "santo" WITH PASSWORD 'asdfasdf';
GRANT ALL ON DATABASE "prueba" TO santo;
CREATE TABLE userinfo
(
uid serial NOT NULL,
@hectorgool
hectorgool / getip.go
Last active November 2, 2016 19:12
Get doker ip container and print
/*
http://stackoverflow.com/questions/26411594/executing-docker-command-using-golang-exec-fails
*/
package main
import (
"fmt"
"os/exec"
)
@hectorgool
hectorgool / elasticsearch_client.go
Created November 2, 2016 19:08
ElasticSearch Client go example
package main
import (
"encoding/json"
"fmt"
"reflect"
elastic "gopkg.in/olivere/elastic.v3"
)
#!/usr/bin/perl
system("clear");
open( F, "id_attachment.txt" ) || die "Error al abrir archivo";
@base = <F>;
$contador = 0;
foreach ( @base ) {
class Admin::ToursController < Admin::ApplicationController
before_action :set_tour, only: [:edit, :update, :destroy]
def new
@tour = Tour.new
#3.times { @tour.attachments.build }
@tour.attachments.build
end
@hectorgool
hectorgool / jsongo.go
Created November 22, 2016 17:21
query term
package main
/*
{
"query": {
"match": {
"_all": {
"operator": "and",
"query": "Rodolfo Guzman Huerta"
}