$ rails g model User
belongs_to
has_one
| from pyparsing import * | |
| # By default, PyParsing treats \n as whitespace and ignores it | |
| # In our grammer, \n is significant, so tell PyParsing not to ignore it | |
| ParserElement.setDefaultWhitespaceChars(" \t") | |
| def parse(input_string): | |
| def convert_prop_to_dict(tokens): | |
| """Convert a list of field property tokens to a dict""" | |
| prop_dict = {} |
| class Api::RegistrationsController < Api::BaseController | |
| respond_to :json | |
| def create | |
| user = User.new(params[:user]) | |
| if user.save | |
| render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
| return | |
| else |
| # Set cache dir | |
| proxy_cache_path /var/cache/nginx levels=1:2 | |
| keys_zone=microcache:5m max_size=1000m; | |
| # Virtualhost/server configuration | |
| server { | |
| listen 80; | |
| server_name yourhost.domain.com; | |
| # Define cached location (may not be whole site) |
| #!/bin/bash | |
| # current Git branch | |
| branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
| # v1.0.0, v1.5.2, etc. | |
| versionLabel=v$1 | |
| # establish branch and tag name variables | |
| devBranch=develop |
| # | |
| # Initialize the stuff | |
| # | |
| # We build the status bar item menu | |
| def setupMenu | |
| menu = NSMenu.new | |
| menu.initWithTitle 'FooApp' | |
| mi = NSMenuItem.new | |
| mi.title = 'Hellow from MacRuby!' | |
| mi.action = 'sayHello:' |
| # This is Neocities' Rainbows! config file. We are using this in production to run all our web apps. | |
| # It works really well for us and has been heavily load tested, so I wanted to share it with the community. | |
| # | |
| # In my opinion, this is the best way to deploy a ruby web application. Unlike EventMachine based solutions, | |
| # it uses real ruby threads, which allows it to take advantage of the internal non-blocking IO pattern | |
| # in MRI. | |
| # | |
| # Contrary to popular belief, MRI doesn't block execution to wait on IO when you are using threads, even | |
| # with the GIL. The requests are done concurrently for anything that is based on the IO class. This | |
| # includes things like Net::HTTP and even `system commands`. Grep the MRI Ruby source code for |
| # Documentation for HAProxy | |
| # http://code.google.com/p/haproxy-docs/w/list | |
| # http://haproxy.1wt.eu/download/1.2/doc/architecture.txt | |
| # NOTES: | |
| # open files limits need to be > 256000, use ulimit -n to set (on most POSIX systems) | |
| global | |
| log 127.0.0.1 local0 | |
| log 127.0.0.1 local1 notice |
| # This code demonstrates how CS scoping works within a file. Scroll down to the end to | |
| # see how cross-file scoping works. | |
| # Here are the rules. | |
| # | |
| # Scoping is all lexical. Read the file from top to bottom to determine variable scopes. | |
| # | |
| # 1) When you encounter any variable in the top-level nesting, its scope is top level. | |
| # 2) Inside a function, if you encounter a variable name that still exists in an outer scope, then that | |
| # variable name refers to the variable in the outer scope. (This is "closure".) |
| ARDUINO_PATH='/usr/share/arduino/hardware/arduino/cores/arduino' | |
| VARIANTS_PATH='/usr/share/arduino/hardware/arduino/variants/standard' | |
| MCU='atmega328p' | |
| F_CPU=16000000 | |
| PORT='/dev/ttyACM0' | |
| UPLOAD_RATE=115200 | |
| CORE_SOURCES=\ | |
| $(ARDUINO_PATH)/wiring.c\ | |
| $(ARDUINO_PATH)/wiring_analog.c\ |