This file contains hidden or 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/env node | |
| /** | |
| * Setup android keystore | |
| * Save this script in hooks/after_paltform_add/ | |
| * And make sure it has x permission | |
| */ | |
| var exec = require('child_process').exec; | |
| var path = require('path'); |
This file contains hidden or 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
| # === Example | |
| # class User | |
| # include Mongoid::Document | |
| # extend FindupOrCreate | |
| # | |
| # field :name, type: String | |
| # field :locale, type: String | |
| # field :password,type: String | |
| # end | |
| # |
This file contains hidden or 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 RoutingMacors | |
| CRUD = { index: :get, show: :get, new: :get, edit: :get, update: :put, create: :post, destroy: :delete } | |
| def have_restful_resource *resources | |
| faked_id = Time.now.to_i.to_s | |
| options = resources.extract_options! | |
| collection_name = resources.last.to_s.pluralize | |
| ancestors = resources[0..-2].collect{|ancestor| [ancestor.to_s.pluralize, faked_id] }.join("/") | |
| actions = CRUD.keys |
This file contains hidden or 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
| zh-CN: | |
| devise: | |
| helpers: | |
| labels: | |
| username_placeholder: "用户名/手机号码/电子邮件" | |
| email_placeholder: "电子邮件" | |
| mobile_placeholder: "手机号码" | |
| password_placeholder: "密码" | |
| password_conformation_placeholder: "确认密码" |
This file contains hidden or 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 urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()) |
This file contains hidden or 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 MongoidUtils | |
| module RandomDocuments | |
| extend ActiveSupport::Concern | |
| module ClassMethods | |
| def random n = 1 | |
| skip((rand * 99999999).to_i % ([count-n, 2].max)).limit(n) | |
| end | |
| end | |
| end |
This file contains hidden or 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
| Summarizer(originalText, maxSummarySize): | |
| // 计算原始文本的词频,生成一个数组,比如[(10,'the'), (3,'language'), (8,'code')...] | |
| wordFrequences = getWordCounts(originalText) | |
| // 过滤掉停用词,数组变成[(3, 'language'), (8, 'code')...] | |
| contentWordFrequences = filtStopWords(wordFrequences) | |
| // 按照词频进行排序,数组变成['code', 'language'...] | |
| contentWordsSortbyFreq = sortByFreqThenDropFreq(contentWordFrequences) | |
| // 将文章分成句子 | |
| sentences = getSentences(originalText) | |
| // 选择关键词首先出现的句子 |
This file contains hidden or 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:webupd8team/sublime-text-2 | |
| sudo apt-get update | |
| sudo apt-get install sublime-text-2 |
This file contains hidden or 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 RandomSelector | |
| class << self | |
| def included(base) | |
| base.module_eval do | |
| def self.random n, conditions=nil | |
| criteria = conditions.is_a?(Mongoid::Criteria) ? (self.where({}).merge(conditions)) : self.where(conditions||{}) | |
| cc = criteria.count | |
| mo = [cc-n,2].max | |
| criteria.skip((rand*cc%mo).to_i).limit(n) | |
| end |
This file contains hidden or 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
| <?php | |
| /** | |
| * StringUtil | |
| * | |
| * @author mickey | |
| * @version 1.0 | |
| * @package Utility | |
| */ | |
| final class StringUtil | |
| { |