This is a fairly common question, and there isn't a One True Answer.
These are the most common techniques:
| Warden::Manager.serialize_into_session{|user| user.id } | |
| Warden::Manager.serialize_from_session{|id| User.get(id) } | |
| Warden::Manager.before_failure do |env,opts| | |
| # Sinatra is very sensitive to the request method | |
| # since authentication could fail on any type of method, we need | |
| # to set it for the failure app so it is routed to the correct block | |
| env['REQUEST_METHOD'] = "POST" | |
| end | |
| *.acn | |
| *.acr | |
| *.alg | |
| *.aux | |
| *.bak | |
| *.bbl | |
| *.bcf | |
| *.blg | |
| *.brf | |
| *.bst |
| ############################################################################# | |
| # Migration file to create index so you don't get duplicate users for a group | |
| ############################################################################# | |
| class AddMembersUniquenessIndex < ActiveRecord::Migration | |
| def self.up | |
| add_index :group_members, [:group_id,:user_id], :unique => true | |
| end | |
| def self.down | |
| remove_index :group_members, [:group_id,:user_id] |
| def valid? version | |
| pattern = /^\d+\.\d+\.\d+(\-(dev|beta|rc\d+))?$/ | |
| raise "Tried to set invalid version: #{version}".red unless version =~ pattern | |
| end | |
| def correct_version version | |
| ver, flag = version.split '-' | |
| v = ver.split '.' | |
| (0..2).each do |n| | |
| v[n] = v[n].to_i |
This was useful for me when we created a new branch for a new major release, but were still working on our current version as well. I cloned our repo again and kept the new project on our new branch, but also wanted to get my stashes there.
git stash show -p > patch
You'll have to specify your stash and name your file whatevery you want. Do this for as all your stashes, and you'll have patch files in your pwd.
| ## | |
| # Haversine Distance Calculation | |
| # | |
| # Accepts two coordinates in the form | |
| # of a tuple. I.e. | |
| # geo_a Array(Num, Num) | |
| # geo_b Array(Num, Num) | |
| # miles Boolean | |
| # | |
| # Returns the distance between these two |
| # | |
| # CORS header support | |
| # | |
| # One way to use this is by placing it into a file called "cors_support" | |
| # under your Nginx configuration directory and placing the following | |
| # statement inside your **location** block(s): | |
| # | |
| # include cors_support; | |
| # | |
| # As of Nginx 1.7.5, add_header supports an "always" parameter which |
| # Question: | |
| # Suppose you have an array of 99 numbers. | |
| # The array contains the digits 1 to 100 with one digit missing. | |
| # Write four different algorithms to compute the missing number. | |
| # Two of these should optimize for low storage and two of these should optimize for fast processing. | |
| # (Keep in mind, there are no duplicates and the array is not already sorted.) | |
| ####################################################### |