https://gist.github.com/kevin-smets/8568070
Instructions to get started with Oh-my-Zsh
- Zsh should be installed (v4.3.9 or more recent). If not pre-installed (zsh --version to confirm), check the following instruction here: Installing ZSH
module.exports = { | |
//param A : array of integers | |
//param B : array of integers | |
//param C : integer | |
//return an integer | |
solve : function(A, B, C){ | |
let n = A.length; | |
let maxValue = Array.from({length: C + 1}).fill(0); | |
for (let i=1; i<=n; i++) { |
module.exports = { | |
//param A : string | |
//param B : string | |
//return an integer | |
solve : function(A, B){ | |
let rows = A.length, cols = B.length; | |
let lcs = Array.from({ length: rows + 1 }, () => Array.from({ length: cols + 1 }).fill(0)); | |
for (let i=1;i<=rows;i++) { | |
for (let j=1;j<=cols;j++) { |
#! /usr/bin/env php | |
<?php | |
// Guessing game CLI app | |
$options = getopt('h::', ["min::", "max::"]); | |
if (isset($options['h'])) { | |
printf("This is a guessing game application"); | |
} else { | |
$min = (int) ($options['min'] ?? 1); |
<?php | |
// Problem 1 | |
function reverse($x) { | |
$x = intval($x); | |
if ($x < 0) { | |
return false; | |
} | |
$reversedInt = 0; |
<?php | |
use Illuminate\Database\Migrations\Migration; | |
class CreateTrigger extends Migration | |
{ | |
public function up() | |
{ | |
DB::unprepared(' | |
CREATE TRIGGER tr_after_main_insert AFTER INSERT ON `main` FOR EACH ROW |
const fs = require('fs'); | |
const path = require('path'); | |
const rootDir = process.argv[2] || __dirname; //Take the 'directory path' given in command line argument. Otherwise take the 'current directory' | |
//List of Regular Expressions need to apply | |
const changeRules = [{ | |
//Header Elements fixers | |
'find': /^(#+)([^ #].+)$/, | |
'replaceWith': "$1 $2" |
https://gist.github.com/kevin-smets/8568070
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)); |
export default function createStore(reducer) { | |
// আমাদের currentState রাখার জন্য একটা ভ্যারিয়েবল লাগবে | |
let currentState = null; | |
// createStore এ যেই reducer টা পাঠানো হয়েছে সেটার রেফারেন্স | |
// রাখার জন্য একটা ভ্যারিয়েবল লাগবে | |
let mainReducer = reducer; | |
// subscribe মেথডে যেই ফাংশনটা পাঠানো হবে সেটার রেফারেন্স | |
// রাখার জন্য একটা ভ্যারিয়েবল লাগবে | |
let mainListener = null; | |
// রিডাক্স লাইব্রেরীটা থেকে আমরা শুধুমাত্র createSotre মেথডটা import করতেছি | |
import { createStore } from 'redux' | |
// এটাই হচ্ছে আমাদের Reducer ফাংশন যেটা আমরা Redux কে দিবো। | |
// এখানে আমরা বলে দিচ্ছি একটা state আর action দিলে পরবর্তীতে state টা চেঞ্জ | |
// হয়ে কি হবে। এই ফাংশনটা একটা pure function. কেন? কারণ এটাতে যেই | |
// প্যারামিটার গুলো দেয়া হয়, মূলত state টা, সে সরাসরি সেগুলোতে চেঞ্জ করে না, | |
// বরং নতুন একটা পরিবর্তিত ডাটা রিটার্ন করে। এটার কারণেই আসলে লগিং এর কাজটা | |
// ভালোভাবে করা যায়। যেহেতু প্রতিবার নতুন একটা state ডাটা রিটার্ন হয়, logger | |
// টুলস সেটাকে সেইভ করে রেখে দিতে পারে। নতুবা যদি মূল state এ চেইঞ্জ হতো | |
// তাহলে লগারকে আগের state এর রেফারেন্স রাখতে হতো আর লগ দেখানোর সময় |