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
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to | |
# newer versions of the distribution. | |
deb http://archive.ubuntu.com/ubuntu/ bionic main restricted | |
# deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted | |
## Major bug fix updates produced after the final release of the | |
## distribution. | |
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted | |
# deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted |
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
# Original from http://snippets.dzone.com/posts/show/4468 by MichaelBoutros | |
# | |
# Optimized version which uses to_yaml for content creation and checks | |
# that models are ActiveRecord::Base models before trying to fetch | |
# them from database. | |
namespace :db do | |
namespace :fixtures do | |
desc 'Dumps all models into fixtures.' | |
task :dump => :environment do | |
models = Dir.glob(Rails.root + 'app/models/**.rb').map do |s| |
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
# Original from http://snippets.dzone.com/posts/show/4468 by MichaelBoutros | |
# | |
# Optimized version which uses to_yaml for content creation and checks | |
# that models are ActiveRecord::Base models before trying to fetch | |
# them from database. | |
namespace :db do | |
namespace :fixtures do | |
desc 'Dumps all models into fixtures.' | |
task :dump => :environment do | |
models = Dir.glob(Rails.root + 'app/models/**.rb').map do |s| |
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
:javascript | |
function init() { | |
console.log('focus'); | |
location.reload(); | |
} | |
window.addEventListener('focus', init); |
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
filepath = "in.csv" | |
out_file = "out" | |
line_count = 250 | |
lines = IO.readlines(filepath) | |
total_page = (lines.count - 1) / line_count + 1 | |
header = lines.first | |
(1.. total_page).each do |page| | |
File.open("#{out_file}#{page}.csv","w") do |text| |
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
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
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
module FactoryBot | |
module Syntax | |
module Methods | |
def find_or_create(name, *attributes, &block) | |
attributes = FactoryBot.attributes_for(name, *attributes) | |
klass = FactoryBot.factory_by_name(name).build_class | |
enums = klass.defined_enums | |
find_attributes = attributes.clone | |
find_attributes.keys.each do |key| | |
find_attributes[key] = enums[key.to_s][find_attributes[key]] if enums.has_key?(key.to_s) |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
require 'json' | |
require 'net/http' | |
# usage | |
# GoogleMapGeocoding.new.set_store | |
# class priori | |
class GoogleMapGeocoding |
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 Google Geocode API ) | |
#********************************************* | |
# | |
require 'json' | |
require 'net/http' | |
BASE_URL = "http://maps.googleapis.com/maps/api/geocode/json" |
NewerOlder