Skip to content

Instantly share code, notes, and snippets.

View Lazhari's full-sized avatar
:octocat:
Working from home

Lazhari Lazhari

:octocat:
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am lazhari on github.
  • I am medlazhari (https://keybase.io/medlazhari) on keybase.
  • I have a public key ASBAlv6WFJqsYB-gZXM09J0vWaOa7QahDCXqGKz6kqF5Fgo

To claim this, I am signing this object:

@Lazhari
Lazhari / sub_arrays.rs
Created May 3, 2020 16:33
Print all sub arrays with 0 sum using rust
fn print_all_sub_arrays(arr: Vec<i128>) -> Vec<Vec<i128>> {
let mut sub_arrays:Vec<Vec<i128>> = Vec::new();
for i in 0..arr.len() {
let mut sum = 0;
for j in i..arr.len() {
sum += arr[j];
if sum == 0 {
sub_arrays.push(arr[i..=j].to_vec());
}
@Lazhari
Lazhari / update-email-git.sh
Created July 3, 2019 00:43
Update the user email on all commits
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="OLD_EMAIL"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="NEW_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
@Lazhari
Lazhari / command.sh
Created December 27, 2018 10:58
Rename your current branch on Git
git branch -m newname
@Lazhari
Lazhari / throttle.js
Created September 9, 2018 00:47
Duplex Stream with Node.js
const { PassThrough, Duplex } = require("stream");
const { createReadStream, createWriteStream } = require("fs");
const readStream = createReadStream("../../powder-day.mp4");
const writeStream = createWriteStream("./copy.mp4");
class Throttle extends Duplex {
constructor(ms) {
super();
this.delay = ms;
@Lazhari
Lazhari / concurrent-tasks.js
Created September 8, 2018 23:05
Logging concurrent tasks with Node.js
const logUpdate = require("log-update");
const toX = () => "X";
const delay = seconds =>
new Promise(resolves => {
setTimeout(resolves, seconds * 1000);
});
const tasks = [
delay(4),
delay(6),
@Lazhari
Lazhari / app.js
Created August 28, 2018 16:19 — forked from JaniKibichi/app.js
Sample code about uploading pictures to cloudinary using multer - NodeJs ExpressJS Framework
'use strict';
var express = require("express");
var multer = require('multer');
var app = express();
var options = require('./config/config')
var mongoose = require('mongoose');
/* photo manenos */
var cloudinary = require('cloudinary');
@Lazhari
Lazhari / settings.json
Created May 6, 2018 22:13
Visual Studio Code, Enable Emmet for create-react-app
{
"emmet.includeLanguages": {
"javascript": "javascriptreact"
}
}
@Lazhari
Lazhari / README.md
Created February 9, 2018 10:22
MongoDB migration from 3.4.x to 3.6.x on Macos
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
@Lazhari
Lazhari / redux-demo.js
Created December 2, 2017 10:41
Redux, Redux middleware, immutablejs, axios
import {createStore, combineReducers, applyMiddleware} from 'redux';
import {List, Map} from 'immutable';
import axios from 'axios';
// The user reducer
const usersReducer = (state= List(), action) => {
switch (action.type) {
case 'GET_USERS':
console.log('action', action);
return List(action.payload.data.data);