Skip to content

Instantly share code, notes, and snippets.

@romulodl
romulodl / db-open
Created September 26, 2017 10:32 — forked from helderco/db-open
Script to open a mysql database in Sequel Pro from a service in docker-compose.
#!/bin/bash
set -e
show_help() {
cat << EOF
Usage: ${0##*/} [-u USER] [-p PASS] [-P PORT] [-H HOST] [DATABASE]
${0##*/} -h
Open a standard connection in Sequel PRO.
@romulodl
romulodl / tribe-eventbrite.class.php
Last active December 19, 2015 01:38
Tribe evetbrite tickets plugin hack to work with php 5.4 - Edit the file tribe-eventbrite.class.php form the line 1268 to 1302
<?php
public function payment_update( $postId, $eventId, $raw_post ) {
$paymentTypes = array('check' => '', 'cash' => '', 'invoice' => '');
$requestParams = 'event_id=' . $eventId;
// make it accept cash if free & assign a message
if ( 2 == $raw_post['EventBriteIsDonation'] ) {
$requestParams .= '&accept_cash=1';
$requestParams .= '&instructions_cash=' . urlencode( __( 'This event is free to attend', 'tribe-eventbrite' ) );
} else {
@romulodl
romulodl / gist:4605767
Last active December 11, 2015 13:09
Just pasting here / code by https://github.com/thoferon
class Monad
attr_reader :value
def bind(f)
raise "not implemented"
end
def self.return(v)
self.new v
end
@romulodl
romulodl / example_regex.php
Created December 20, 2011 23:22
Example of REGEX
<?php
//pega tudo que tem oi ou ola = (oi|ola)
$pattern = "/(oi|ola)/";
//para evitar que palavras derivadas de oi ou ola (ex: foi, escola) sejam capturadas, colocamos \b antes e depois um \W, um "no word" (caractere que não seja uma letra, ex: espaço, vírgula).
$pattern = "/\b(oi|ola)\W/";
?>
@romulodl
romulodl / edit_title.php
Created December 6, 2011 00:44
Example of OO Wordpress plugin (comments in portuguese)
<?php
/*
Plugin Name: Edit Title
Plugin URI: http://romulodl.com/
Description: Example of OO Wordpress plugin (comments in portuguese)
Author: Romulo De Lazzari
Version: 0.1
Author URI: http://romulodl.com/
*/
@romulodl
romulodl / word_boundary.php
Created December 1, 2011 01:16
Word Boundary \b php example
<?php
/**
* Example using Word Boundaries (\b)
*/
$regex = "/\b4\b/";
$string = "4, 44, 41, 99, 404, 433, 004, 4";
preg_match_all($regex, $string, $matches);
print_r($matches);
/**
@romulodl
romulodl / caralho.php
Created November 9, 2011 02:41
Wordpress workaround to Facebook's like button bug (?fb_xd_fragment=$)
<?php
/**
* @package Caralho!
* @version 1.6
*/
/*
Plugin Name: CARALHO
Plugin URI: http://pudim.com.br
Description: (CARALHO == portuguese of FUCK). If you are getting a blank page because of the "?fb_xd_fragment=$" in your URI, this plugin could be your solution!
Author: CARALHO!