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
| require 'digest/md5' | |
| module Shorten | |
| #base32 | |
| TABLE = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z 2 3 4 6 7 8) | |
| # short('balabala') => Array | |
| # short('balabala',1) => String, Array[1] | |
| def self.short long_str, index = nil | |
| index = (0..3).to_a.include?(index) ? index : nil | |
| hash_string = Digest::MD5.hexdigest(long_str) |
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 | |
| { |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Text; | |
| namespace Mickey.Utils | |
| { | |
| /// <summary> | |
| /// 字符串编码/解码 | |
| /// </summary> | |
| public static class StringEncoder | |
| { |
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 | |
| { |
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
| 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
| 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
| 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
| 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
| zh-CN: | |
| devise: | |
| helpers: | |
| labels: | |
| username_placeholder: "用户名/手机号码/电子邮件" | |
| email_placeholder: "电子邮件" | |
| mobile_placeholder: "手机号码" | |
| password_placeholder: "密码" | |
| password_conformation_placeholder: "确认密码" |
OlderNewer