Skip to content

Instantly share code, notes, and snippets.

View rubyonrailsworks's full-sized avatar

RubyonRailsWorks rubyonrailsworks

  • Shanghai,China
View GitHub Profile
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/
// 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?
@rubyonrailsworks
rubyonrailsworks / 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
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;");
@rubyonrailsworks
rubyonrailsworks / 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
```shell
#101 A State Capitals Quiz
#Once you have a tool for choosing a line randomly from a file, as we have with Script #76, Displaying Random Text, there's no limit to the type of quiz games you can write. In this instance, I've pulled #together a list of the capitals of all 50 states in the United States of America; this script randomly chooses one, shows the state, and asks the user to type in the matching capital.
#The Code
#!/bin/sh
# states - A state capital guessing game. Requires the state capitals
# data file at http://www.intuitive.com/wicked/examples/state.capitals.txt.
@rubyonrailsworks
rubyonrailsworks / gfm.rb
Created November 27, 2011 15:22 — forked from mojombo/gfm.rb
highlighting
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
class TestHighLighting
def code
end
end
@rubyonrailsworks
rubyonrailsworks / gist_tag.rb
Created November 27, 2011 15:38 — forked from imathis/gist_tag.rb
A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers.
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
@rubyonrailsworks
rubyonrailsworks / alias
Created November 28, 2011 12:07
Sh配置文件
alias ls='ls --color=auto'