This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS test_table; | |
CREATE TABLE test_table( | |
id bigserial NOT NULL, | |
latitude double precision, | |
longitude double precision, | |
geom geometry, | |
geog geography, | |
updated_ts double precision, | |
CONSTRAINT test_table_unique_key UNIQUE (id) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from pprint import pprint | |
from django.db import models, signals | |
from django.utils import timezone | |
import django.dispatch | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Facebook\FacebookSession; | |
use Facebook\FacebookRequest; | |
use Facebook\GraphUser; | |
use Facebook\FacebookRequestException; | |
FacebookSession::setDefaultApplication('YOUR_APP_ID','YOUR_APP_SECRET'); | |
// Use one of the helper classes to get a FacebookSession object. | |
// FacebookRedirectLoginHelper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Copyright (c) 2011 Muntasir Mohiuddin<muntasir@bakedproject.com> | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // php csv_parser.php <table name> <csv target> <sql target> | |
ini_set('memory_limit', '8000M'); | |
ini_set('max_execution_time', 3000); | |
if (empty($argc)) { | |
echo "Arguments missing"; | |
exit(1); | |
} | |
if (!strstr($argv[0], basename(__FILE__))) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCSVData($file){ | |
$info = pathinfo($file); | |
$fp = @fopen($file, "r"); | |
$data = array(); | |
$line = fgets($fp, 4096); // read the first line, headers | |
// use /[ "\']+/ to remove white spaces as well | |
$fields = preg_replace('/[ "\']+/', '', explode(",", trim($line))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Flatten a multi dimension array. For an associative array the child keys are separated by underscore(_). | |
* @author Muntasir Mohiuddin | |
* @param array $a multidimensional array to flatten | |
* @param array $a multidimensional array to save values | |
* @param string $p previous parents separated by underscore(_) | |
* @return array all flattened keys | |
*/ | |
function flatten_array($a, &$r, $p=NULL){ | |
foreach($a as $k => $v) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The text file data.txt contains the following | |
ZADD myzset 1 a | |
ZADD myzset 1 b | |
ZADD myzset 1 c | |
Run this command to read from data file and insert to redis: | |
cat data.txt|xargs -n 4 redis-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[circus] | |
check_delay = 5 | |
endpoint = tcp://127.0.0.1:5555 | |
pubsub_endpoint = tcp://127.0.0.1:5556 | |
;stats_endpoint = tcp://127.0.0.1:5557 | |
httpd = False | |
debug = False | |
[plugin:flapping] | |
use = circus.plugins.flapping.Flapping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
ini_set("error_reporting",E_ALL); | |
ini_set("display_errors",1); | |
printf("%s MAIN %s\n\n", getmypid(), date("H:i:s")); | |
$shm_id = shm_attach(1); | |
$main_process_id = getmypid(); |
NewerOlder