Models | Examples |
---|---|
Display ads | Yahoo! |
Search ads |

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
arr = [2, 4, 67, 0, 12, 7] | |
def reach_end arr | |
current_max_index = arr[0] | |
hop_count = 0 | |
last_index_of_array = arr.size - 1 | |
puts "=-"*5 | |
puts "CURRENT_MAX_INDEX : #{current_max_index}" |
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 find_next_largest arr | |
base = arr[0] | |
new_base = arr.map{|x| x if x > base}.compact.sort.first | |
new_array = [new_base] | |
no_of_times_base_value_present = arr.select{|x| x == new_base}.compact.count | |
rest_array = arr - [new_base] + (new_base.to_s*(no_of_times_base_value_present-1)).split("").map{|x| x.to_i} | |
rest_array = rest_array.sort |
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 ImageUploader < CarrierWave::Uploader::Base | |
include CarrierWave::MiniMagick | |
storage :file | |
def thumb(size) | |
begun_at = Time.now | |
size.gsub!(/#/, '!') | |
uploader = Class.new(self.class) | |
uploader.versions.clear | |
uploader.version_names = [size] |
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 class='content'> | |
<!-- your application code, which requires some JS --> | |
</div> | |
<% content_for :javascript do %> | |
<script type="text/javascript"> | |
$(function () { | |
$('th').tooltip(); | |
}); | |
</script> |
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
#!/usr/bin/env ruby | |
# Author : Emad Elsaid (https://github.com/blazeeboy) | |
require 'linkedin' # gem install linkedin | |
require 'json' | |
# create an appliation then | |
# get your api keys at https://www.linkedin.com/secure/developer | |
config = { | |
your_consumer_key: 'xxxxxxxxxxxxxxxx', | |
your_consumer_secret: 'xxxxxxxxxxxxxxxx', |
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 'csv' | |
class Exporter | |
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ] | |
DESTINATION_FOLDER = "tmp/" | |
def self.export_tables_to_csv(tables = DEFAULT_EXPORT_TABLES) | |
tables.each { |klass| export_table_to_csv(klass) } | |
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
# install rvm | |
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) | |
# install ruby 1.9.2 + some global gems | |
rvm install 1.9.2 | |
rvm use 1.9.2@global | |
gem install awesome_print map_by_method wirble bundler builder pg cheat | |
gem install -v2.1.2 builder |