Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Springett paulspringett

View GitHub Profile
@paulspringett
paulspringett / array_focus.rb
Created Oct 26, 2012
Focus on elements in an Array
View array_focus.rb
class Array
# Public: slice Array while focusing on the given item in the array
# and padding around it
#
# item - element in the Array to focus on
# padding - Integer of the number of elements to pad by (default: 2)
#
# Examples:
# items = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t"]
#
View likes.sh
# Creating a like
curl -X POST \
http://api.rusic.com/buckets/123/ideas/456/like \
-D "like[should_post_to_social]=true" \
-H "X-API-Key: 8bca8fa86b" \
-H "X-Participant-Token: 19ba7d23ef" \
# Removing a like
curl -X DELETE \
http://api.rusic.com/buckets/123/ideas/456/like \
View hostname_regex.rb
regex = /^(([a-z0-9\-]+\.)+[a-z]{2,})$/
regex.match('example.org')
=> #<MatchData "example.org"...>
regex.match('nota-hostname')
=> nil
regex.match('sub.example.org')
=> #<MatchData "sub.example.org"...>
View instructions.md
View bumpme
Thu Jan 12 15:21:23 UTC 2017