Skip to content

Instantly share code, notes, and snippets.

View finbarr's full-sized avatar

Finbarr Taylor finbarr

View GitHub Profile
@finbarr
finbarr / gist:401c1449ad102387a4b2
Created September 5, 2014 20:16
Getting the e164 and national numbers
NSString *e164 = [self.phoneNumberField phoneNumberWithFormat:LTPhoneNumberFormatE164];
NSString *formatted = [self.phoneNumberField phoneNumberWithFormat:LTPhoneNumberFormatNATIONAL];
@finbarr
finbarr / gist:cec3c89387c3cac7d5ad
Last active August 29, 2015 14:06
Changing the region of the phone field when the country is changed
- (void)countryPicker:(CountryPicker *)picker didSelectCountryWithName:(NSString *)name code:(NSString *)code
{
// ...
self.localeField.text = [NSString stringWithFormat:@"%@ - %@", code, name];
self.phoneNumberField = [[LTPhoneNumberField alloc] initWithFrame:self.phoneNumberField.frame regionCode:code];
// ...
}
@finbarr
finbarr / gist:da00c1c0f0c3cfcf2564
Last active August 29, 2015 14:06
Setting up country picker with current locale
// localeField is a UITextField
NSString *countryCode = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];
NSString *countryName = [CountryPicker countryNamesByCode][countryCode];
self.localeField.inputView = self.countryPicker;
self.localeField.text = [NSString stringWithFormat:@"%@ - %@", countryCode, countryName];
[self.countryPicker setSelectedCountryCode:countryCode];
@finbarr
finbarr / arraysort.rb
Created July 22, 2014 18:50
Array Sort
def arraysort(array)
result = []
array.each do |a|
if result[a].nil?
result[a] = [a]
else
result[a] << a
end
end
result.compact.flatten
@finbarr
finbarr / duplicates.rb
Last active August 29, 2015 14:04
Duplicates.
require "set"
def duplicates(array)
s = Set.new
array.each_with_object([]) { |a, d| (d << a) unless s.add?(a) }
end

Keybase proof

I hereby claim:

  • I am finbarr on github.
  • I am finbarr (https://keybase.io/finbarr) on keybase.
  • I have a public key whose fingerprint is D6C7 EA10 D18F D363 1BA7 22E6 9941 D223 4F7C 7D49

To claim this, I am signing this object:

@finbarr
finbarr / pref.json
Created October 23, 2013 22:40
Sublime Text 2 Preferences
{
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 0,
"bold_folder_labels": true,
"caret_style": "wide",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
alias ll="ls -al"
alias gch="git checkout"
alias gb="git branch"
alias gs="git status"
alias gp="git pull"
alias gf="git fetch"
alias gr="git rebase"
alias gl="git log"
alias gd="git diff"
alias gdo="git diff origin/master"
@finbarr
finbarr / .gemrc
Created September 27, 2013 16:53
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
@finbarr
finbarr / git_stats.rb
Created September 27, 2013 16:49
This was a quick hack to find out the aggregate contributions of members of a git repository based on the output of `git log --shortstat`.
file_name = ARGV[0]
puts file_name
def rip_num(part)
part.split(" ").first.to_i
end
File.open(file_name) do |f|
insertions = 0