This file contains 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
irb(main):001:0> require “scanf” | |
=> true | |
irb(main):002:0> “Mozaix LLC”.scanf(“%s%s”) | |
=> [“Mozaix”, “LLC”] | |
irb(main):003:0> “Mozaix 2017”.scanf(“%s%d”) | |
=> [“Mozaix”, 2017] |
This file contains 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
irb(main):001:0> require “scanf” | |
=> true | |
irb(main):002:0> “Mozaix LLC”.scanf(“%s%s”) | |
=> [“Mozaix”, “LLC”] | |
irb(main):003:0> “Mozaix 2017”.scanf(“%s%d”) | |
=> [“Mozaix”, 2017] |
This file contains 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
# Allows you to build a Hash in a fashion very similar to Builder. Example: | |
# Fork of https://gist.github.com/360506 by BrentD with some enhancements | |
class HashBuilder | |
instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|^object_id$)/ } | |
def initialize | |
@hash = Hash.new | |
@target = @hash | |
end |
This file contains 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
# Allows you to build a Hash in a fashion very similar to Builder. Example: | |
# | |
# HashBuilder.build! do |h| | |
# h.name "Brent" | |
# h.skillz true | |
# h.location do | |
# h.planet "Earth" | |
# end | |
# end | |
# |
This file contains 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
# https://github.com/github/gitignore/blob/master/Rails.gitignore | |
*.rbc | |
capybara-*.html | |
.rspec | |
/log | |
/tmp | |
/db/*.sqlite3 | |
/db/*.sqlite3-journal | |
/public/system |
This file contains 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
# by Alexander Kovtunov | |
# require 'benchmark' | |
# require 'benchmark/ips' | |
require './tire_user_model.rb' | |
# | |
# User.tire.index.create(:mappings => User.tire.mapping_to_hash, :settings => User.tire.settings) | |
#User.tire.index.reindex('users',:mappings => User.tire.mapping_to_hash,:settings => User.tire.settings) | |
# User.tire.index.delete |
This file contains 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
# by Alexander Kovtunov | |
require 'active_support' | |
require 'active_record' | |
require 'tire' #gem install tire | |
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' | |
ActiveRecord::Base.connection.instance_eval do | |
create_table(:users) { |t| t.string :name; t.string :country } |
This file contains 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
# Google Direction API | |
include HTTParty | |
format :json | |
def api_key | |
# Your API key | |
end | |
def direciton_api_url |
This file contains 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
add_action( 'admin_notices', 'wps_print_admin_pagehook' ); | |
function wps_print_admin_pagehook(){ | |
global $hook_suffix; | |
if( !current_user_can( 'manage_options') ) | |
return; | |
?> | |
<div class="error"><p><?php echo $hook_suffix; ?></p></div> | |
<?php | |
} |