Skip to content

Instantly share code, notes, and snippets.

View alihesari's full-sized avatar
🏠
Working from home

Ali Hesari alihesari

🏠
Working from home
View GitHub Profile
@marchawkins
marchawkins / geocode-user-input-address.html
Created March 7, 2014 06:43
Using the google maps geocoding api to find an address input by the user. The address is then plotted on a google map. The location is determined by the value of the textfield. Initially, the map will display a generic location (nyc). Most major browsers supported, including IE9, Chrome, Safari, Opera and Firefox. For this test, enter an address…
<div class="row">
<div class="col-md-2 col-sm-2 col-xs-2">
<p><button class="btn btn-primary btn-sm" id="map-address-btn"><span>Find It</span></button></p>
</div><!-- .col -->
<div class="col-md-10 col-sm-10 col-xs-10">
<div class="panel panel-default">
<div class="panel-heading">Location Response</div>
<div class="panel-body">
<p>Enter Address: <input id="location-address" type="text" class="form-control" placeholder="Street, City, State"/</p>
<p>Map:</p><div id="map-canvas" style="height: 400px;"></div>
@krolow
krolow / countries.sql
Created February 3, 2012 16:38
Countries ISO SQL for MySQL / CakePHP
CREATE TABLE `countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`printable_name` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=240 DEFAULT CHARSET=utf8;
@ryanoboril
ryanoboril / gist:278197b04cb8c838d72b
Last active June 13, 2019 18:09
Setup PhantomJS on CentOS 6.5
# Use one of the download links here: http://phantomjs.org/download.html
# In this case, it's the 32-bit version.
sudo yum install freetype fontconfig
cd ~
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-i686.tar.bz2
bunzip2 phantomjs*.tar.bz2
tar xvf phantomjs*.tar
sudo cp phantomjs*/bin/phantomjs /usr/bin/phantomjs
phantomjs -v
@vuongtran
vuongtran / RESTful API sample structure using Node.js, Express.js included tesing
Last active December 4, 2019 15:44
RESTful API sample structure using Node.js, Express.js included tesing
Let's lool at the following example structure for RESTful API using Node.js, Express.js included tesing
app/
|---models/
|---controller/
|---helpers/
|---middlewares/
|---tests/
|---models/
|---controllers/
@ahmadina
ahmadina / pm2.json
Last active December 15, 2019 09:26
using PM2 for run ES6 (babel) application
{
"apps": [{
"name": "Application",
"exec_interpreter": "./node_modules/babel-cli/bin/babel-node.js",
"script": "./bin/www",
"args": [],
"watch": ["public", "package.json", "pm2.development.json"],
"ignore_watch": ["public"],
"watch_options": {
"persistent": true,
# for development
pm2 start npm --name "next" -- run dev
# for production
npm run build
pm2 start npm --name "next" -- start
"scripts": {
"start": "node ./node_modules/.bin/pm2 start app.js -i max --attach"
@inadarei
inadarei / base64.js
Created January 6, 2013 04:11
base64 encode/decode in Node.js
var url = "http://cdn1.giltcdn.com/images/share/uploads/0000/0001/7250/172502872/420x560.jpg";
var encoded = new Buffer(url).toString('base64');
var decoded = new Buffer(encoded, 'base64').toString('ascii')
console.log(encoded);
console.log(decoded);
@sean-roberts
sean-roberts / ImmutableVsMutable.js
Last active May 26, 2020 19:09
Immutable vs Mutable in JS - the immutable (unable to change or mutate) values are primitive values - numbers, strings, booleans, null, undefined). While the mutable are all other objects. They are generally referred to as reference types because the object values are references to the location, in memory, that the value resides.
// start with at string
var s = "my string";
//change its value (remember this changing of value is by value not reference)
s.toUpperCase();
// assign it to t
var t = s;
@msmfsd
msmfsd / Iframe.js
Last active July 15, 2020 11:48
React iframe component
/*
INIT: ensure Babel/Eslint/Flow is configured for ES Class Fields & Static Properties
JSX USAGE: <Iframe src='http://web.site' onLoad={myOnloadFunction}/>
*/
import React, { Component, PropTypes } from 'react'
import ReactDOM from 'react-dom'
class Iframe extends Component {
static propTypes: Object = {
@cagataycali
cagataycali / babelInterpreter.sh
Created July 8, 2016 16:28
Start pm2 process with babel-node interpreter
pm2 start app.js --interpreter ./node_modules/.bin/babel-node