underlines in between digits will be dropped.
1_234_567
oct numbers have a 0o prefix, so that number parsing won't make mistakes on numbers that start with 0
| # enable the template engine shortcuts | |
| Slim::Engine.set_options shortcut: {'&' => {tag: 'input', attr: 'type'}, '#' => {attr: 'id'}, '.' => {attr: 'class'}}, sort_attrs: false | |
| # enable stimulus shortcuts: | |
| # - @controller="foo" | |
| # - @target="bar" | |
| # - @click...="#action" | |
| module Slim | |
| class Parser |
| PokerHand = Struct.new :player, :cards | |
| class PokerHand | |
| Card = Struct.new :name, :value, :suit | |
| class Card | |
| def initialize name | |
| super name, '23456789TJQKA'.index(name[0]), name[1] | |
| end | |
| def <=> other | |
| value <=> other.value |
| // run: cscript a.js | |
| inFile = "C:\\Users\\z\\Desktop\\1.xlsx" | |
| inSheet = 1 | |
| outFile = "C:\\Users\\z\\Desktop\\2.xlsx" | |
| outSheet = 1 | |
| brandCol = 10 // J 列品牌 | |
| tradeCol = 12 // L 列行业 | |
| subCatCol = 13 // M 列子类 |
| # http://zh.wikipedia.org/wiki/中文数字 | |
| # http://china.younosuke.com/03_013.html | |
| module ChineseNum | |
| extend self | |
| UPPER_ZERO = '零' | |
| LOWER_ZERO = '〇' | |
| UPPER_DIGITS = %w[壹 贰 叁 肆 伍 陆 柒 捌 玖].unshift nil | |
| LOWER_DIGITS = %w[一 二 三 四 五 六 七 八 九].unshift nil |
| # generate a regexp for match full-width characters | |
| # data from | |
| # | |
| # A ; Ambiguous 不确定 | |
| # F ; Fullwidth 全宽 | |
| # H ; Halfwidth 半宽 | |
| # N ; Neutral 中性 | |
| # Na ; Narrow 窄 | |
| # W ; Wide 宽 | |
| # |
| def cn_id_verify id, gender=nil | |
| return false if id !~ /\A\d{17}[\dX]\z/i | |
| r = 0 | |
| x = 1 | |
| id.chars.take(17).reverse_each {|a| | |
| x = (x * 2) % 11 | |
| r += a.to_i * x | |
| } | |
| last = (12 - r % 11) | |
| last = 'X' if last == 10 |
| # need to install ghostscript first | |
| pdf-shrink() { | |
| if [[ -e $1 ]]; then | |
| gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$2 $1 | |
| else | |
| echo 'usage: pdf-shrink in.pdf out.pdf' | |
| fi | |
| } |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |