Skip to content

Instantly share code, notes, and snippets.

View samueljoli's full-sized avatar
🔒
lalilulelo

Samuel Joli samueljoli

🔒
lalilulelo
View GitHub Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
sentence = <<-something
Steven likes the movies. Blake likes to ride his bike but hates movies.
Blake is taller than steven. Steven is a great teacher.
something
sentence2 = sentence.gsub('.', '').split(' ')
sentence2 = sentence2.collect { |i| i = i.upcase }
num = 1
word = nil
count = 0
counter = 0
flatiron_school = {:teachers=>[{:name=>"steph"}, {:name=>"uzo"}, {:name=>"blake"}], :students => [{:name => "giancarlo", :grade => 100, :address => "bronx"},{:name => "jamie", :grade => 200, :address => "NJ"}]}
flatiron_school.each do |key, value|
value.each do |names|
puts names[:name]
end
end
# Count words in a sentence
require 'pry-nav'
require "pry"
require 'ap'
paragraph = <<-something
Steven likes the movies. Blake likes to ride his bike but hates movies.
Blake is taller than steven. Steven is a great teacher.
something
@samueljoli
samueljoli / issues_with_modules.md
Last active September 6, 2015 15:35 — forked from ryanb/issues_with_modules.md
Points on how modules can make code difficult to read.

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article &lt; ActiveRecord::Base
@samueljoli
samueljoli / gist:28a0c81be2bfeb24be5e13b25ff3922a
Created August 15, 2018 15:39
Simple node.js code style tips to improve code quality

Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.

Required modules

JavaScript makes it harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.

Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using new. This was an important semantic in the early days of JavaScript but at this point, if you don't know Date requires new Date() you are probably very new. We have adopted Upper Camel Case variable names for all module global variables

@samueljoli
samueljoli / array_iteration_thoughts.md
Created December 14, 2018 15:52 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

@samueljoli
samueljoli / README.markdown
Created August 3, 2020 13:51
Rob Pike - "Concurrency is not Parallelism"

Rob Pike - "Concurrency is not Parallelism"

Rob Pike - "Concurrency is not Parallelism"

source: https://www.youtube.com/watch?v=cN_DpYBzKso

Notes

  • the world is not object oriented, is actually parallel
  • concurrency is dealing with a lot of things at once, parallel is doing a lot of things at once, one is about structure,