Skip to content

Instantly share code, notes, and snippets.

View geekontheway's full-sized avatar

geekontheway geekontheway

  • Shanghai,China
View GitHub Profile
@geekontheway
geekontheway / gpa.rb
Created October 4, 2014 15:07
绩点算法
# 学分,成绩,绩点,5分制
arr = [[2, 90, 4], [1, 99, 4.9], [2, 96, 4.6], [1, 80, 3], [2, 86, 3.6], [2, 90, 4], [1, 92, 4.2], [2, 82, 3.2], [2, 88, 3.8], [3, 96, 4.6], [3, 96, 4.6], [2.5, 90, 4.0], [2.5, 100, 5], [2.5, 90, 4], [2.5, 93, 4.3], [1.5, 94, 4.4], [2, 96, 4.6], [2, 89, 3.9], [3, 87, 3.7], [3.5, 99, 4.9], [3, 91, 4.1], [3, 99, 4.9], [5, 96, 4.6], [5, 86, 3.6], [5, 90, 4], [3, 96, 4.6], [3.5, 96, 4.6], [3, 87, 3.7], [3, 95, 4.5], [3.5, 98, 4.8], [6, 80, 3], [5, 92, 4.2], [5, 93, 4.3], [3.5, 94, 4.4], [3, 94, 4.4], [3, 90, 4], [3, 98, 4.8], [3, 88, 3.8], [3, 85, 3.5], [3, 83, 3.3], [2, 79, 2.9], [2, 84, 3.4], [3, 89, 3.9], [3, 85, 3.5], [3, 84, 3.4], [3, 86, 3.6], [3, 82, 3.2], [2, 80, 3], [1, 97, 4.7], [2, 66, 1.6], [6, 94, 4.4], [1, 98, 4.8], [1, 81, 3.1], [1, 90, 4], [1, 90, 4], [1, 89, 3.9], [1, 84.9, 3.4], [1, 89.6, 3.9]]
arr.each do |sub|
alls+= sub[0]*sub[2]
allv+=sub[0]
end
gpa = alls/allv
@geekontheway
geekontheway / 0_reuse_code.js
Created June 13, 2014 16:38
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
function consoleTrick() {
console.clear();
var rainbowStyle = 'background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) );color:transparent;-webkit-background-clip: text;font-size:2em;';
var msg = "来自博主的问候:欢迎来访,美图奉上 \\(^____^)/";
console.log("%c", "padding:50px 300px;line-height:120px;background:url('http://wayouliu.duapp.com/img/tagsImg/youth.gif') no-repeat;");
console.log('%c' + msg, rainbowStyle);
var picNo = getRandomInt(1, 16);
console.log("Print out the " + picNo + "th image.");
console.log("%c", "padding:165px 150px;line-height:350px;background:url('http://wayouliu.duapp.com/img/tagsImg/" + picNo + ".jpg') no-repeat;");
console.log("%c 试试F5刷新", "color:green;");
@geekontheway
geekontheway / GetCityName.vb
Last active August 29, 2015 13:57
VBA FOR RACHEL
Function GETCITYNAME(district As Range, cities As Range) As String
Dim X As Range
For Each X In cities
If InStr(1, district.Value, X.Value) > 0 Then
GETCITYNAME = X.Value
Exit For
End If
Next X
End Function
// 1. How to check if one array has all elements of another?
var importedEmails = ['john@doe.com', 'janet@doe.com'],
existingEmails = ['john@doe.com', 'janet@doe.com', 'fred@mercury.com'];
if(!_.difference(importedEmails, existingEmails).length) console.log('already imported')
// > already imported
// **********************************************************
// 2. How to find what elements are common to two arrays?
curl -L https://www.atom.io/api/updates/download -A "Atom/0.1 CFNetwork/1.5" > Atom.zip
unzip Atom.zip
mv Atom.app /Applications/
gem 'will_paginate'
@geekontheway
geekontheway / location.log
Last active December 27, 2015 22:18
Weixin
Started POST "/api/service?id=MTAwMDE=&signature=e9a66c8c14c88925e45dc2df11d066c34c415bd2&timestamp=1384088325&nonce=1383278484" for 101.226.33.171 at 2013-11-10 20:58:45 +0800
Processing by ApiController#service as */*
Parameters: {"xml"=>{"ToUserName"=>"gh_db4ac511bbf0", "FromUserName"=>"oZmj5jjRYwr_OkYovPdvF4ZdWcUo", "CreateTime"=>"1384088325", "MsgType"=>"text", "Content"=>"附近酒店", "MsgId"=>"5944614090650424067"}, "id"=>"MTAwMDE=", "signature"=>"e9a66c8c14c88925e45dc2df11d066c34c415bd2", "timestamp"=>"1384088325", "nonce"=>"1383278484"}
WARNING: Can't verify CSRF token authenticity
Supplier Load (2.0ms) SELECT `suppliers`.* FROM `suppliers` WHERE `suppliers`.`id` IS NULL LIMIT 1
WxMpUser Load (1.9ms) SELECT `wx_mp_users`.* FROM `wx_mp_users` WHERE `wx_mp_users`.`id` = 10001 AND (wx_mp_users.status = 1) LIMIT 1
(0.1ms) BEGIN
SQL (0.7ms) INSERT INTO `wx_messages` (`create_time`, `created_at`, `metadata`, `msg_type`, `updated_at`, `wx_mp_user_uid`, `wx_user_uid`) VALUES ('2013-11-10 20:58:45',

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@geekontheway
geekontheway / ReceiptAdd.xml
Last active December 20, 2015 20:29
GQS 接口测试规划
<DATA><RECEIPT><HEADER><RECEIPTID>20130628164206DC8</RECEIPTID><RECEIPTDATE>2013-06-27 16:39</RECEIPTDATE><ORDERTYPE>STD</ORDERTYPE><POID>20130628164206DC8</POID><TOTALPIECESQTY>40</TOTALPIECESQTY></HEADER><DETAIL><ITEMID></ITEMID><STATUSID>1</STATUSID><DESCR>瑞莱 褪黑素片3MG 60片</DESCR><QTYRECEIVED>1</QTYRECEIVED><QTY>1</QTY><UNITPRICE>101.15</UNITPRICE></DETAIL><DETAIL><ITEMID></ITEMID><STATUSID>1</STATUSID><DESCR>买一送一促销 瑞莱 ASF褪黑素春黄菊复合胶囊</DESCR><QTYRECEIVED>1</QTYRECEIVED><QTY>1</QTY><UNITPRICE>299.0</UNITPRICE></DETAIL><DETAIL><ITEMID></ITEMID><STATUSID>1</STATUSID><DESCR>两件75折特惠装 瑞莱 甲壳素 90粒</DESCR><QTYRECEIVED>1</QTYRECEIVED><QTY>1</QTY><UNITPRICE>403.5</UNITPRICE></DETAIL><DETAIL><ITEMID></ITEMID><STATUSID>1</STATUSID><DESCR>两件75折特惠装 瑞莱 左旋肉碱胶囊 600mg 30&amp;lsquo;s</DESCR><QTYRECEIVED>1</QTYRECEIVED><QTY>1</QTY><UNITPRICE>448.5</UNITPRICE></DETAIL><DETAIL><ITEMID></ITEMID><STATUSID>1</STATUSID><DESCR>瑞莱 左旋肉碱覆盆子复合胶囊 60粒</DESCR><QTYRECEIVED>1</QTYRECEIVED><QTY>1</QTY><UNITPRICE>305.15</UNITPRICE></DETAIL><DETA