Skip to content

Instantly share code, notes, and snippets.

Avatar

Akinjide Bankole akinjide

View GitHub Profile
@akinjide
akinjide / anime.txt
Created May 14, 2017
Node JS streams
View anime.txt
Psycho-Pass
Deadman Wonderland
One Punch Man
God Eater
Ghost in the Shell
Sword Art Online
@akinjide
akinjide / anime.txt
Created May 14, 2017
Node js streams with transform
View anime.txt
Psycho-Pass
Deadman Wonderland
One Punch Man
God Eater
Ghost in the Shell
Sword Art Online
@akinjide
akinjide / scroll.directive.js
Created May 15, 2017
AngularJS ScrollTo directive
View scroll.directive.js
(function () {
'use strict';
angular
.module('app')
.directive('scrollOnClick', scrollOnClick);
scrollOnClick.$inject = [];
/* @ngInject */
@akinjide
akinjide / monthlyTemps.js
Created Jun 5, 2017
Book: Data Structures and Algorithms with JavaScript by Michael McMillan
View monthlyTemps.js
function MonthlyTemps() {
this.dataStore = [];
this.add = add;
this.average = average;
}
function add(week) {
this.dataStore.push(arguments[0]);
}
@akinjide
akinjide / get_http.js
Last active Jul 7, 2017
Native HTTP Request using Promise
View get_http.js
const get = (url) => {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
resolve(JSON.parse(xhr.responseText));
} else {
reject(xhr);
@akinjide
akinjide / seed.js
Created Aug 6, 2017
Generate seed for users information
View seed.js
const chance = require('chance').Chance();
const fs = require('fs');
let generateUsers = totalUsers => {
let users = [];
for (let i = 0; i < totalUsers; i++) {
const user = {
id: 'user-' + chance.guid(),
added_at: chance.date(),
@akinjide
akinjide / local_remote.txt
Created Sep 28, 2017
Rename a local and remote branch in git
View local_remote.txt
1. Rename your local branch.
If you are on the branch you want to rename:
$ git branch -m new-name
If you are on a different branch:
$ git branch -m old-name new-name
2. Delete the old-name remote branch and push the new-name local branch.
$ git push origin :old-name new-name
View gfudi.js
const i = 'gfudi';
const k = s => s.split('').map(c => String.fromCharCode(c.charCodeAt() - 1)).join('');
self[k(i)](urlWithYourPreciousData);
View callback.js
Array.prototype.click = function(fn, thisArg) {
const _self = thisArg || this;
for (let i = 0; i < _self.length; i++) {
fn.apply(thisArg, [_self[i], i, thisArg]);
// Mutation.
thisArg.values[i] = i;
}
};
@akinjide
akinjide / staircase.js
Created Mar 2, 2018
Staircase problem implemented in JavaScript
View staircase.js
// Time Complexity O(n2)
const staircase = (n, c) => {
let y = [];
let s;
for (let i = 1; i <= n; i++) y[i - 1] = i;
for (let j = 1; j <= n; j++) {
s = y.length - j;
console.log(' '.repeat(s), c.repeat(j));
You can’t perform that action at this time.