Skip to content

Instantly share code, notes, and snippets.

View obonyojimmy's full-sized avatar
💻
probably coding

jimmycliff obonyo obonyojimmy

💻
probably coding
View GitHub Profile
@obonyojimmy
obonyojimmy / gist:c2d7209ca75479c78bb78cbef7379072
Last active May 4, 2018 23:24 — forked from yesvods/gist:51af798dd1e7058625f4
Merge Arrays in one with ES6 Array spread
You can use this :
let arr1 = [1, 2, 3];
let arr2 = [4, 5, 6];
let concatAndDeDuplicate = (...arrs) => [ ...new Set( [].concat(...arrs) ) ];
concatAndDeDuplicate(arr1, arr2, [7, 8, 9, 2, 4]);
// [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
And if you have multiple arrays of potentialy identical objects, you can use this :
@obonyojimmy
obonyojimmy / async-foreach.js
Created May 10, 2018 18:10 — forked from atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)

update object

var state = {
    id: 1,
    points: 100,
    name: "Goran"
};

var newState = {
@obonyojimmy
obonyojimmy / gist:411b1995bd1957da6d7a5d541fbe8308
Created May 16, 2018 21:29 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@obonyojimmy
obonyojimmy / docker-destroy-all.sh
Created May 17, 2018 00:19 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@obonyojimmy
obonyojimmy / protips.js
Created June 1, 2018 21:21 — forked from nolanlawson/protips.js
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@obonyojimmy
obonyojimmy / lock-switch-to-signup.html
Created June 14, 2018 01:31 — forked from sandrinodimattia/lock-switch-to-signup.html
Auth0 Lock example that shows how to switch to the Login page when a certain condition is met
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Auth0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
html, body { padding: 0; margin: 0; }
@obonyojimmy
obonyojimmy / cloudSettings
Created June 20, 2018 21:18 — forked from aurawindsurfing/cloudSettings
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-05-03T11:33:27.621Z","extensionVersion":"v2.9.2"}
@obonyojimmy
obonyojimmy / .md
Created July 5, 2018 23:26 — forked from SeriousM/.md
Logout all users from meteor application