Skip to content

Instantly share code, notes, and snippets.

View 6ewis's full-sized avatar

Lewis 6ewis

  • Toronto, Ontario
View GitHub Profile
@6ewis
6ewis / Life cycle method
Created October 13, 2017 19:01
Describe the 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
(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 June 17, 2016 20:48 — forked from havenwood/mock_monster.rb
Mocking a few Monsters with Minitest::Mock
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
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 April 7, 2016 21:01
(contains-key :a {:v 1 :b 3 :a 3 :g 6})
(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)))))
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});
const accordionInstance = (
<Accordion>
<Panel header="Collapsible Group Item #1" eventKey="1">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</Panel>
<Panel header="Collapsible Group Item #2" eventKey="2">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, s
const Test = (
React.createClass({
render: function() {
return (
<Panel {...this.props} header={this.props.header} eventKey={this.props.eventKey}>
{React.createElement(React.createClass({
getInitialState: function() {
return {term: "test"};
},
const state = [
{id: 12, foo: 'bar', 'attribute': 101},
{id: 34, foo: 'baz', 'attribute': 102},
{id: 56, foo: 'qux', 'attribute': 103}
];
const action = {payload: {id: 34, attribute: 'attribute'}};
// findObjectIndex :: [Object] -> Int
const findObjectIndex = findIndex(propEq('id', action.payload.id));
@6ewis
6ewis / vim74_lua
Last active August 29, 2015 14:28 — forked from jdewit/vim74_lua
Installing vim 7.4 with lua on Ubuntu 12.04
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common
sudo apt-get build-dep vim-gnome
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev mercurial libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev
sudo rm -rf /usr/local/share/vim
sudo rm /usr/bin/vim