Skip to content

Instantly share code, notes, and snippets.

View a-eid's full-sized avatar
🎯
Focusing

Ahmed Eid a-eid

🎯
Focusing
View GitHub Profile
import UIKit
extension UIView {
// top bottom left and right
func anchorEdges(top: NSLayoutYAxisAnchor?, tConst: CGFloat = 0,
left: NSLayoutXAxisAnchor?, lConst: CGFloat = 0 ,
right: NSLayoutXAxisAnchor?, rConst: CGFloat = 0 ,
bottom: NSLayoutYAxisAnchor?, bConst: CGFloat = 0
) -> (NSLayoutConstraint?, NSLayoutConstraint?, NSLayoutConstraint?, NSLayoutConstraint?) {
extension UIColor {
convenience init(hex: Int, alpha: CGFloat = 1.0) {
let r = CGFloat((hex >> 16) & 0xff) / 255
let g = CGFloat((hex >> 08) & 0xff) / 255
let b = CGFloat((hex >> 00) & 0xff) / 255
self.init(red: r, green: g, blue: b, alpha: alpha)
} }
// usage
/*
@arr: array of 0s and 1s
@returns: an array of indexes
*/
const findIndexes = arr => {
return arr.reduce((m, e, i) => {
e && m.push(i)
return m
}, [])
}
module.exports = {
parser: "babel-eslint",
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
jest: true,
},
## Install MongoDB on macOS Sierra
This procedure explains how to install [MongoDB](https://www.mongodb.org) using [Homebrew](http://brew.sh) on macOS Sierra 10.12.
Official MongoDB install documentation: [here](https://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/)
### Install Homebrew
* Installing Homebrew is effortless, open Terminal and enter :
`$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
const fetch = require("isomorphic-fetch")
const endpoint = `https://talaikis.com/api/quotes/random/`
function* createGetQuote(){
const resp = yield fetch(endpoint)
const quote = yield resp.json()
return `${quote.quote}--${quote.author}`
}
const getQuote = createGetQuote()
@a-eid
a-eid / n
Created September 22, 2018 19:56
export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin"
@a-eid
a-eid / ...js
Created October 27, 2018 17:27
import EventEmitter from "events"
import fs from "fs"
class WithTime extends EventEmitter {
execute(asyncFunc, ...args) {
console.time("execute")
asyncFund(...args, (err, data) => {
if (err) return this.emit("error", err)
this.emit("data", data)
console.timeEnd("execute")
this.emit("end")
# cat << EOF > /dev/null
# https://github.com/gpakosz/.tmux
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
# without any warranty.
# Copyright 2012— Gregory Pakosz (@gpakosz).
# /!\ do not edit this file
# instead, override settings in ~/.tmux.conf.local, see README.md
# -- general -------------------------------------------------------------------
# https://github.com/gpakosz/.tmux
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
# without any warranty.
# Copyright 2012— Gregory Pakosz (@gpakosz).
# -- navigation ----------------------------------------------------------------
# if you're running tmux within iTerm2
# - and tmux is 1.9 or 1.9a
# - and iTerm2 is configured to let option key act as +Esc