Skip to content

Instantly share code, notes, and snippets.

View mattantonelli's full-sized avatar

Matt Antonelli mattantonelli

  • 04:08 (UTC -04:00)
View GitHub Profile
@mattantonelli
mattantonelli / gist:4ee3a3ddca0dc1ae2f6f
Last active August 29, 2015 14:19
Singapore Math Problem
Albert knows the month. Bernard knows the day.
May 15 May 16 May 19
Jun 17 Jun 18
Jul 14 Jul 16
Aug 14 Aug 15 Aug 17
Albert does not know the date because all months have more than one day. Albert knows that Bernard
cannot know the date. Therefore, Albert knows that the month contains no uniquely identifying days.
@mattantonelli
mattantonelli / count_occurences.rb
Last active May 21, 2017 20:25
Count the occurrences of each element in an array.
>> a = ['a', 'a', 'b', 'c', 'c', 'c', 'd', 'd', 'e', 'f']
=> ["a", "a", "b", "c", "c", "c", "d", "d", "e", "f"]
>> a.each_with_object(Hash.new(0)) { |x, h| h[x] += 1 }
=> {"a"=>2, "b"=>1, "c"=>3, "d"=>2, "e"=>1, "f"=>1}
@mattantonelli
mattantonelli / lodestone_api.rb
Last active August 29, 2015 14:21
Ruby API for parsing FFXIV Lodestone
#!/usr/bin/env ruby
# encoding: utf-8
require 'nokogiri'
require 'open-uri'
require 'json'
module LodestoneApi
CHARACTER_URL = 'http://na.finalfantasyxiv.com/lodestone/character'
@mattantonelli
mattantonelli / install_rbenv.sh
Last active August 29, 2015 14:21
How to install rbenv on CentOS
# If you are not using bash, you should take care to append the echo
# lines below to the appropriate shell_profile
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
exec $SHELL -l
" turn on left and right in command mode
nnoremap <Left> <Left>
nnoremap <Right> <Right>
" turn on arrow keys in insert mode
inoremap <Left> <Left>
inoremap <Down> <Down>
inoremap <Up> <Up>
inoremap <Right> <Right>
@mattantonelli
mattantonelli / soundcloud_pitch_black.css
Last active December 10, 2015 15:46
Pitch Black Stylish theme for Soundcloud with some personal color tweaks. Functional as of 12/9/15.
@namespace url(http://www.w3.org/1999/xhtml);
/*** GENERAL ***/
html, .social-sign-in-separator span, .readMoreBadge__countWrapper {
background: #000 !important}
body, .site, .dashbox, .listenContent__inner, .sound__soundActions, .l-footer, .activity__sharingNote-container, .commentForm, .commentForm__inputWrapper, .createPlaylist:hover, .createPlaylist.focused, .uploadStatus, .activeUpload__section, .activeUpload__quietTeaser, .activeUpload__blockTable.threeCell, .autoTagger__fields, .sc-background-light, .addToPlaylistTabs .tabs__tabs, .g-modal-section, .addToPlaylistItem__actions, .createPlaylistSuggestion__addContainer, .conversation__actions, .conversation__form, .inbox__item:before, .inboxItem.active, .inboxItem:hover, .g-form-section.highlight:hover, .advancedFields__quietTeaser, .sharePanel .tabs__tabs, .embedPanel__tabLink, .manageSounds__upsellWrapper, .uploadMain__foot, .searchTitle__content {
background: transparent !important}
.commentForm, .commentForm__inputWrapper, .sc-button-group, .
@mattantonelli
mattantonelli / binary_tree_checker.rb
Created August 21, 2015 18:03
Checks if a binary tree's children all contain 2 nodes (except the last level.)
#!/usr/bin/env ruby
# encoding: utf-8
# Task: You are given number of nodes (n) in a binary tree.
# You have to tell whether it is possible having a tree with given number of nodes
# such that all nodes at all levels have 2 children (except the last level).
num_nodes = ARGV[0].to_i
total = 0
row = 0
[user]
email = guy@example.com
name = That Guy
[push]
default = matching
[alias]
tree = log --graph --decorate --pretty=oneline --abbrev-commit
[hub]
protocol = https
[core]
@mattantonelli
mattantonelli / .bashrc
Created August 26, 2015 12:06
rbenv .bashrc
# add this to your .bashrc (or whatever is appropriate for your shell flavor of preference) to
# automatically set up rbenv when a new session is started
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
@mattantonelli
mattantonelli / remove_atom_context.reg
Created August 26, 2015 17:23
Removes Atom from the context menu in Windows.
Windows Registry Editor Version 5.00
; Removes 'Open in Atom' from the context menu.
; windows-context-menu
[-HKEY_CLASSES_ROOT\*\shell\Open File in Atom]
[-HKEY_CLASSES_ROOT\Directory\shell\Open Folder in Atom]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\Open Folder in Atom]
[-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Open Folder in Atom]