Skip to content

Instantly share code, notes, and snippets.

View jamesyang124's full-sized avatar

James Yang jamesyang124

  • HTC
  • Richmond, California
View GitHub Profile
@jamesyang124
jamesyang124 / confident_ruby_review.md
Last active August 29, 2015 14:05
Review of the book - Confident Ruby

Review of Confident Ruby

Read API doc

  1. any? [{ |obj| block }] → true or false means could either accept 0 or 1 { |obj| block } block.

  2. send(symbol [, args...]) → obj means could either accept 0 or many argumetns. if symobol method accept block, then may also appen that block to it, e.g. define_method.

Xor and Sum

You are given two positive integers a and b in binary representation. You should find the following sum modulo 10 ^ 9 + 7:

Summation(a xor (b shl i)) from i = 0 to 314159

where operation xor means exclusive OR operation, operation shl means binary shift to the left.

  • Item 6
  • Ruby find a method by searching its suplerclass until to the top, then back to original class then searching the hierachy for method_missing again.
// example object

var obj = {'property': 1234}

Object & Prototype

  1. Everything is object, except null and undefined.
@jamesyang124
jamesyang124 / ios_development.md
Last active August 29, 2015 14:25
Side notes from CS193P course in Stanford University.

Lecture 1

  1. Constraint and auto layout.
  • Auto Layout Concepts
  • The attributes leading and trailing are the same as left and right for left-to-right languages such as English, but in a right-to-left environment such as Hebrew or Arabic, leading and trailing are the same as right and left.
  • Constraints are cumulative, and do not override each other. Setting a second width constraint for a view does not remove or alter the first width constraint.
  1. @IBOutlet weak var prpoerty.
@jamesyang124
jamesyang124 / red_black_tree_revisited.md
Last active May 8, 2023 01:51
Red black tree in ruby.

Red Black Tree revisit.

TIME
INSERTION O(log n)
DELETION O(log n)
SEARCH O(log n)

| SPACE | O(n) |

@jamesyang124
jamesyang124 / css_learning_note.md
Last active January 11, 2016 11:00
85+% correct CSS notes.

#Learning CSS Note

###1. Class Selector

If two class selector rules ovelap same properties, the later rule in css file will take it. So it is called css.

If rule selector select element, then more restrictive element will apply that rule. ex: div prior then body.

The precedence is more specific selector will take the higer priority.

@jamesyang124
jamesyang124 / weird_part_of_js.md
Created September 17, 2015 23:07
notes from udemy online course.

#Weird Part Of JS

  1. this is global object if there does not have receiver. If so, it also imply it is a window object, document === window.document.

  2. JS engine create this execution context(window object) in bottom of execution stack and run other execution context which is in top of it for you.

  3. When you declare a var or define as a function(function expression or function statement), you can find it through window.func() or func() in global environment.

  4. Hoisting: var and func are all firstly initialize but not assigned its value yet until the later code assign it. Check code example below.

@jamesyang124
jamesyang124 / action_controller_review.md
Last active July 13, 2023 08:54
Notes for action controller overview from Rails official site. rails 4.2

#Action Controller Overview

##0. Mass Assignment

  1. Mass assignment allows us to set a bunch of attributes at once:

    attrs = {	:first => "John", :last => "Doe", 
    			:email => "john.doe@example.com"}
    user = User.new(attrs)