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
@Lazhari
Lazhari / fix-docker-daemon-connection.md
Created October 16, 2024 23:06
Fix Cannot connect to the Docker daemon at unix:///var/run/docker.sock.

To fix the "cannot connect to the Docker daemon at unix:///var/run/docker.sock" error on macOS, try exporting the following:

export DOCKER_HOST=unix://$HOME/.docker/run/docker.sock  

Alternatively, you can use Docker over TCP. Here's how to configure Docker Desktop to expose the Docker daemon via TCP instead of a Unix socket:

  1. Open Docker Desktop.
  2. Navigate to Settings > General.
@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);