It's common in Ruby to see some code setup a Struct
like this:
class Specialized < Struct.new(:whatever)
# ... define custom methods here...
end
# Rakefile | |
begin | |
require 'bundler/setup' | |
rescue LoadError | |
puts 'You must `gem install bundler` and `bundle install` to run rake tasks' | |
end | |
require 'rdoc/task' |
fn current_branch(path: &Path) -> String { | |
let head_ref = head_ref(path); | |
println!("The ref for HEAD is {}", head_ref); | |
let r = regex!(r"refs/heads/(.+)"); | |
let caps_result = r.captures(head_ref.as_slice()); | |
let branch: String = match caps_result { | |
Some(cap) => { String::from_str(cap.at(1)) }, | |
None => { panic!("You must be somewhere on refs/heads, and you aren't") } | |
}; | |
branch |
use std::iter::iterate; | |
use std::num::Float; | |
use std::sync::Future; | |
fn main() { | |
if let Some(n) = read_uint(1) { | |
let sum_of_primes = { | |
let block_size = if n > 999 { n / 20 } else { n }; | |
let mut futures = Vec::new(); |
Inline cache type: Rubinius::MonoInlineCache | |
Hits Module Name | |
563069 Fixnum + | |
401513 Rubinius::Tuple at | |
391974 Fixnum < | |
214380 Array each | |
187879 Fixnum == | |
132183 Array [] | |
127737 Fixnum - | |
126048 Fixnum > |
ids = current_user.facebook_friends if current_user | |
@search = Profile.solr_search do | |
keywords params[:q] do | |
boost_fields name: 10.0, user: 4.0 | |
end | |
unless ids.blank? | |
adjust_solr_params do |params| | |
# See "bq (boost query)" in http://wiki.apache.org/solr/DisMaxQParserPlugin | |
params[:bq] = "facebook_id_s:(#{ids.join(' OR ')})^10" |
有人用过cell么? | |
<span style="font-size: small;"><a target="_blank" href="http://rubyforge.org/frs/?group_id=2978&release_id=9650">http://rubyforge.org/frs/?group_id=2978&release_id=9650</a> | |
<br /></span> | |
<br /><span style="font-size: small;"> </span> | |
<br /><span style="font-size: small;"> | |
<br />非常小,源代码一目了然。感觉虽然有点土,但比自己做个module的方式好一点点 | |
<br />号称: 代替发挥component作用的controller, 这样就不需要邪恶的render_component了 | |
<br /></span> | |
<br /><span style="font-size: small;">A cell acts as a lightweight controller in the sense that it will assign variables and render a view.</span> |
if [ "$(id -u)" -eq "0" ]; then | |
echo "This script should not be run as root" | |
exit 1 | |
fi | |
sudo ntpdate ntp.ubuntu.com | |
sudo apt-get install gcc -y | |
sudo apt-get install language-pack-zh-hant language-pack-zh-hans -y | |
sudo apt-get install yasm imagemagick ghostscript libsasl2-dev libmemcached-dev -y |
#! /usr/bin/env python | |
# License: http://creativecommons.org/publicdomain/zero/1.0/ | |
# See http://preshing.com/20130115/view-your-filesystem-history-using-python | |
import optparse | |
import os | |
import fnmatch | |
import time | |
# Parse options | |
parser = optparse.OptionParser(usage='Usage: %prog [options] path [path2 ...]') |