Skip to content

Instantly share code, notes, and snippets.

@codemilan
codemilan / ar_arel_wrapper.rb
Created June 14, 2018 11:13 — forked from tokland/ar_arel_wrapper.rb
Simple wrapper over arel
require 'active_record'
require 'arel'
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0).
#
# What you would usually write like this:
#
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"])
#
# can now be written like this (note those parentheses required by the operators precedences):
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'pg'
gem 'activerecord', '5.2.0'
gem 'memory_profiler'
gem 'benchmark-ips'
end
@codemilan
codemilan / gist:ddc81229f4dfc765da5698a61c4c6af9
Created May 12, 2018 16:08 — forked from ssjr/gist:5970762
My setup for Ruby on Rails with Mac OS X

My initial setup for Ruby on Rails development

Note: I'm using Mac OS X Lion (10.7.5)

All links, commands and order to install

  1. Download Xcode
  2. Open Xcode, Xcode (menu) > Preferences... > Downloads. Install Command Line Tools
  3. Install Homebrew
  • ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@codemilan
codemilan / react-native-setup-linux.md
Created November 3, 2017 14:54 — forked from andrei-cacio/react-native-setup-linux.md
React native setup on Ubuntu/Linux

Guide for installing React Native on Linux (ubuntu 14.04)

Step 1: Install JDK 7

sudo apt-get install openjdk-7-jdk

Step 2: Download the Android SDK

@codemilan
codemilan / react_fiber.md
Created October 12, 2017 05:18 — forked from geoffreydhuyvetters/react_fiber.md
What is React Fiber? And how can I try it out today?
@codemilan
codemilan / gist:a299067b783fed70ad44a04c203aeab9
Created August 31, 2017 11:15 — forked from markbates/gist:4240848
Getting Started with Rack

If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.

Rack describes itself as follows:

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.

At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.

@codemilan
codemilan / digital_ocean_setup.md
Created August 13, 2017 10:49 — forked from ChuckJHardy/digital_ocean_setup.md
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions

DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3

SSH into Root

$ ssh root@123.123.123.123

Change Root Password

* Downloaded or downloading
=============================
**http://kickass.to/infiniteskills-learning-jquery-mobile-working-files-t7967156.html
**http://kickass.to/lynda-bootstrap-3-advanced-web-development-2013-eng-t8167587.html
**http://kickass.to/lynda-css-advanced-typographic-techniques-t7928210.html
**http://kickass.to/lynda-html5-projects-interactive-charts-2013-eng-t8167670.html
**http://kickass.to/vtc-html5-css3-responsive-web-design-course-t7922533.html
*http://kickass.to/10gen-m101js-mongodb-for-node-js-developers-2013-eng-t8165205.html
*http://kickass.to/cbt-nuggets-amazon-web-services-aws-foundations-t7839734.html