Skip to content

Instantly share code, notes, and snippets.

View between40and2's full-sized avatar

Juguang XIAO between40and2

  • London & Beijing
View GitHub Profile
@between40and2
between40and2 / rails-response.md
Last active August 29, 2015 14:02
This gist explains how to use render or redirect_to for HTTP response

render and redirect_to

To

@between40and2
between40and2 / rails-console.md
Last active August 29, 2015 14:02
Rails console tips

rails console

Model

> ActiveRecord::Base.connection.tables.map { |t| "#{t} => " + ActiveRecord::Base.connection.execute("select count(*) from #{t}").fetch_row.first}

@between40and2
between40and2 / rails-http-basic-digest-auth.md
Created June 23, 2014 09:03
HTTP Basic/Digest Auth in Rails

ActionController::HttpAuthentication::Basic::ControllerMethods

  • authenticate_or_request_with_http_basic(realm = "Application", &login_procedure)
  • authenticate_with_http_basic(&login_procedure)
  • request_http_basic_authentication(realm = "Application")

ActionController::HttpAuthentication::Digest::ControllerMethods

@between40and2
between40and2 / -rails-routing-intro.md
Last active August 29, 2015 14:02
Rails Routing System components

input part

use part

##Methodology to examine routing system.

Playing with Rails console

$ rails c
> app.main_app.routes  

=> #

@between40and2
between40and2 / rails-bin.md
Created July 1, 2014 01:15
Scripts under bin directory of your Rails app

bundle

#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

rails

Ugliness of iOS Programming
First of all, i love iOS and iOS development ecosystem.
However, after I quick learnt Ruby on Rails, I found how messy iOS Programming Frameworks are. Apple guys must feel innocent on this. They have worked hard to make the frameworks easy to use, powerful yet flexible.
one end is, "there is more than one way to do a thing". I first heard it from Perl, which they are proud of that.. However, the downside of this is there is no conversion or culture.
There is no so-called application framework for iOS officially from Apple. After rough understanding on UIKit and Foundation, the developers need a further direction on how to improve the productivity on iOS development.
@between40and2
between40and2 / WelcomeToBlockWorld
Last active December 10, 2015 07:58
WelcomeToBlockWorld. get habit to use block-based, rather than old-style return-based invocation.
WelcomeToBlockWorld
http://www.cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html
@between40and2
between40and2 / gist:5194810
Last active December 15, 2015 03:29
iOS & RoR
iOS & RoR
Wired combination? In my past 12 years, I have used more than these technologies on GUI and Web. Finally I fell in these 2.
One feature charms me in RoR is the feature of metaprogramming. Ruby supports it and Rails fully uses it. It sucks me into deeper thought on metaphysics of programming. Why are we (as programmers) here? What can machine (software) facilitates men (programmers) ? I would like to share some of my ideas.
Before iOS, I was working intensively with Adobe Flex. The beauty of Flex's flexible architecture attacks me, plus its UI expressiveness. I was my dream back in 2005, to present fancier UI on Web via programmable Flash. In 2010, the year I came to meet iOS, there was the debate on whether Flash should be run on iOS, I was wondering whether I should go for iOS. I became so determined after I realised the depth and width of iOS technologies are much greater than of Flash/Flex. Another obviously plus on iOS is, I can carry on my program anywhere I go.
@between40and2
between40and2 / gist:5194833
Last active December 15, 2015 03:29
rails plugin migration
http://stackoverflow.com/questions/4974039/rails-project-organization-with-many-models
http://stackoverflow.com/questions/6550103/in-which-folder-should-i-put-global-shared-partial-templates
http://stackoverflow.com/questions/6550103/in-which-folder-should-i-put-global-shared-partial-templates
<pre><code>$ cd your_repo_root/repo_name
$ git fetch origin
$ git checkout gh-pages