⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
This file contains 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 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.854.0 Safari/535.2" | |
html = "http://www.somedomain.com/somepage/" | |
@doc = Nokogiri::HTML(open(html, 'User-Agent' => user_agent), nil, "UTF-8") | |
@doc.xpath("//li[a[text()='Home']]/following-sibling::li").each do |link| |
This file contains 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
#change some specific application's interface language | |
defaults write com.google.Chrome AppleLanguages "(zh_CN,en_US)" | |
defaults write com.apple.iWork.Pages AppleLanguages "(zh_CN,en_US)" | |
defaults write com.apple.Aperture AppleLanguages "(zh_CN,en_US)" | |
#change all applications' interface language, don't recommend. | |
defaults write NSGlobalDomain AppleLanguages "(en_US,zh_CN)" | |
defaults write NSGlobalDomain AppleLanguages "(zh_CN,en_US)" |
This file contains 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
alias server='open http://localhost:8000 && python -m SimpleHTTPServer' |
This file contains 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
#config/initializers/mime_types.rb | |
Mime::Type.register_alias "text/html", :iphone | |
#Make a copy of app/views/layouts/application.html.erb calling it application.iphone.erb | |
#Make copies of the necessary view files in your controllers, calling them things like index.iphone.erb | |
#in Controller | |
respond_to :html, :iphone |
This file contains 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 sublime, sublime_plugin | |
import os | |
class DetectFileTypeCommand(sublime_plugin.EventListener): | |
""" Detects current file type if the file's extension isn't conclusive """ | |
""" Modified for Ruby on Rails and Sublime Text 2 """ | |
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """ | |
def on_load(self, view): | |
filename = view.file_name() |
This file contains 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 java.util.concurrent.atomic.AtomicLong; | |
import java.util.concurrent.locks.ReentrantLock; | |
public class LockVsAtomic { | |
protected final ReentrantLock lock = new ReentrantLock(); | |
private volatile long l1 = 0l; | |
private AtomicLong l2 = new AtomicLong(0l); |
This file contains 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
find . -name '*.java' ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \; |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<include resource="org/springframework/boot/logging/logback/base.xml"/> | |
<appender name="ErrorOnlyConsole" class="ch.qos.logback.core.ConsoleAppender"> | |
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | |
<level>ERROR</level> | |
</filter> | |
<encoder> | |
<pattern>${CONSOLE_LOG_PATTERN}</pattern> |