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
| def create_token | |
| characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890' | |
| token = '' | |
| 4.times do | |
| pos = rand(characters.length) | |
| token += characters[pos..pos] | |
| end | |
| token | |
| 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
| token = Digest::SHA1.hexdigest(Time.now.to_s.split(//).sort_by {rand}.join) |
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
| def create_token(len = 20) | |
| chars = (("a".."z").to_a + ("1".."9").to_a )- %w(i o 0 1 l 0) | |
| token = Array.new(len, '').collect{chars[rand(chars.size)]}.join | |
| 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
| chars = ("a".."z").to_a + ("1".."9").to_a | |
| token = Array.new(8, '').collect{chars[rand(chars.size)]}.join |
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
| token = Digest::SHA1.hexdigest([Time.now, rand].join) |
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
| def create_token | |
| self.token = secure_digest(Time.now, self.id, (1..10).map{ rand.to_s }) | |
| end | |
| def secure_digest(*args) | |
| Digest::SHA1.hexdigest(args.flatten.join('--')) | |
| 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
| token = ActiveSupport::SecureRandom.hex(5) |
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
| # Finds videos by tags (keywords). | |
| # | |
| # You can use the operators +NOT+(-) and +OR+(|). For example: | |
| # find_by_tag('cats|dogs', '-rats') | |
| def find_by_tag(*tags) | |
| url = "videos/-/%7Bhttp%3A%2F%2Fgdata.youtube.com%2Fschemas%2F2007%2Fkeywords.cat%7D" | |
| keywords = tags.map{ |t| CGI::escape(t) }.join('/') | |
| request("#{url}#{keywords}") | |
| 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
| class Twitter < YqlTable | |
| def grab | |
| category = Category.find_by_name("Tweets") | |
| terms = ["ucsd", "ucla", "csupomona"] # TODO Needs to pull from colleges | |
| result_set = self.query(terms).run | |
| raise result_set.inspect unless result_set["query"] && result_set["query"]["results"] | |
| default_user = User.find_by_login("twitter") || User.first | |
| result_set["query"]["results"]["entry"].each do |result| | |
| author = User.find_by_twitter_name(result["author"]["uri"].split('/').last) || default_user | |
| post = category.posts.create!(:title => result["title"], :raw_post => result["content"]["content"], :service_id => result["id"], :user => author, :published_as => 'live') |
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
| SQL (0.1ms) SET client_min_messages TO 'panic' | |
| SQL (0.1ms) SET client_min_messages TO 'notice' | |
| Loading routes from /Users/davidamcclain/apps/notch8/loc_dashboard/vendor/plugins/community_engine/config/desert_routes.rb. | |
| ThinkingSphinx::Deltas::Job Delete all (0.8ms) DELETE FROM "delayed_jobs" WHERE (handler LIKE '--- !ruby/object:ThinkingSphinx::Deltas::%') | |
| SQL (0.3ms) begin | |
| SQL (0.6ms) savepoint ts | |
| SQL (0.0ms) PGError: ERROR: function "array_accum" already exists with same argument types | |
| : CREATE AGGREGATE array_accum (anyelement) | |
| ( | |
| sfunc = array_append, |
OlderNewer