Skip to content

Instantly share code, notes, and snippets.

View one-aalam's full-sized avatar
🎯
Focusing

Aftab Alam one-aalam

🎯
Focusing
View GitHub Profile
function url_clean(url) {
return url.toLowerCase()//
.replace(/^\s+|\s+$/g, "")// trim leading and trailing spaces
.replace(/[_|\s]+/g, "-")// change all spaces and underscores to a hyphen
.replace(/[^a-zF0-9-\/]+/g, "")// remove non alpha, digit, '-', '/' chars
.replace(/[-]+/g, "-")// replace multiple hyphens with one
.replace(/^-+|-+$/g, ""); // trim leading and trailing hyphens
}
var getSupportedTransform = function() {
var prefixes = ['transform','WebkitTransform','MozTransform','OTransform','msTransform'];
for(var ix = 0; ix < prefixes.length; ix++) {
if(document.createElement('div').style[prefixes[ix]] !== undefined) {
return prefixes[ix];
}
}
return false;
}
/**
* requestAnimationFrame and cancel polyfill
* WHY USE THIS?
* http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
*/
(function () {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
@one-aalam
one-aalam / zip.php
Last active August 29, 2015 14:14 — forked from jonmaim/zip.php
<?php
/*
*
* This script will backup your web site by remotely archiving all files on the root FTP directory.
* It will work even if your web server is memory limited buy splitting zips in several arhive files it they are too many files.
* All zip files will be stored in a directory called temporary which must be writable.
*
* How to use it:
* - Place the script at the root of your FTP.
@one-aalam
one-aalam / introrx.md
Last active August 29, 2015 14:24 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@one-aalam
one-aalam / Makefile
Created October 9, 2015 03:55 — forked from toolmantim/Makefile
An example of using Make instead of Grunt for fast, simple and maintainable front-end asset compilation.
# A simple Makefile alternative to using Grunt for your static asset compilation
#
## Usage
#
# $ npm install
#
# And then you can run various commands:
#
# $ make # compile files that need compiling
# $ make clean all # remove target files and recompile from scratch
@one-aalam
one-aalam / nginx-osx-install.sh
Created December 8, 2015 12:44
Mac OS X nginx installation from source
# download PCRE and nginx source
sudo mkdir -p /usr/local/src
cd /usr/local/src
# copy PCRE to directory
# eg. cp /tmp/pcre-8.20.tar.gz /usr/local/src/
tar xzvf pcre-8.20.tar.gz
cd pcre-8.20
./configure --prefix=/usr/local
make && sudo make install && make clean
@one-aalam
one-aalam / 0_reuse_code.js
Created April 1, 2016 13:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@one-aalam
one-aalam / _baseline.scss
Created June 17, 2016 17:45 — forked from razwan/_baseline.scss
Aligning type to baseline the right way with SASS
$base-font-size: 16px;
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
@one-aalam
one-aalam / .babelrc
Created August 23, 2017 08:35 — forked from c9s/.babelrc
webpack + babel + typescript + es6 - total solutions!
{
"presets": ["es2015"],
"plugins": ["transform-runtime"]
}