Skip to content

Instantly share code, notes, and snippets.

View diogok's full-sized avatar

Diogo Souza da Silva diogok

View GitHub Profile
dofile("utils/http.lua")
dofile("utils/json.lua")
search = function(query)
local url = "http://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=".. http.encode(query);
local headers = {
{
"User-Agent",
"AnySearch"
}
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
<?php
$mail = "[email protected]" ;
$header = "From: [email protected]\n" ;
$msg = "Mensagem" ;
$subject = "Assunto" ;
mail($mail,$subject,$msg,$header);
(ns twitter-search
(:require [clojure.contrib.json.read :as json])
(:require [clojure.contrib.http.agent :as http ])
(:import (java.net URL URLEncoder))
)
(defn search [word last-id]
(let [term (URLEncoder/encode word "UTF-8")
result (http/string (http/http-agent (str
"http://search.twitter.com/search.json?q="
@diogok
diogok / couchdb.clj
Created August 17, 2010 12:35
couchdb.clj
(ns couchdb
(:use clojure.data.json)
(:refer-clojure :exclude [get key]))
(defn server
"Wraps a server"
[host port] {:server (str "http://" host ":" port)})
(defn db
"Wraps a database on a server"
@diogok
diogok / proxy.lua
Created April 15, 2011 17:09
Simple HTTP reverse proxy in Lua
#!/usr/bin/env lua
require 'socket'
require 'copas'
assert(arg[1],"Must pass host and port to listen")
assert(arg[2],"Must pass host and port to proxy")
local config = {
newhost=string.gsub(arg[1],"([^:]+):(%d+)","%1"),
newport=string.gsub(arg[1],"([^:]+):(%d+)","%2"),
@diogok
diogok / OnlineUsers.php
Created May 4, 2011 19:48
Online Users using PHP and Redis
<?php
include 'predis/predis.phar';
class OnlineUsers {
/* time to consider user online */
private $minutes = 5 ;
function online() {
/* current hour and minute */
<?php
namespace cncflora\repository;
class Profiles {
public $user = null;
public $couchdb = null;
public $db = null;
public function __construct($user=null) {
@diogok
diogok / etcd-to-env.sh
Last active December 6, 2015 07:55
Register running docker containers and vagrant vms into ETCD and reads them out into ENVironment vars.
#!/bin/bash
# this script tries to turn your etcd into env vars
[[ ! $EHOST ]] && EHOST="$(hostname -I | awk '{ print $1 }')"
[[ ! $EPORT ]] && EPORT=4001
[[ ! $ETCD ]] && ETCD="http://${EHOST}:$EPORT"
ETCD_FILE="/tmp/$(date +%s).etcd.json"
wget "$ETCD/v2/keys/?recursive=true" -O $ETCD_FILE
@diogok
diogok / ruby.sh
Created April 3, 2014 01:20
Ruby and rbenv setup, for vagrant.
#!/usr/bin/env bash
# basic ruby
apt-get update
apt-get install aptitude libxslt-dev libxml2-dev ruby ruby1.9.1-dev libssl-dev build-essential -y
# config ruby gems to https
gem sources -r http://rubygems.org
gem sources -r http://rubygems.org/
gem sources -a https://rubygems.org