Skip to content

Instantly share code, notes, and snippets.

View knt's full-sized avatar

Nichole Treadway knt

View GitHub Profile
< if content =~ /([^-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]%)/ then
< CGI.unescape(content).gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
< else
< content.gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
< end
---
> if content.respond_to?(:force_encoding) && content.force_encoding("binary") =~ /([^-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]%)/n then
> CGI.unescape(content).gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
> else
> content.gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
@knt
knt / lololol.rb
Created September 24, 2013 22:21
# I want to write a method that returns the first number in a sub array where the letter matches a passed in letter
# If passed in letter does not exist, it should return nil
a = [["a", 1], ["b", 2]]
>> #Desired Results
>> get_number_for_letter(a, "a")
1
>> get_number_for_letter(a, "b")
2
>> get_number_for_letter(a, "c")
"People make it out to seem like women are intentionally oppressed. It reminds me of the time when chess went through the same thing.
There aren't many female grandmasters! Make them play!
I would like for people to go around asking men and women do they want to program. Don't be shocked if the results mirror the current ratio between men and women."
@knt
knt / gist:5228431
Created March 23, 2013 16:57
In .bash_profile
export GIT_PS1_SHOWDIRTYSTATE=true # '*' for unstaged changes, '+' for staged
export GIT_PS1_SHOWSTASHSTATE=true # '$' if smth is stashed
export GIT_PS1_SHOWUNTRACKEDFILES=true # '%' if un-tracked files
# GIT
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names