Skip to content

Instantly share code, notes, and snippets.

View bycosta's full-sized avatar

Caio Costa bycosta

  • Mérida, Yucatán, México
View GitHub Profile
@SethRobertson
SethRobertson / index.md
Created December 30, 2011 18:22
Commit Often, Perfect Later, Publish Once: Git Best Practices
@nikic
nikic / coroutine.php
Created July 14, 2012 13:25
A coroutine example: Streaming XML parsing using xml_parser
<?php
error_reporting(E_ALL);
/* Data can be send to coroutines using `$coroutine->send($data)`. The sent data will then
* be the result of the `yield` expression. Thus it can be received using a code like
* `$data = yield;`.
*/
/* What we're building in this script is a coroutine-based streaming XML parser. The PHP
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 1, 2024 13:31
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%'
@kristerkari
kristerkari / lazyeval.html
Last active February 6, 2020 04:00
Lazy evaluating Javascript code
<html>
<body>
<!-- ----------------------------------------------- -->
<!-- inline script block with commented code inside: -->
<!-- ----------------------------------------------- -->
<script id="myjscode">
/*
(function(h,v){function q(b){if(""===m)return b;
@Hounddog
Hounddog / templatemap_generator.php
Created November 29, 2012 13:51
Template Map Generator
#!/usr/bin/env php
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@nixpulvis
nixpulvis / description_printer.rb
Last active December 14, 2015 15:09
Automatically print tasks description wrapping the execution of the task.
# Automatically print tasks description wrapping the execution of
# the task.
module Capistrano::Configuration::Namespaces
alias_method :_task, :task
def task(name, options = {}, &block)
desc = next_description
full_task_name = [fully_qualified_name, name].compact.join(':')
$column = 0
$last_was_after = true
@nikic
nikic / php-5.5-features.md
Last active August 31, 2020 10:39
List of new features in PHP 5.5
@rais38
rais38 / gist:5766980
Created June 12, 2013 16:35
Create patch from stash
git stash show -p stash@{0} > Stash0.patch
@danielcosta
danielcosta / post-merge
Created September 17, 2014 17:41
post-merge hook for bob/alice (mobly)
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` or `git merge` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"