This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| has_many :categories_users, :class_name => 'CategoriesUsers' | |
| #not working | |
| has_many :categories, :through => 'categories_users' | |
| #working | |
| has_many :categories, :through => :categories_users |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ViewsQueue | |
| # | |
| # data = [ {:hits => 10, :data => 'cool.js'}, {:hits => 10, :data => 'another.js'} ] | |
| # queue = ViewsQueue.new(data) | |
| # queue.get_next | |
| # | |
| def initialize(queue) | |
| @queue = queue.cycle | |
| @current_item = @queue.next | |
| @current_item_hits = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'net/http' | |
| require 'net/https' | |
| require 'openssl' | |
| require 'uri' | |
| require 'rubygems' | |
| require 'gdata' | |
| require 'gdata/http' | |
| require 'digest/sha1' | |
| url = 'https://apps-apis.google.com/a/feeds/almazom.com/user/2.0' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fetch_to_buffer(Socket, Boundary, Buff) when length(Buff) < 3 -> | |
| case gen_tcp:recv(Socket, 0) of | |
| {ok, Boundary} -> | |
| fetch_to_buffer(Socket, Boundary, [#form_data{} | Buff]); | |
| {ok, <<"Content-Disposition: form-data; name=", Name/binary>>} -> | |
| [Item|List] = Buff, | |
| io:format("debug content-desposition ~p ~n", [Item]), | |
| V1 = Item#form_data{param_name = Name}, | |
| fetch_to_buffer(Socket, Boundary, [V1 | List]); | |
| {ok, <<"Content-Type: ", Type/binary>>} -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(app). | |
| -export([start/0, listen/1]). | |
| -include_lib("kernel/include/file.hrl"). | |
| -record(state, {port, asock, request_count = 0}). | |
| -record(req, {method, path, a, bin_path, content_type, content_length, headers}). | |
| -record(form_data, {content_type, param_name, value}). | |
| -define(_if(Predicate, TrueCase, FalseCase), if Predicate -> TrueCase; true -> FalseCase end). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cool buff [{form_data,undefined,undefined,undefined}] | |
| 71> | |
| =ERROR REPORT==== 30-Jul-2012::19:09:52 === | |
| Error in process <0.429.0> with exit value: {badarg,[{app,fetch_to_buffer,3,[{file,"app.erl"},{line,108}]},{app,do_recv,5,[{file,"app.erl"},{line,128}]},{app,consume_body,3,[{file,"app.erl"},{line,80}]},{app,receive_req,1,[{file,"app.erl"},{line,34}]}]} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ActiveRecord::Base | |
| attr_protected :role, :expires_at, :salt, :hashed_pass, :secure_id | |
| SESSION_TIME_MIN = 100000.to_i | |
| email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i | |
| validates :role, presence: true | |
| validates :name, :presence => true, :length => { :maximum => 40 } | |
| validates :surname, :presence => true, :length => { :maximum => 40 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Integer | |
| def fibo() | |
| return 0 if self == 0 | |
| (self - 1).fibo + self | |
| end | |
| end | |
| p 5.fibo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="commands" class="even"> | |
| <div style="float:right;"> | |
| <% form_tag(url, :multipart => true, | |
| :onsubmit => "return AIM.submit(this, { | |
| onStart: function() { SITEMAN.loading(); }, | |
| onComplete: function(results) { | |
| var url = '#{reload_url}', | |
| reloadPicker = #{reload_picker}; | |
| if (reloadPicker) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Locomotive | |
| class FileInput | |
| include Formtastic::Inputs::Base | |
| def to_html | |
| input_wrapping do | |
| label_html | |
| end | |
| end |