Skip to content

Instantly share code, notes, and snippets.

View ismnoiet's full-sized avatar

ismnoiet

  • Planet Earth
View GitHub Profile
@ismnoiet
ismnoiet / generate-gpx.js
Created July 1, 2017 02:38
genereate gpx file to simulate location one iPhone device using xcode
// 1. find location latitude & longitude of desired location and name of location
// 2. call generate_gpx using previous data
// alternative, you can use http://gpx-poi.com to generate .gpx file
function generate_gpx(lat,lon,name,time='2017-07-01T02:24:02Z'){
return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gpx
xmlns="http://www.topografix.com/GPX/1/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@ismnoiet
ismnoiet / backbone-sync-override.js
Created February 12, 2017 13:17 — forked from elijahmanor/backbone-sync-override.js
Overriding Backbone.sync to POST instead of PUT/DELETE/PATCH
// The following could have been replaced by setting `Backbone.emulateHTTP = true;`
Backbone._sync = Backbone.sync;
Backbone.sync = function( method, model, options ) {
var beforeSend = options.beforeSend;
options = options || {};
if ( method === "update" || method === "delete" || method === "patch" ) {
options.beforeSend = function( xhr ) {
@ismnoiet
ismnoiet / refresh-spotlight-index.sh
Last active July 26, 2017 20:02
Refresh spotlight index to list the newly installed applications
# pboblem : some applications can't be found using spotlight search box.
# solution : reload the metadata plist
# source : http://apple.stackexchange.com/questions/62715/applications-dont-show-up-in-spotlight
# Turn off spotlight
sudo mdutil -a -i off
# Unload it :
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
@ismnoiet
ismnoiet / 00.howto_install_phantomjs.md
Created August 11, 2016 22:50 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
function Emitter(){
this.events = {};
}
Emitter.prototype.emit = function(eventType,data){
this.events[eventType].map(function(callback){
callback.call(null,data);
});
}
// A function for creating a new object that inherits from another
// method1:
// naked function to be used as a constructor
var Ctor = function(){};
function cloneObj(srcObj){
Ctor.prototype = srcObj;
var clone = new Ctor();
Ctor.prototype = null;
@ismnoiet
ismnoiet / sublime.sublime-project
Created May 4, 2016 09:05
Set up Sublime text 3 to ignore "bower_components" & "node_modules" folders while searching for words.
{
"folders":
[
{
"path": ".",
"follow_symlinks": true,
"folder_exclude_patterns": ["bower_components", "node_modules"]
}
]
}
@ismnoiet
ismnoiet / index.js
Created April 7, 2016 13:17
requirebin sketch
var markdown = require( "markdown" ).markdown;
var markdownStr = ['#Hello World','somethig else','#another title'].join("\n");
var htmlResult= markdown.toHTML(markdownStr);
var finalResult = htmlResult.replace(/<h1>/g,'<h3>');
finalResult.replace(/<\/h1>/g,'</h3>');
//first.js
var util = require('util'),
EventEmitter = require('events');
function First () {
EventEmitter.call(this)
}
util.inherits(First, EventEmitter);
@ismnoiet
ismnoiet / date_to_french_format.php
Last active March 25, 2016 10:13
Convert date to french format in PHP without using locals
<?php
function to_french_format($date){
$date = date("l d/m/Y h:i", strtotime($date));
$date_components = split(' ',$date);
$french_days = array(
'Saturday'=>'Samedi',
'Sundy'=>'Dimanche',
'Monday'=>'Lundi',
'Tuesday'=>'Mardi',