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
#1. The first Test | |
#The command is, | |
#rails g migration AddPermalinkToPosts permalink:string:uniq | |
#In the migration file that just generated, I will add some code, then the migration file should be, | |
class AddPermalinkToPosts < ActiveRecord::Migration | |
def change | |
add_column :posts, :permalink, :string | |
add_index :posts, :permalink, unique: true | |
Post.select("id,title").each do |post| |
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
describe "Admin see company list" do | |
subject {page} | |
describe "when there are no companies" do | |
before do | |
@admin = FactoryGirl.create(:developer_admin) | |
admin_login(@admin) | |
end | |
it "displays an empty company list" do |
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 gem 'ruby-mp3info' | |
require "mp3info" | |
dir_root = "/Users/keating/Music/EnglishPod 1-50/" | |
d = Dir.new(dir_root) | |
flags = ('A'..'Z').to_a | |
d.each do |dir_name| | |
next if ['.', '..', '.DS_Store'].include?(dir_name) | |
if File.directory?(dir_root + dir_name) | |
dir = Dir.new(dir_root + dir_name) |
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
import java.util.ArrayList; | |
import java.util.List; | |
import com.beiyanght.utils.dto.DtoException; | |
import com.beiyanght.utils.dto.DtoHelper; | |
/** | |
* | |
* @author keating_andy_given | |
*/ |
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
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.OutputStreamWriter; | |
/** | |
* some helpers for file operation |
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
import javax.swing.JDialog; | |
import javax.swing.JFrame; | |
import javax.swing.JTable; | |
import javax.swing.UIManager; | |
import javax.swing.UnsupportedLookAndFeelException; | |
import javax.swing.table.TableColumnModel; | |
/** | |
* Swing helper for column of JTable | |
* @author keating_andy_given |
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
import java.text.DateFormat; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
/** | |
* some helpers for java.util.Date | |
* @author keating_andy_given | |
* | |
*/ |
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
import com.beiyanght.masterdata.common.exception.DataNotFoundException; | |
/** | |
* helpers for String | |
* | |
* @author keating_andy_given | |
*/ | |
public class StringHelp { | |
private enum Flag{ |
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
import static com.beiyanght.jpa.ThreadLocalEntityManager.em; | |
import java.math.BigDecimal; | |
/** | |
* | |
* @author keating_andy_given | |
*/ | |
public class SequenceHelp { | |
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
#!/usr/bin/ruby | |
require 'rss' | |
p 'Downloading rss index' | |
rss_string = open('http://feeds.feedburner.com/railscasts').read | |
rss = RSS::Parser.parse(rss_string, false) | |
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse | |
videos_filenames = videos_urls.map {|url| url.split('/').last } |
OlderNewer