Skip to content

Instantly share code, notes, and snippets.

View abdulhannanali's full-sized avatar
💭
WUNDERWALL!!!!

Hannan Ali abdulhannanali

💭
WUNDERWALL!!!!
View GitHub Profile
@abdulhannanali
abdulhannanali / purepromise.js
Last active November 29, 2016 07:33
Question: Is the function that returns a promise can be considered pure? The returned function might be performing I/O
import axios from 'axios'
/**
* getIdentity
* returns a Promise provided the name of the user
*/
function getIdentity (name) {
return axios.get('https://getyourinfo.pk/' + name)
}
@abdulhannanali
abdulhannanali / brainworkers.js
Created May 16, 2016 17:43
Too many things in your mind at same time, use Clustering in Node.js to solve this issue
/*
* brainworkers.js
* Having non-blocking IO code is good but you still are single threaded
* and are not built for this fast internet world of 21st Century
* this code is for you.
*/
const mindClusters = require("cluster");
const yourMind = require("brain");
const numBpus = yourMind.bpus().length;
@abdulhannanali
abdulhannanali / gist:e927f84afa52bc39adcf
Created March 8, 2016 16:57 — forked from josteink/on_stateful_code.txt
On why stateful code is bad
STUDENT: Sir, can I ask a question?
TEACHER: Yes!
STUDENT: How do you put an elephant inside a fridge?
TEACHER: I don't know.
STUDENT: It's easy, you just open the fridge and put it in. I have another question!
TEACHER: Ok, ask.
STUDENT: How to put a donkey inside the fridge?
TEACHER: It's easy, you just open the fridge and put it in.
STUDENT: No sir, You just open the fridge take out the elephant and put it in.
TEACHER: Ooh...ok!!
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/pouchdb/latest/pouchdb.min.js"></script>
<script src="https://code.jquery.com/jquery-compat-3.0.0-alpha1.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@abdulhannanali
abdulhannanali / companion.html
Last active February 6, 2016 21:07
Horrible JavaScript code
<tr class="student">
<td class="name-col">Slappy the Frog</td>
<td class="attend-col"><input type="checkbox"></td>
<td class="attend-col"><input type="checkbox"></td>
<td class="attend-col"><input type="checkbox"></td>
<td class="attend-col"><input type="checkbox"></td>
<td class="attend-col"><input type="checkbox"></td>
<td class="attend-col"><input type="checkbox"></td>
<td class="attend-col"><input type="checkbox"></td>
<td class="attend-col"><input type="checkbox"></td>
@abdulhannanali
abdulhannanali / Sublime Text License Key.md
Created January 9, 2016 16:37
Sublime Text 2 License Key, Sublime Text 3 License Key, Sublime Text Full Version.
@abdulhannanali
abdulhannanali / gulpfile.js
Created January 7, 2016 22:56
Gulp, Browserify, Babelify and React gulpfile. Don't use Watchify instead use gulp.watch. A personal tip. Watchify gives me problems
var gulp = require('gulp')
var browserify = require('browserify')
var watchify = require('watchify')
var babelify = require('babelify')
var plumber = require('gulp-plumber')
var buffer = require("vinyl-buffer")
var source = require("vinyl-source-stream")
var sourcemaps = require("gulp-sourcemaps")
var uglify = require("gulp-uglify")
@abdulhannanali
abdulhannanali / ossiuse.md
Created January 1, 2016 18:59
Open Source applications, softwares, frameworks and operating systems, I use, have used, or I am using. 😄 Hope you get something out of it :)

Some of the open source applications I use:

  • KDE Softwares
  • Kubuntu 15.10
  • Xubuntu 14.04
  • Mozilla Firefox
  • Chromium
  • Node.js
  • Express JS (a web application framework)
  • KoaJS (a web application framework)

Configuring babel 6 for node with me

A little introduction to babel

Hi! If you are like me, you are tired of writing the same old ES5 JS Code in your node applications.

If yes, you can use the newer features of JavaScript ES6 and ES7 standards in your node applications today. ES6 and ES7 make the JavaScript development a cool breeze. But hey, not every ES6 feature is supported in our beloved Node.js.

This is where BabelJS comes to the rescue. BabelJS is a transpiler for JavaScript which transpiles your ES6 and ES7 code into ES5 and even ES3 code. In simple words it converts it into JavaScript that node.js can run and make you really happy.

Little Notice: If you just want ES6 features and don't want to babelify stuff. You can use --harmony flag before running your node application. In order to access more harmony flags for staging and experimental features run this command node --v8-options | grep harmony

LOKLAK Movie Tool

We'll retrieve the tweets using LOKLAK API and we'll use The OpenMovieDatabase in order to get the more information about the movie.