Skip to content

Instantly share code, notes, and snippets.

View coffeejunk's full-sized avatar
:shipit:

Maximilian Haack coffeejunk

:shipit:
View GitHub Profile
@coffeejunk
coffeejunk / whois-ms.txt
Last active December 20, 2015 23:49
whois microsoft.com
$ 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
# 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
$ 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
@coffeejunk
coffeejunk / pr.md
Created January 12, 2013 12:04 — forked from piscisaureus/pr.md

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
class Awesome
def initialize(hello, &block)
yield hello
end
end
str = 'hi tom'
Awesome.new(str) do |hio|
puts hio
end
@coffeejunk
coffeejunk / gist:3827905
Created October 3, 2012 16:10
ruby string for xml
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:
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
#!/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
@coffeejunk
coffeejunk / test_dog_barking.rb
Created April 12, 2012 16:15
flexmock error when mocking methods created by method_missing & respond_to_missing?
# 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