Skip to content

Instantly share code, notes, and snippets.

View oliviachang29's full-sized avatar

olivia chang oliviachang29

View GitHub Profile
@oliviachang29
oliviachang29 / notes.json
Last active June 22, 2018 07:01
Frequencies of musical notes
[
{
"note": "C",
"octave": 0,
"frequency": 16.35,
},
{
"note": "C#",
"octave": 0,
"frequency": 17.32,
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
@oliviachang29
oliviachang29 / new.html.erb
Last active September 23, 2018 19:16
app/views/parents/new.html.erb
<%= form_for(@parent) do |f| %>
… parent attributes go here …
<ul>
<%= f.nested_fields_for :kids do |kids_form| %>
<li>
<%= kids_form.text_field :name %>
<%= kids_form.remove_nested_fields_link %> # Delete link
</li>
<% end %>
</ul>
@oliviachang29
oliviachang29 / new.html.erb
Last active September 23, 2018 19:16
app/views/parents/new.html.erb
<%= form_for(@parent) do |f| %>
<%= f.add_nested_fields_link :kids do %>
<span>New Kid</span>
<% end %>
...
<% end %>
@oliviachang29
oliviachang29 / new.html.erb
Last active September 23, 2018 19:16
app/views/parents/new.html.erb
<%= form_for(@parent) do |f| %>
… parent attributes go here …
<ul>
<%= f.nested_fields_for :kids do |kids_form| %>
<li>
<%= kids_form.text_field :name %>
</li>
<% end %>
</ul>
@oliviachang29
oliviachang29 / parents_controller.rb
Last active September 29, 2018 00:21
app/controllers/parents_controller.rb
class ParentsController < ApplicationController
def new
@parent = User.new
2.times {@parent.kids.build} 
# This creates a new, empty Parent instance and two empty kid instances belonging to the Parent.
end
 
 def create
  @parent = Parent.create(parent_params)
if @parent.save
@oliviachang29
oliviachang29 / kid.rb
Created August 3, 2017 19:18
app/models/kid.rb
class Kid < ActiveRecord::Base
 belongs_to :parent
end
@oliviachang29
oliviachang29 / parent.rb
Created August 3, 2017 19:17
app/models/parent.rb
class Parent < ActiveRecord::Base
 has_many :kids
 accepts_nested_attributes_for :kids
end
@oliviachang29
oliviachang29 / CodePushComponent.js
Last active May 4, 2019 17:14
CodePushComponent.js
import React from 'react'
import codePush from 'react-native-code-push'
let codePushOptions = { installMode: codePush.InstallMode.ON_NEXT_RESUME, checkFrequency: codePush.CheckFrequency.ON_APP_RESUME }
export class CodePushComponent extends React.Component {
componentDidMount() {
codePush.sync()
}