Skip to content

Instantly share code, notes, and snippets.

View mmohiudd's full-sized avatar

Muntasir Mohiuddin mmohiudd

View GitHub Profile
@mmohiudd
mmohiudd / CustomManager.py
Created October 17, 2012 03:13
MySQL INSERT … ON DUPLICATE KEY UPDATE with django 1.4 for bulk insert
import datetime
from pprint import pprint
from django.db import models, signals
from django.utils import timezone
import django.dispatch
@mmohiudd
mmohiudd / csv_table_generator.php
Created September 17, 2012 16:18
MySQL table generator from CSV file
<?php
// GENERATE TABLE FROM FIRST LINE OF CSV FILE
$inputFile = 'csv/sample.csv'; // path to CSV file
$tableName = 'csv'; // table name
$fh = fopen($inputFile, 'r');
$contents = fread($fh, 5120); // 5KB
fclose($fh);
@mmohiudd
mmohiudd / csv_parser.php
Created September 17, 2012 16:17
Generic CSV parser
<?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__))) {
@mmohiudd
mmohiudd / ua-test-script.php
Created July 27, 2012 16:49
Urban Airship test script
<?php
send_push($_REQUEST['alert'], $_REQUEST['appkey'], $_REQUEST['appmaster']);
function send_push($alert, $appkey, $appmaster) {
$badge = 1; // default is 1
$auth = $appkey . ":" . $appmaster;
$url = "https://go.urbanairship.com/api/push/broadcast/";
@mmohiudd
mmohiudd / home.php
Created July 12, 2012 17:03
$_REQUEST variable for Kohana
class Controller_Home extends Controller {
protected $args; // store GET/POST variables
public function before() {
parent::before();
// if a GET request
if( $this->request->method() == "GET" ) {
$this->args = $this->request->query();
@mmohiudd
mmohiudd / code.js
Created June 26, 2012 21:52
Use batch request to grab and save Facebook test user information
args.batch.push({
method : "GET",
name : "get-users",
relative_url : "/"+app.id+"/accounts/test-users",
omit_response_on_success : false
});
args.batch.push({
method : "GET",
relative_url : "?ids={result=get-users:$.data.*.id}"
@mmohiudd
mmohiudd / change_password.py
Created June 16, 2012 04:07
change Facebook test user password
#!/usr/bin/env python
'''
Change Facebook test users password
'''
import urllib, urllib2, json
# makes a batch call to facebook
# access_token : facebook access token
@mmohiudd
mmohiudd / before.php
Created May 28, 2012 23:07
kohana before for open grabp
public function before(){
parent::before();
// this block provides header information for facebook send message popup
if( preg_match('/facebook/', $_SERVER['HTTP_USER_AGENT'])) {
$facebook_config = kohana::$config->load('facebook');
$share = $facebook_config['share'][$this->lang];
$item_id = $this->request->query('id');
$media = ORM::factory('Media', $item_id)->as_array();
@mmohiudd
mmohiudd / wp_url_updater.php
Created May 15, 2012 18:16
WordPress URL update script
<?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
@mmohiudd
mmohiudd / save.php
Created May 9, 2012 12:38
save Facebook test users to database
<?php
ini_set('precision', 20);
?>
<!-- Decreased Latency -->
<!-- Increased parallelism -->
<!-- Better caching -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="js/mustache.js" type="text/javascript"></script><!-- -->
<script>