$ cat lolruby.rb
# encoding: utf-8
puts Encoding.default_internal
puts Encoding.default_external
Encoding.default_internal = "UTF-8"
Encoding.default_external = "UTF-8"
puts Encoding.default_internal
puts Encoding.default_external
puts 1.to_s.encoding
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
$ whois microsoft.com | |
Whois Server Version 2.0 | |
Domain names in the .com and .net domains can now be registered | |
with many different competing registrars. Go to http://www.internic.net | |
for detailed information. | |
MICROSOFT.COM.ZZZZZZZZZZZZZZZZZZZZZZ.IS.A.GREAT.COMPANY.ITREBAL.COM | |
MICROSOFT.COM.ZZZZZZZZZZZZZZZZZZZ.GET.ONE.MILLION.DOLLARS.AT.WWW.UNIMUNDI.COM |
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
# app/controllers/users/password_controller.rb | |
class Users::PasswordsController < Devise::PasswordsController | |
def resource_params | |
params.require(:user).permit(:email, :password, :password_confirmation) | |
end | |
private :resource_params | |
end |
Locate the section for your github remote in the .git/config
file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
$ mkdir lol_DS
$ cd lol_DS
$ git init
# => Initialized empty Git repository in /private/tmp/lol_DS/.git
$ touch README
$ git add README
$ git commit -m 'Initial commit'
$ touch .DS_Store
$ git add .DS_Store
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
class Awesome | |
def initialize(hello, &block) | |
yield hello | |
end | |
end | |
str = 'hi tom' | |
Awesome.new(str) do |hio| | |
puts hio | |
end |
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
In Ruby 1.9.2 to escape XML special characters in Strings, use the 'encode' method. | |
Example, if you have: | |
my_string = 'this is "my" complicated <String>' | |
For XML attributes use: | |
"<node attr=#{my_string.encode(:xml => :attr)} />" | |
Generates: |
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
File.open("vorlage_iso.tex", 'w') do |f| | |
File.open("vorlage_utf8.tex", "r:iso-8859-1:utf-8").each_line do |l| | |
f.puts l.force_encoding 'utf-8' | |
end | |
end |
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
#!/bin/bash | |
# | |
# this script adds a comment with the current build status to a commit on github | |
# | |
# you have to set the environment variable $GH_TOKEN with your github oauth token, | |
# $JANKY_SHA1 will be set by janky. | |
# | |
# run: `./jenkins_github_comment.sh 0 user/repository` for a passing build and | |
# `./jenkins_github_comment.sh 1 user/repository` for a failing build |
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
# slight modification of the example 'Creating Partial Mocks' from http://flexmock.rubyforge.org/ | |
require 'test/unit' | |
require 'flexmock/test_unit' | |
class Woofer | |
def woof | |
'miau' | |
end | |
end |