Deploy a Express.js project on Heroku
Step by step from command line by Michael Hsu
$ express myfirstexpress && cd myfirstexpress
var iller = { | |
"Ankara": ["Altındağ", "Ayaş", "Bala", "Beypazarı", "Çamlıdere", "Çankaya", "Çubuk", "Etimesgut", "Haymana", "Kalecik", "Keçiören", "Kızılcahamam", "Mamak", "Nallıhan", "Polatlı", "Şereflikoçhisar", "Sincan", "Yenimahalle"], | |
"İstanbul": ["Adalar", "Bağcılar", "Bahçelievler", "Bakırköy", "Beşiktaş", "Beykoz", "Beyoğlu", "Büyükçekmece", "Çatalca", "Eminönü", "Esenler", "Eyüp", "Fatih", "Gaziosmanpaşa", "Güngören", "Kadıköy", "Kağıthane", "Kartal", "Küçükçekmece", "Maltepe", "Pendik", "Sarıyer", "Silivri", "Şile", "Şişli", "Sultanbeyli", "Tuzla", "Ümraniye", "Üsküdar", "Zeytinburnu"], | |
"İzmir": ["Aliağa", "Balçova", "Bayındır", "Bergama", "Beydağ", "Bornova", "Buca", "Çeşme", "Dikili", "Foça", "Güzelbahçe", "Karaburun", "Karşıyaka", "Kemalpaşa", "Kınık", "Kiraz", "Konak", "Menderes", "Menemen", "Narlıdere", "Ödemiş", "Seferihisar", "Selçuk", "Tire", "Torbalı", "Urla"], | |
"Adana": ["Aladağ", "Ceyhan", "Feke", "Karaisalı", "Kozan", "Pozantı", "Saimbeyli", "Seyhan", "Yumurtalı", "Yüreğir" |
<?php | |
/** | |
* Permutations | |
* | |
* Returns an array of strings containing all the | |
* ($alphabet ^ $output_length) permutations | |
* | |
* @alphabet (string|array) set of at least two elements to choose from | |
* @output_length (int) the number of elements in each output string | |
* |
// Simulates try/catch statements wrapping async functions in (nested) object | |
// Returns copy of original object with basic promise-rejection handling for async functions using .catch | |
// Saves the time of writing try/catch statements in every single async function | |
const trycatch = obj => Object.keys(obj) | |
.reduce((acc, curr) => ({ ...acc, [curr]: obj[curr] instanceof Function | |
? (...args) => obj[curr](...args).catch(::console.error) | |
: trycatch(obj[curr]) }), {}) | |
<?php | |
/** | |
* Exception handling class. | |
*/ | |
class EnvatoException extends Exception { | |
} | |
/** | |
* $.unserialize | |
* | |
* Takes a string in format "param1=value1¶m2=value2" and returns an object { param1: 'value1', param2: 'value2' }. If the "param1" ends with "[]" the param is treated as an array. | |
* | |
* Example: | |
* | |
* Input: param1=value1¶m2=value2 | |
* Return: { param1 : value1, param2: value2 } | |
* |
// Set sizes without units | |
$basefont: 20; | |
$total-width-px: 1169; | |
$column-width-px: 72; | |
// Concatenation of units by addition results in conversion to string. This is bad | |
$basefont-px: $basefont+'px'; // = "20px" | |
// Conversion to pixels using multiplication | |
$basefont-px: $basefont*1px; // = 20px; |
<?php | |
/* | |
* Foce File Download | |
* Usage: http://example.com/download.php?file=./uploads/image.jpg | |
* | |
* There are a couple of *ninja* exit() as security guarantee, adapt as necessary | |
* | |
*/ | |
// grab the requested file's name |
# Get SHA256 of a text | |
# Usage: sha256 password | |
# output: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 | |
function sha256() { | |
echo -n $1 | shasum -a 256 | |
# Source: http://albertech.blogspot.fr/2015/02/generate-sha-256-hash-from-command-line.html | |
} |
Step by step from command line by Michael Hsu
$ express myfirstexpress && cd myfirstexpress
$(window).on("scroll", function() { | |
var scrollHeight = $(document).height(); | |
var scrollPosition = $(window).height() + $(window).scrollTop(); | |
if ((scrollHeight - scrollPosition) / scrollHeight === 0) { | |
// when scroll to bottom of the page | |
} | |
}); |