Skip to content

Instantly share code, notes, and snippets.

View avargas's full-sized avatar

Angelo Vargas avargas

View GitHub Profile
{
'mongod': [
{'ip': '1.2.3.4:1234'},
{'ip': '1.2.3.4:1234'},
{'ip': '1.2.3.4:1234'}
],
'config': [
{'ip': '1.2.3.4:1234'},
{'ip': '1.2.3.4:1234'},
{
type: 'cluster',
members: [
{
type: 'shard',
members: [
{
type: 'mongod',
name: 'shard1'
},
@avargas
avargas / monitor-run.php
Created April 24, 2012 21:19
php script rerun on saved changes
<?php
function monitor ($file)
{
$last = filemtime($file);
$command = trim(`which php`);
$command .= " -f " . $file;
$command .= ' 2>&1';
<?php
class Controller {
public function run ()
{
SomeLibrary::accidentalStatic();
}
public function __toString ()
{
@avargas
avargas / gist:2243016
Created March 29, 2012 19:52
Git push current branch!!!
$ git push `remote name` `local branch`:`remote_branch`
@avargas
avargas / gist:1474305
Created December 13, 2011 22:47
proof of concept quick and simple php benchmarking and profiling
<?php
function ticks_counter ($return = null)
{
static $ticks;
if ($return) {
return $ticks;
}
@avargas
avargas / gist:1356141
Created November 10, 2011 20:40
MongoDB Tail (Graylog2 messages)
<?php
function bash_color($string, $color='white', $background='black') {
$colored_string = "";
$_color['black'] = '0;30';
$_color['dark_gray'] = '1;30';
$_color['blue'] = '0;34';
$_color['light_blue'] = '1;34';
@avargas
avargas / gist:1355521
Created November 10, 2011 17:34
debian package patch and re-generate deb
$ apt-get source nginx
$ cd nginx*
$ patch -p1 < /patch
$ ...
$ dpkg-buildpackage -rfakeroot -uc -b
@avargas
avargas / gist:1328457
Created October 31, 2011 18:53
MySQL query without locking
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
select * from big_data_table;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
@avargas
avargas / gist:1232324
Created September 21, 2011 15:15
java posting example
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.net.URL;
import java.util.Hashtable;
import java.util.Map;
import java.util.Iterator;