Skip to content

Instantly share code, notes, and snippets.

View me-shaon's full-sized avatar
💭
Learning...

Ahmed shamim me-shaon

💭
Learning...
View GitHub Profile
@me-shaon
me-shaon / sample_c.c
Last active November 16, 2017 15:18
Sample Block Scope example for Medium article
void testFunction() { //Scope 1: Starts here. This scope is created by the Function block
int a = 1;
if(true) { //Scope 2: Starts here. This scope created by the 'if' block
int b = 2;
//a is available here, because it is inside of it's scope
printf("%d %d", a, b);
}//Scope 2: Ends here
@me-shaon
me-shaon / sample_js.js
Created November 13, 2017 13:28
Sample Function Scope example for Medium Article
function testFunction() { //Scope 1: Starts here. This scope is created by the Function block
var a = 1;
if(true) { //This block is not creating any new Scope
var b = 2;
console.log(a, b); //'a', 'b' both is accessible here
}
console.log(b); //Though 'b' defined inside the 'if' block, it's still accessible here
@me-shaon
me-shaon / js_hoisting.js
Last active November 14, 2017 14:59
Javascript hoisting example for Medium article
function hoist() {
a = 10;
console.log(a); //this will print '10'
var a;
}
hoist();
@me-shaon
me-shaon / js_hoisting_caveat.js
Created November 14, 2017 15:00
Javascript Hoisting caveat example for medium article
function hoist() {
console.log(a); //this will show 'undefined'
var a = 10;
}
hoist();

Keybase proof

I hereby claim:

  • I am me-shaon on github.
  • I am ahmed_shamim (https://keybase.io/ahmed_shamim) on keybase.
  • I have a public key whose fingerprint is E4BA 494C 935A D262 CED5 8F59 5453 B580 DC74 C2C1

To claim this, I am signing this object:

// রিডাক্স লাইব্রেরীটা থেকে আমরা শুধুমাত্র createSotre মেথডটা import করতেছি
import { createStore } from 'redux'
// এটাই হচ্ছে আমাদের Reducer ফাংশন যেটা আমরা Redux কে দিবো।
// এখানে আমরা বলে দিচ্ছি একটা state আর action দিলে পরবর্তীতে state টা চেঞ্জ
// হয়ে কি হবে। এই ফাংশনটা একটা pure function. কেন? কারণ এটাতে যেই
// প্যারামিটার গুলো দেয়া হয়, মূলত state টা, সে সরাসরি সেগুলোতে চেঞ্জ করে না,
// বরং নতুন একটা পরিবর্তিত ডাটা রিটার্ন করে। এটার কারণেই আসলে লগিং এর কাজটা
// ভালোভাবে করা যায়। যেহেতু প্রতিবার নতুন একটা state ডাটা রিটার্ন হয়, logger
// টুলস সেটাকে সেইভ করে রেখে দিতে পারে। নতুবা যদি মূল state এ চেইঞ্জ হতো
// তাহলে লগারকে আগের state এর রেফারেন্স রাখতে হতো আর লগ দেখানোর সময়
export default function createStore(reducer) {
// আমাদের currentState রাখার জন্য একটা ভ্যারিয়েবল লাগবে
let currentState = null;
// createStore এ যেই reducer টা পাঠানো হয়েছে সেটার রেফারেন্স
// রাখার জন্য একটা ভ্যারিয়েবল লাগবে
let mainReducer = reducer;
// subscribe মেথডে যেই ফাংশনটা পাঠানো হবে সেটার রেফারেন্স
// রাখার জন্য একটা ভ্যারিয়েবল লাগবে
let mainListener = null;
@me-shaon
me-shaon / pipe.js
Last active June 6, 2018 09:01
A simple PIPE method implementation using ES6
const addOne = x => (x+1);
const addTwo = x => (x+2);
const addThree = x => (x+3);
const pipe = (...arr) => x => arr.reduce((res, curr) => curr(res), x);
console.log(pipe(addOne, addTwo, addThree)(2));
@me-shaon
me-shaon / oh-my-zsh-setup.md
Last active January 12, 2020 10:33
oh-my-zsh setup and tweaking tips
<?php
// Problem 1
function reverse($x) {
$x = intval($x);
if ($x < 0) {
return false;
}
$reversedInt = 0;