Skip to content

Instantly share code, notes, and snippets.

View zemuldo's full-sized avatar
🇰🇪
Geeks don't sleep

Danstan Onyango zemuldo

🇰🇪
Geeks don't sleep
View GitHub Profile
@zemuldo
zemuldo / semantic-commit-messages.md
Created February 14, 2020 09:25 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

import React from "react";
import WithName from "./WithName";
function HelloName({ name }) {
return <div>Hello {name}</div>;
}
export default WithName(HelloName);
@zemuldo
zemuldo / async_js_handle_asyncawait_errors.js
Created June 22, 2019 22:50
Handle errors in async await
async function run_handle_errors() {
try {
await i_am_first_but_i_take_10_sec()
await i_am_second_but_i_take_8_sec()
await i_am_third_but_i_take_6_sec()
await i_am_fourth_but_i_take_4_sec()
await i_am_last_but_i_take_1_sec()
console.log("Done")
} catch (error) {
console.log(error)
@zemuldo
zemuldo / async_js_asyc_await.js
Created June 22, 2019 21:53
Async await on promises
function i_am_last_but_i_take_1_sec() {
return new Promise((resolve, reject)=>{
setTimeout(() => {
console.log('i was no: 5 and i take 1 second')
resolve('done')
}, 1000);
})
}
function i_am_fourth_but_i_take_4_sec() {
@zemuldo
zemuldo / async_js_catch_in_promise.js
Last active June 22, 2019 22:08
Catch errors in a promise chain
function run (){
i_am_first_but_i_take_10_sec()
.then(() => {
return i_am_second_but_i_take_8_sec()
})
.then(() => {
return i_am_third_but_i_take_6_sec()
})
.then(() => {
@zemuldo
zemuldo / promisified_js_async_code.js
Created June 22, 2019 21:29
JS Async code with promises
function i_am_last_but_i_take_1_sec() {
return new Promise((resolve, reject)=>{
setTimeout(() => {
console.log('i was no: 5 and i take 1 second')
resolve('done')
}, 1000);
})
}
function i_am_fourth_but_i_take_4_sec() {
@zemuldo
zemuldo / callback_hell_js.js
Created June 22, 2019 21:14
ugly javascript callback hell
function run (){
i_am_first_but_i_take_10_sec(()=>{
let error_0
if(error_0) throw Error(error_0)
else {
i_am_second_but_i_take_8_sec(()=>{
let error_1
if(error_1) throw Error(error_1)
else{
i_am_second_but_i_take_8_sec(()=>{
@zemuldo
zemuldo / callbacks_async_js_code.js
Last active June 22, 2019 20:56
Async JS code with callback hell, needs improving.
function i_am_last_but_i_take_1_sec(callback) {
return setTimeout(() => {
console.log('i was no: 5 and i take 1 second')
callback()
}, 1000);
}
function i_am_fourth_but_i_take_4_sec(callback) {
return setTimeout(() => {
console.log('i was no: 4 and i take 4 seconds')
@zemuldo
zemuldo / problem_async_js_code.js
Last active June 22, 2019 20:54
This is an async code that need to be written to get the desired result.
function i_am_last_but_i_take_1_sec() {
return setTimeout(() => {
console.log('i was no: 5 and i take 1 second')
}, 1000);
}
function i_am_fourth_but_i_take_4_sec() {
return setTimeout(() => {
console.log('i was no: 4 and i take 4 seconds')
}, 4000);
# Ensure to execute chmod 777 path/to/this/file
# Configure your env variables here
export PG_USER=username
export PG_PASSWORD=password
export PG_HOST=prod_db_host
export DATABASE=prod_db
# Create database, Run migrations Compile app and Start Server
MIX_ENV=prod mix compile.protocols