Skip to content

Instantly share code, notes, and snippets.

View mmohiudd's full-sized avatar

Muntasir Mohiuddin mmohiudd

View GitHub Profile
@mmohiudd
mmohiudd / geo_update_trigger.sql
Created September 30, 2015 17:03
Update geometry and geography data with a trigger for PostgreSQL(PostGIS)
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)
);
@mmohiudd
mmohiudd / API.md
Last active August 29, 2015 14:24 — forked from iros/API.md

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@mmohiudd
mmohiudd / gist:1c04702b965d309c2027
Created February 10, 2015 17:33
redis mass insertion
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
@mmohiudd
mmohiudd / facebook-batchcall.php
Created May 8, 2014 22:21
Batch call with facebook-php-sdk-v4
<?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
@mmohiudd
mmohiudd / falatten_array.php
Created November 14, 2013 21:47
Flatten a multidimensional array with keys separated by _
/**
* 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) {
@mmohiudd
mmohiudd / circusd.ini
Created September 5, 2013 17:51
testing SIGNALs with circusd
[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
@mmohiudd
mmohiudd / fork.php
Created July 31, 2013 20:17
sample fork with shared memory
#!/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();
@mmohiudd
mmohiudd / csv_parser.php
Last active October 7, 2018 21:23
Basic CSV parse function
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)));
@mmohiudd
mmohiudd / send_dialog.html
Last active December 12, 2015 06:58
send dialog test
<h1>feed</h1>
<p>
Publishing to the stream is easy, as all the fields are optional. Just specify
what you need, and leave the rest out.
</p>
<script>
var publish = {
method: 'send',
to: [120803038, 100002268364410], // comma separated friend ids
@mmohiudd
mmohiudd / authorize.js
Created November 1, 2012 18:18
FB JS auth
function authorize(){
FB.login(function(response) {
if(response.authResponse) { // user authorized
// do something
} else { // not authorized
// do something
}
},{
scope: '{{fb_permissions}}'
});