Skip to content

Instantly share code, notes, and snippets.

Avatar

ismnoiet

  • Planet Earth
View GitHub Profile
@ismnoiet
ismnoiet / refresh-spotlight-index.sh
Last active Jul 26, 2017
Refresh spotlight index to list the newly installed applications
View refresh-spotlight-index.sh
# 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 / generate-gpx.js
Created Jul 1, 2017
genereate gpx file to simulate location one iPhone device using xcode
View generate-gpx.js
// 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 Feb 12, 2017 — forked from elijahmanor/backbone-sync-override.js
Overriding Backbone.sync to POST instead of PUT/DELETE/PATCH
View backbone-sync-override.js
// 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 / 00.howto_install_phantomjs.md
Created Aug 11, 2016 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu
View 00.howto_install_phantomjs.md

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
View simple-javascript-event-system.js
function Emitter(){
this.events = {};
}
Emitter.prototype.emit = function(eventType,data){
this.events[eventType].map(function(callback){
callback.call(null,data);
});
}
View cloneObj.js
// 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
Set up Sublime text 3 to ignore "bower_components" & "node_modules" folders while searching for words.
View sublime.sublime-project
{
"folders":
[
{
"path": ".",
"follow_symlinks": true,
"folder_exclude_patterns": ["bower_components", "node_modules"]
}
]
}
@ismnoiet
ismnoiet / index.js
Created Apr 7, 2016
requirebin sketch
View index.js
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>');
View eventEmitter.js
//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 Mar 25, 2016
Convert date to french format in PHP without using locals
View date_to_french_format.php
<?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',