Regular expressions in Sublime Text 2 only seach single lines by default. You can force them to search all lines with an inline search modifier:
(?s)
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
# From: | |
# https://stackoverflow.com/questions/88311/how-best-to-generate-a-random-string-in-ruby | |
#Generates a random URL-safe key/token much faster than UUID | |
#Comes with additional risk for high integrity keys, but for many cases it's good enough. | |
#I'm using it to generate unique file names without the overhead of UUID. | |
#Occasionally returns a key of length-1 | |
length = 5 | |
p rand(36**length).to_s(36) |
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
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE |
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
#index capture groups: | |
url = "https://gist.github.com/ryancastro/whatever.git" | |
p url[/(.*)\/whatever.git/, 1] | |
p url.gsub(/(.*)\/whatever.git/, '\1') | |
#named capture groups: | |
url = "https://gist.github.com/ryancastro/whatever.git" | |
p url[/(?<url>.*)\/whatever.git/, "url"] | |
p url.gsub(/(?<url>.*)\/whatever.git/, '\k<url>') |
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
def speak sentence | |
sentence = sentence.gsub /'/, "''" | |
`powershell.exe -c $speaker = new-object -com SAPI.SpVoice; $speaker.Speak('#{sentence}');` | |
end | |
speak "Hello." |
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
// Load Facebook's mobile activity log | |
// https://m.facebook.com/#{you}/allactivity?log_filter=all | |
// loads jQuery into Facebook | |
var jq = document.createElement('script'); | |
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
// wait for jQuery to load up. | |
setTimeout(removeIt, 2000); |
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
def stuff(things) | |
things.each do |command| | |
puts "I am executing this command: #{command.strip}\n" | |
end | |
end | |
stuff(ARGV.join(" ").split(",")) | |
# cmd: test argument1, argument2, argument 3 things, argument 4 | |
# I am executing this command: argument1 | |
# I am executing this command: argument2 |
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
#'compiled' with Ocra | |
require 'win32ole' | |
@wsh = WIN32OLE.new('Wscript.Shell') | |
@title1, @title1_seconds, @title2, @title2_seconds = ARGV | |
if !@title2_seconds | |
puts "usage: window1_title seconds window2_title seconds" | |
puts "ex: Skype 10 Untitled 5" | |
puts "note: you only need to match the first letters in the window title." | |
puts "'Untitled' will find the 'Untitled - Notepad' window" |
Here's a little tutorial in Ruby sockets.
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
def isInt?(number) | |
true if Integer(number) rescue false | |
end | |
isInt?("13") | |
result = true if Integer("12") rescue false # true | |
result = true if Integer("test") rescue false #false | |
result = true if Float("test") rescue false #false | |
result = true if Float(13.2) rescue false #true |
NewerOlder