Skip to content

Instantly share code, notes, and snippets.

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

Pomba Magar pombadev

🏠
Working from home
  • Kathmandu, Nepal
  • 08:37 (UTC +05:45)
View GitHub Profile
@pombadev
pombadev / ListCookies.js
Created March 10, 2017 06:42
List out cookies
function ListCookies() {
var o = {};
var c = document.cookie.split(' ')
for (var i=0; i<c.length; i++) {
o[c[i].split('=')[0]] = c[i].split('=')[1];
}
return o
}
console.log(ListCookies())
@pombadev
pombadev / Solutions.md
Created October 12, 2016 18:03
Solutions to CodeWars' "Kata".
@pombadev
pombadev / revrot.js
Last active October 12, 2016 18:09
Reverse or rotate given string.
function revrot(str, sz) {
/**
* If string (str), size (sz) or size is greater than string's
* length, return empty string.
*/
if (sz === 0 || str.length === 0 || sz > str.length) {
return ''
}
@pombadev
pombadev / validate.js
Last active October 12, 2016 04:51
Implementation of The Luhn Algorithm
/*
Implementation of The Luhn Algorithm (https://en.wikipedia.org/wiki/Luhn_algorithm)
*/
function validate(n) {
/**
* Check if the given number is of valid type
*/
if (!n || typeof n !== 'number') {
@pombadev
pombadev / tiny_hacks.md
Last active February 14, 2017 15:58
Tiny everyday hacks i found useful.

Better Git Blame ??

Credits: @andrewray
URL: http://blog.andrewray.me/

git log -p -M --follow --stat -- /path/to/file/name

Better Git Log

@pombadev
pombadev / coffeescript_to_javascript.js
Last active August 5, 2016 04:20
CoffeScript official examples in ES6
// CoffeeScript
square = (x) -> x * x
cube = (x) -> square(x) * x
fill = (container, liquid = "coffee") ->
"Filling the #{container} with #{liquid}..."
// ES6
let square = (x) => x*x
let cube = (x) => square(x)*x
let fill = (container, liquid = null) => `Filling the ${container} with ${liquid}...`