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
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get update | |
sudo apt-get install gcc-4.9 g++-4.9 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 |
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
Calculating ------------------------------------- | |
project_guest_rules without method cache | |
79.352k i/100ms | |
project_guest_rules with method cache | |
93.634k i/100ms | |
------------------------------------------------- | |
project_guest_rules without method cache | |
2.865M (±32.5%) i/s - 11.982M | |
project_guest_rules with method cache | |
4.419M (± 7.4%) i/s - 22.004M |
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
# config/initializes/0_custom_extends.rb | |
# 让 Rails Autoload Path 载入 lib/custom 里面的内容 | |
# 让 lib/custom/uploaders 里面的东西优先级更高 | |
ActiveSupport::Dependencies.autoload_paths.delete("#{Rails.root}/app/uploaders") | |
ActiveSupport::Dependencies.autoload_paths.delete("#{Rails.root}/app/models") | |
ActiveSupport::Dependencies.autoload_paths += %W( | |
#{Rails.root}/lib/custom/models | |
#{Rails.root}/lib/custom/models/hooks | |
#{Rails.root}/lib/custom/models/concerns | |
#{Rails.root}/app/models |
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 'active_support/all' | |
class Foo | |
def foo | |
bar | |
puts "foo" | |
end | |
private | |
def bar |
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
# sprockets-rails/test/test_railtie.rb | |
def test_benchmark_assets_tag | |
app.configure do | |
config.assets.paths << FIXTURES_PATH | |
config.assets.precompile += ["bar.js", "bar.css"] | |
end | |
app.initialize! | |
require 'benchmark/ips' |
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
class Libeasy < Formula | |
homepage "http://gitlab.alibaba-inc.com/zicheng.lhs/libeasy" | |
head "http://gitlab.alibaba-inc.com/zicheng.lhs/libeasy.git" | |
version "1.0.3" | |
depends_on "libtool" => :build | |
depends_on "automake" => :build | |
depends_on "autoconf" => :build | |
def install |
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.xml.bind.DatatypeConverter; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
// 用于将 GPS 的坐标格式转成浮点数 | |
// 如 DMSToDecimal.convert("N 30d17m27.786712646484375s") => 30.282034 | |
public class DMSToDecimal { | |
private static final String REGEXP = "(N|E|W|S)([\\.\\d\\s]+)d([\\.\\d\\s]+)m([\\.\\d\\s]+)s"; | |
private static double dmsToDecimal(String hemisphereOUmeridien,double degres,double minutes,double secondes){ |
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
URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}i | |
def asset_path(source, options = {}) | |
source = source.to_s | |
return "" unless source.present? | |
return source if source =~ URI_REGEXP | |
tail = source[/([\?#].+)$/] || '' | |
source.chomp!(tail) | |
if extname = compute_asset_extname(source, options) |
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
Calculating ------------------------------------- | |
str.start_with? 78491 i/100ms | |
str[0] == '/' 66410 i/100ms | |
------------------------------------------------- | |
str.start_with? 3663514.9 (±7.8%) i/s - 18209912 in 5.002869s | |
str[0] == '/' 2905683.6 (±7.6%) i/s - 14477380 in 5.011908s | |
Comparison: | |
str.start_with?: 3663514.9 i/s | |
str[0] == '/': 2905683.6 i/s - 1.26x slower |
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
task :test_string_freeze_vs_nofreeze do | |
str = "this is a example string" | |
Benchmark.ips do |x| | |
x.report("no_freeze") { | |
str.index("example") | |
} | |
x.report("freeze") { | |
str.index("example".freeze) | |
} |