I hereby claim:
- I am daybreaker on github.
- I am daybreaker (https://keybase.io/daybreaker) on keybase.
- I have a public key ASCEUAt6wF2hH23KgNdKGvj_z3awkseJV7L4ScLJDwXTGQo
To claim this, I am signing this object:
# Needed a script to loop through several php files modify any links, and insert some code into the header of each page. | |
# Since the header was standard on each page, it was easy enough to match, as were any links | |
# My question: How could I refactor this to be more efficient than using two different sub/gsubs, and a seperate file write? | |
Dir.glob('*.php') do |file_name| | |
#Find one instance of the header, and modify it | |
content = File.read(file_name).sub(/regex/i, "multiline\nreplacement") | |
#find every instance of <a href="blah.php"> and modify it to say <a href="blah.php?foo=bar"> |
print("<pre>".print_r($my_array,true)."</pre>"); |
# model | |
class Survey < ActiveRecord::Base | |
CONDITIONS = ["surveys.hotel_id IS NOT NULL"] | |
end | |
# controller | |
conditions = Survey::CONDITIONS | |
unless params[:time_period].blank? | |
conditions << "surveys.created_at > '#{params[:time_period].to_i.months.ago}'" |
{ | |
:songkick_id=>"147918", | |
:videos=>[ | |
{"title"=>"Radio Birdman - New Race", "url"=>"http://www.dailymotion.com/video/x9js5b_radio-birdman-new-race_music", "site"=>"dailymotion.com", "date_found"=>"2013-04-16T00:00:00", "image_url"=>"https://s2-ssl.dmcdn.net/trGO.jpg", "id"=>"710c28f7f2c45e4f570412ee586cd412"}, | |
{"title"=>"Radio Birdman - Aloha Steve & Danno", "url"=>"http://www.dailymotion.com/video/x113dd_radio-birdman-aloha-steve-danno_music", "site"=>"dailymotion.com", "date_found"=>"2013-04-16T00:00:00", "image_url"=>"https://s1-ssl.dmcdn.net/f1D4.jpg", "id"=>"a0fe04216155c2450bf0016f11d8d34d"}, | |
{"title"=>"RADIO BIRDMAN - DIE LIKE APRIL", "url"=>"http://www.youtube.com/watch?v=xfVnsZdE7_U&feature=youtube_gdata_player", "site"=>"youtube.com", "date_found"=>"2013-04-16T00:00:00", "image_url"=>"http://i.ytimg.com/vi/xfVnsZdE7_U/default.jpg", "id"=>"1cc29d48cf5f5a46c779cdc048ef1cbb"}, | |
{"title"=>"Radio Birdman - Man With Golden Helmet", "url"=>"http://www.youtube.com/watch?v=dMlDbT13eXU |
951 -- joy | |
746 -- clapping | |
493 -- heart | |
454 -- ditto | |
450 -- +1 | |
387 -- 100 | |
249 -- revelry | |
192 -- nice | |
190 -- tada | |
160 -- wave |
490 -- +1 | |
125 -- 100 | |
120 -- eyes | |
105 -- clapping | |
101 -- nice | |
98 -- ditto | |
80 -- joy | |
69 -- heart | |
67 -- white_check_mark | |
57 -- nugget |
require 'slack-ruby-client' | |
require 'byebug' | |
require 'date' | |
def count_words(string) | |
words = string.split(' ') | |
frequency = Hash.new(0) | |
words.each { |word| frequency[word.downcase] += 1 } | |
frequency | |
end |
require 'slack-ruby-client' # first, make sure you do: gem install slack-ruby-client | |
require 'date' | |
# Add your Slack API token here | |
token = [YOUR TOKEN HERE] | |
Slack.configure do |config| | |
config.token = token | |
end |
I hereby claim:
To claim this, I am signing this object:
# gem install slack-ruby-client rubyzip | |
# run with: ruby dlemoji.rb | |
require 'rubygems' | |
require 'zip' | |
require 'slack-ruby-client' | |
require 'open-uri' | |
token = 'your slack api token' | |
directory = '/<absolute/path/to>/emoji/' # The emoji directory must exist, and be empty. |