Skip to content

Instantly share code, notes, and snippets.

View remoharsono's full-sized avatar

Remo Harsono remoharsono

View GitHub Profile
@remoharsono
remoharsono / gist:95910ed53c1a1e4f8d60
Created January 11, 2016 01:34 — forked from emptyhammond/gist:1603144
Make a PUT request with jQuery.ajax()
$.ajax({
type: 'POST', // Use POST with X-HTTP-Method-Override or a straight PUT if appropriate.
dataType: 'json', // Set datatype - affects Accept header
url: "http://example.com/people/1", // A valid URL
headers: {"X-HTTP-Method-Override": "PUT"}, // X-HTTP-Method-Override set to PUT.
data: '{"name": "Dave"}' // Some data e.g. Valid JSON as a string
});
/* Some clients do not support PUT or it’s difficult to send in a PUT request. For these cases, you could POST the request with a request header of X-HTTP-Method-Override set to PUT. What this tells the server is that the intended request is a PUT. Obviously this relies on the API you are accessing making use of the X-HTTP-Method-Override Header.*/
@remoharsono
remoharsono / shape2mysql
Created May 4, 2016 17:46 — forked from rugbyprof/shape2mysql
Add shapefile to MySQL
ogr2ogr -f MySQL MySQL:DATABASENAME,host=localhost,user=USER,password=PASSWORD SHAPEFILE.shp -nln TABLENAME -update -overwrite -lco engine=MYISAM
@remoharsono
remoharsono / jquery add & remove table rows
Created June 25, 2016 02:55 — forked from abixalmon/jquery add & remove table rows
jQuery function to add and remove table row. Works with a form attached.
<table class="table table-striped table-bordered" id="form_fields_data">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
@remoharsono
remoharsono / face-boxer-usage.md
Created July 8, 2016 07:26 — forked from dannguyen/face-boxer-usage.md
A face-detection script in Python

This face-boxer.py script is more-or-less the same code that you'll find in the OpenCV tutorial: Face Detection using Haar Cascades. For another variation, with more explanation, check out RealPython's tutorial.

Usage

The face-boxer.py script is designed to be run from the command-line. It has two required arugments:

  1. The path to a XML file containing a Haar-cascade of visual features. In this example, it will be the features that make up a face.
  2. The path to an image file that you want to perform face-detection on. You can pass in more than one image file as space-separated arguments.
@remoharsono
remoharsono / pclzip.lib.php
Created July 21, 2016 15:36 — forked from Idered/pclzip.lib.php
Unzip file with php
<?php
// --------------------------------------------------------------------------------
// PhpConcept Library - Zip Module 1.3
// --------------------------------------------------------------------------------
// License GNU/LGPL - Vincent Blavet - January 2003
// http://www.phpconcept.net
// --------------------------------------------------------------------------------
//
// Presentation :
// PclZip is a PHP library that manage ZIP archives.
@remoharsono
remoharsono / helloworld-win32-service.py
Created August 30, 2016 02:22 — forked from drmalex07/helloworld-win32-service.py
An example Windows service implemented with pywin32 wrappers. #python #windows-service #pywin32
import win32serviceutil
import win32service
import win32event
import servicemanager
import socket
import time
import logging
logging.basicConfig(
filename = 'c:\\Temp\\hello-service.log',
@remoharsono
remoharsono / PHPExcel_Read_Data.php
Last active September 12, 2016 12:17 — forked from jorisros/gist:ac83ca2b53e3fe3ed233
Example PHPExcel read data
//var_dump();
require_once(sfConfig::get('sf_root_dir').'/vendor/phpexcel/PHPExcel.php');
//$php\
$values = $this->getValues();
$id = uniqid();
$file = sfConfig::get('sf_root_dir').'/data/upload/'.$id.'.xlsx';
move_uploaded_file($values['file']->getTempName(), $file);
$objPHPExcel = PHPExcel_IOFactory::load($file);
$lastRowNumber = (int)$objPHPExcel->getActiveSheet()->getHighestRow();
@remoharsono
remoharsono / node-grunt-sass.md
Created March 11, 2017 06:08 — forked from anotheruiguy/node-grunt-sass.md
Set up Node.js, Grunt and Node-Sass from scratch

Run the following steps inside a clean directory

Not sure if you are in the same boat as I, but I could not find any good resource out there that pulled this all together. So here is a step-by-step tutorial for creating a Node.js app from scratch, adding in Grunt and then Node-Sass. Yeah, try and find good docs on Node-Sass alone :(

Hope this is of help!

Create your Node.js project

  • npm init - create a clean node project
  • NOTE: be sure to add "private": true, to the package.json so that your project is not globally distributed as a npm app
@remoharsono
remoharsono / background.js
Created March 22, 2017 17:22 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@remoharsono
remoharsono / instagram_followers.py
Created May 2, 2017 04:12 — forked from tomkdickinson/instagram_followers.py
Followers Extraction Instagram
import json
import requests
import logging as log
log.basicConfig(level=log.DEBUG)
class FollowerExtractor():
"""
Extracts followers for a given profile
"""