Skip to content

Instantly share code, notes, and snippets.

@yosukehasumi
yosukehasumi / .rubocop.yml
Last active September 2, 2020 19:40
Animiki/.rubocop.yml
---
require:
- rubocop-performance
- rubocop-rails
Style/Documentation:
Enabled: false
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
# gem install rubocop-rails
# gem install rubocop-performance
# SublimeLinter Settings - User (if using rbenv)
# {
# "paths": {
# "osx": [
# "~/.rbenv/shims"
# ]
# }
@yosukehasumi
yosukehasumi / boilerplate.sublime-project
Created May 7, 2020 18:36
*.sublime-project example boilerplate
{
"folders":
[
{
"path": ".",
"folder_exclude_patterns": [
"node_modules",
"public",
"storage",
"tmp",
@yosukehasumi
yosukehasumi / .eslintrc.js
Created April 11, 2020 06:31
SublimeText3 - eslint configuration and setup
// Install all dependencies without the need for a package.json like this
// npm install eslint typescript @typescript-eslint/parser eslint-plugin-react@latest @typescript-eslint/eslint-plugin@latest eslint-plugin-react-hooks@latest
// npx install-peerdeps --dev eslint-config-airbnb
// For SublimeText users, install
// 1. SublimeLinter
// 2. SublimeLinter - eslint
// SublimeLinter Settings - User
// {
@yosukehasumi
yosukehasumi / .rubocop.yml
Created April 9, 2020 05:35
My preferred rubocop
# gem install rubocop-rails
# gem install rubocop-performance
# SublimeLinter Settings - User (if using rbenv)
# {
# "paths": {
# "osx": [
# "~/.rbenv/shims"
# ]
# }
# frozen_string_literal: true
# GuestList.find(4)
# {
# guest_id: id,
# additional_guests: {
# '123': {
# name: 'New Name'
# }
@yosukehasumi
yosukehasumi / IMG100LectureNotes.md
Last active October 10, 2019 19:53
Lecture Notes for the IMG students

What is the Web and how does it actually work?

When you browse to a website you're requesting to see a website that is possibly served to you across continents, routed through a vast network of domain name servers and IP addresses in long strings of coding and rendered in a browser. These things don't happen magically! They were written by millions of people and stitched together in an intricate network of computers and cables. The magic is that you have the ability to seemlessly tap into this network as you're laying in bed watching netflix, facebook creeping your latest crush, or looking up a delicious recipe for your favorite apple pie.

We take this for granted! Let me dymistify this a bit for you. I won't try and teach about how to actually do any of this stuff but give you a high-level understanding of what "it" actually is and where to look to learn more.

Information paths

When you type in a url, let's say netflix.com you are actually REQUESTing an address. Your request travels over WIFI and

@yosukehasumi
yosukehasumi / dragevents.coffee
Created May 3, 2019 18:26
Drag Event handler class
window.DragEventHandler = (containers) ->
focused = false
this.windowDragoverOn = ->
unless focused
focused = true
for container in containers
container.classList.add('window-dragover')
this.windowDragoverOff = ->

Implementing Mailers

Let's say we want our application to email us whenever we spend a certain amount on a particular category for the current month

Limits value

Let's create a column on our categories table that can store monthly limits.

bin/rails generate migration add_category_limits

Money Gem

Money displaying in cents has been driving me nuts, let's fix that since I promised a long time ago that we would!

Update table

We need to rename the column name from amount to amount_cents so that we can properly use the 'Money' gem. So let's create a migration

bin/rails generate migration rename_transaction_amount