Skip to content

Instantly share code, notes, and snippets.

Lewis 6ewis

  • Toronto, Ontario
Block or report user

Report or block 6ewis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@6ewis
6ewis / babel-webpack.md
Created May 15, 2019 — forked from ncochard/babel-webpack.md
The correct way to compile ES6 using babel...
View babel-webpack.md

When you create a npm package, remember it might be used in a browser or a server, or even a command line utility… For each package you create, please pay attention at what it will be used for:

  1. Is it going to be used as a dependency to a nodejs application that is not bundled? (e.g. command line utilities)
  2. Is it going to be used as a dependency to a nodejs application that is bundled? (e.g. AWS Lambdas)
  3. Is it going to be used as a dependency to a browser application (always bundled)?.
  • In cases 2) and 3) you want to allow for tree shaking.
  • In cases 1) and 2) you want to benefit from the "ES6"/"ES next" features supported natively by nodejs.
  • In case 3) you also want to benefit from the native support of "ES6" from your browser.
View ramda-title-case.js
import R from 'ramda';
const capitalize =
R.converge(
R.concat(),
[
R.compose(
R.toUpper,
R.head
),
@6ewis
6ewis / aws
Created Nov 21, 2018
s3 lambda permission
View aws
{
"Action": [
"s3:*",
],
"Effect": "Allow",
"Resource": [
"${module.s3_lambda_els_bucket.bucket_arn}",
]
}
@6ewis
6ewis / example.txt
Last active Jan 13, 2018
using reduce for updating nested object vs destructuring
@6ewis
6ewis / Life cycle method
Created Oct 13, 2017
Describe the life-cycle method
View Life cycle method
/**
* ------------------ The Life-Cycle of a Composite Component ------------------
*
* - constructor: Initialization of state. The instance is now retained.
* - componentWillMount
* - render
* - [children's constructors]
* - [children's componentWillMount and render]
* - [children's componentDidMount]
* - componentDidMount
View sorting-sort.clj
(defn remove-one [item list]
(let [[n m] (split-with (partial not= item) list)] (vec (concat n (rest m)))))
(defn sorting-sort [unsorted]
(loop [inner-unsorted unsorted sorted []]
(let [min-val (apply min inner-unsorted)]
(if
(or
(= 1 (count inner-unsorted))
(empty? inner-unsorted))
@6ewis
6ewis / mock_monster.rb
Created Jun 17, 2016 — forked from havenwood/mock_monster.rb
Mocking a few Monsters with Minitest::Mock
View mock_monster.rb
require 'minitest/mock'
##
# This monster eats Symbols. Give it a Symbol and how many to eat and nom nom!
monster = Minitest::Mock.new
monster.expect :eat, :nom_nom, [Symbol, Numeric]
##
# Let's verify the monster in fact ate its Symbols:
monster.verify
View curryAandFilter.js
const data = [
{
"client_number": "00001",
"client_name": "voila Communications Ltd.",
"address1": "Ben votrant",
"address2": "voila Communications",
"address3": "P.O. Box 2086",
"address4": "55 Victoria Street",
"address5": "toronto",
"address6": "BERMUDA"
@6ewis
6ewis / recursion-contains-key.clj
Last active Apr 7, 2016
(contains-key :a {:v 1 :b 3 :a 3 :g 6})
View recursion-contains-key.clj
(boolean (seq (filter #(= k (key %)) m)))
(defn contains-key [m k]
(loop [[entry & rest :as coll] (seq m)]
(if (empty? coll)
false
(or (= (first entry) k)
(recur rest)))))
View versionWork2.js
const Test = React.createClass({
render: function() {
return (
React.createElement(React.createClass({
getInitialState: function() {
return {term: "test"};
},
handleChange: function(event) {
this.setState({term: event.target.value});
You can’t perform that action at this time.