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
| So prefix this with `javascript:` and compress it to one line and it works a treat. I've been playing with it in the chrome inspetor to get started |
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
| cloudfront_url = "https://123123.cloudfront.com" | |
| images_dir = "/users/12321/" | |
| manifest_file_path = "/users/12321/manifest.json" | |
| images = Dir["#{@processing_directory}/html/**/*.jpg"].map do |filename| | |
| "#{cloudfront_url}/#{images_dir}/#{filename}" | |
| end | |
| delivery_data = {images: images} |
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 Pruner | |
| def initialize(root) | |
| @skip = [ | |
| '.', '..', # System files | |
| '.DS_Store', # Mac files | |
| 'determiners' # Directories that are programatic | |
| ] | |
| @root = root | |
| 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
| # DON'T call this _test.rb as you don't want it to run | |
| module AbstractTest | |
| def test_the_abstract_thing | |
| klass.do_something | |
| assert something, klass.something | |
| end | |
| 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 Inquisitio | |
| attr_reader :criteria, :limit, :order | |
| def initialize | |
| @criteria = [] | |
| @limit = 10 | |
| yield(self) if block_given? | |
| 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
| def self.search(name) | |
| User.where(id: Inquisition.search(name, type: "User").ids) | |
| end | |
| describe "User searching" do | |
| it "should return users" do | |
| user = create(:user) |
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 'eventmachine' | |
| def write_file(text) | |
| filename = "/Users/iHiD/Desktop/dump.txt" | |
| File.open(filename, 'w') do |f| | |
| f.flock(File::LOCK_EX) | |
| f.write(text) | |
| sleep 0.005 | |
| end | |
| 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 Creator | |
| class << self | |
| def create!(*args) | |
| create(*args).tap do |object| | |
| raise ActiveRecord::RecordInvalid.new(object) if object.new_record? | |
| end | |
| end | |
| end | |
| 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
| rows = CSV.do_stuff_here | |
| rows.each do |row| | |
| user = User.new | |
| user.name = row[:name] | |
| user.mobile = "" | |
| user.email = row[:email] | |
| user.password = row[:password] | |
| user.admin = true |
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
| # Retrieve a belongsTo association | |
| favourite = @get 'user_favourite' | |
| # I'd like to do the following but it makes the | |
| # record dirty, as user_favourite has changed. | |
| # I really don't want user_favourite being tracked, | |
| # But I want to get it with the initial JSON. | |
| favourite.destroyRecord() | |
| Meducation.store.commit() |