Skip to content

Instantly share code, notes, and snippets.

View Chemaclass's full-sized avatar
🏗️
building

Jose M. Valera Reales Chemaclass

🏗️
building
View GitHub Profile
@jordillonch
jordillonch / async_fetcher.php
Created March 29, 2014 22:42
HHVM async example using curl_multi_exec
<?hh
// Based on https://gist.github.com/chregu/9740519
class Fetcher {
// async function: http://docs.hhvm.com/manual/en/hack.async.php
// return type annotation: http://docs.hhvm.com/manual/en/hack.annotations.introexample.php
// generics: http://docs.hhvm.com/manual/en/hack.generics.php
public async function fetch(string $url) : Awaitable<array>
{
@chregu
chregu / gist:9740519
Last active October 11, 2018 08:55
HHVM async example
<?hh
class Fetcher {
// async function: http://docs.hhvm.com/manual/en/hack.async.php
// return type annotation: http://docs.hhvm.com/manual/en/hack.annotations.introexample.php
// generics: http://docs.hhvm.com/manual/en/hack.generics.php
public async function fetch(string $url) : Awaitable<int> {
$ch1 = curl_init();
print "get $url \n";
$logger = new Logger('test logger');
$memoryStream = fopen('php://memory', 'w');
$memoryHandler = new StreamHandler($memoryStream);
$logger->pushHandler($memoryHandler);
// your code
rewind($memoryStream);
$logs = stream_get_contents($memoryStream);
@honza
honza / gist.md
Created June 30, 2013 23:03
Clojure vs Haskell

Haskell vs Clojure

The JSON data is in the following format

{
    "Genesis": {
        "1": {
            "1": "In the beginning..." ,
            "2": "..."
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 30, 2025 00:48
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), 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(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@bvsatyaram
bvsatyaram / .gitconfig
Created December 20, 2011 05:10 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = [email protected]
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
smtpuser = [email protected]
@bowsersenior
bowsersenior / stooge_loader.rb
Created May 18, 2011 23:18
A demo of YAML anchors, references and nested values
require 'rubygems'
require 'yaml'
# A demonstration of YAML anchors, references and handling of nested values
# For more info, see:
# http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/
stooges = YAML::load( File.read('stooges.yml') )
# => {
# "default" => {