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 / 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 / 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 / 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 / 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

update object

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

var newState = {
@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)
@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 / lock_down_public_s3_buckets.md
Created April 25, 2018 03:01 — forked from apolloclark/lock_down_public_s3_buckets.md
Bash one-liner to find public facing AWS S3 buckets, and make them private

Command

aws s3api list-buckets --query 'Buckets[*].[Name]' --output text | xargs -I {} bash -c 'if [[ $(aws s3api get-bucket-acl --bucket {} --query '"'"'Grants[?Grantee.URI==`http://acs.amazonaws.com/groups/global/AllUsers` && Permission==`READ`]'"'"' --output text) ]]; then aws s3api put-bucket-acl --acl "private" --bucket {} ; fi'



1. List all of the user's buckets, and output the name, as text.

@obonyojimmy
obonyojimmy / .eslintrc.js
Created April 11, 2018 20:43 — forked from jasoet/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@obonyojimmy
obonyojimmy / validate_json.sh
Created April 9, 2018 02:19 — forked from kamiller/validate_json.sh
validate json with python via bash script
echo '{"foo":"bar"}' | python -m json.tool >> /dev/null && exit 0 || echo "NOT valid JSON"; exit 1