Skip to content

Instantly share code, notes, and snippets.

View morajabi's full-sized avatar

Mo morajabi

View GitHub Profile
@morajabi
morajabi / clone-object.js
Created June 22, 2017 13:27
Cloning objects in javascript with Object.assign({}, src)
console.group("Cloning objects");
const firstObject = {
name: 'Mohammad',
};
const clonedObject = Object.assign({}, firstObject);
@kitten
kitten / reactiveconf-sc-cfp.md
Last active November 17, 2020 15:06
ReactiveConf 2017 Lightning Talk CFP: With styled-components into the future

styled-components Logo

With styled-components into the future

Preprocessing is dead, long live preprocessing!


This is a CFP for ReactiveConf 2017's open call for Lightning talks. If you'd like to see this talk become a reality, please ⭐ star this gist. #ReactiveConf

'use strict';
// Dependencies
const gcloud = require('google-cloud', {
projectId: 'sara-bigquery',
keyfileName: 'keyfile.json'
});
const vision = gcloud.vision();
const fs = require('fs');
const async = require('async');
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@ccnokes
ccnokes / preload-example.js
Created February 1, 2017 03:03
Electron preload script
// in preload scripts, we have access to node.js and electron APIs
// the remote web app will not have access, so this is safe
const { ipcRenderer: ipc, remote } = require('electron');
init();
function init() {
// Expose a bridging API to by setting an global on `window`.
// We'll add methods to it here first, and when the remote web app loads,
// it'll add some additional methods as well.
@devopsmariocom
devopsmariocom / webpack.config.js
Created September 26, 2016 12:57
Minimal Webpack 2 config
const { resolve } = require('path');
const webpack = require('webpack');
// plugins
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = (env) => {
return {
@frankchang0125
frankchang0125 / tableView_setContentOffset.swift
Created July 28, 2016 17:10
Scroll to the offset after reloading tableView
/* We call layoutIfNeeded() immediately after reloadData()
* to force table view to perform layout immediately
* This is required to let the setContentOffset() in dispatch block to be executed
* after table view has completed performing its layout to scroll to the correct offset
* For further explanations, please see: http://goo.gl/BpzlA5 and http://goo.gl/6CH64b
*/
self.tableView.reloadData()
self.tableView.layoutIfNeeded()
dispatch_async(dispatch_get_main_queue(), {
@knowbody
knowbody / RNfontWeights.js
Created July 14, 2016 13:42
React Native Font Weight Cheatsheet iOS
{ fontWeight: '100' }, // Thin
{ fontWeight: '200' }, // Ultra Light
{ fontWeight: '300' }, // Light
{ fontWeight: '400' }, // Regular
{ fontWeight: '500' }, // Medium
{ fontWeight: '600' }, // Semibold
{ fontWeight: '700' }, // Bold
{ fontWeight: '800' }, // Heavy
{ fontWeight: '900' }, // Black
@samyk
samyk / chrome_tabs.osa
Created June 14, 2016 18:36
applescript to show all url+titles of Chrome tabs along with front window+tab url+title
# shows all url+titles of Chrome along with front window+tab url+title
set titleString to ""
tell application "Google Chrome"
set window_list to every window # get the windows
repeat with the_window in window_list # for every window
set tab_list to every tab in the_window # get the tabs
repeat with the_tab in tab_list # for every tab
@williampsena
williampsena / js-call-apply.es6.js
Created June 5, 2016 23:53
Javascript Call and Apply - ES6
function notifyClient(message) {
alert(message);
}
function sendMail(customer, total) {
notifyClient.call(this, `TODO: Send mail, (${String(customer.id)}, ${String(total)})`);
}
function getDeals() {
var product = arguments[0];