Skip to content

Instantly share code, notes, and snippets.

View mrsweaters's full-sized avatar
🥜

Jordan Humphreys mrsweaters

🥜
View GitHub Profile
@mrsweaters
mrsweaters / line.js
Created May 21, 2014 21:28
Custom Pizza Line Labels
$.extend(Pizza, {
line : function (legend) {
var settings = legend.data('settings'),
svg = this.svg(legend, settings),
container = $(this.identifier(legend)),
width = container.outerWidth(),
height = container.outerHeight(),
data = legend.data('graph-data'),
max_x = max_y = min_x = min_y = total_x = total_y = 0,
i = data.length,
@mrsweaters
mrsweaters / gist:761e87a55bab02a6a5a0
Created June 13, 2014 21:05
Update Collation in MySQL
mysql> show table status;
```
+----------+--------+-------------------+ ..
| Name | Engine | Collation | ..
+----------+--------+-------------------+ ..
| my_table | InnoDB | latin1_swedish_ci | ..
```
Therefore I altered the character set of the table directly:
@mrsweaters
mrsweaters / calendar.html.erb
Last active August 29, 2015 14:03
rub calendar
<ul class="large-block-grid-7">
<% month = (params[:month] || Date.today.month).to_i %>
<% first_day_of_week = DateTime.new(2014, month, 01).strftime('%w').to_i.times.each do |i| %>
<li>blank</li>
<% end %>
<% Time.days_in_month(month, 2014).times.each do |i| %>
<li><%= Date.new(2014, month, 01) + i.day %>
<% end %>
</ul>
@mrsweaters
mrsweaters / ruby_class_fun.rb
Last active August 29, 2015 14:03
Ruby Classe Stuff
names = []
@topics.each do |topic|
names << topic.name
end
names
names = @topics.map do |topic|
topic.name
end
@mrsweaters
mrsweaters / iframe.html
Created July 1, 2014 16:25
Video Embed
<iframe src="//fast.wistia.net/embed/iframe/qnr7gv5l8i?videoFoam=true" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="720" height="405"></iframe><script src="//fast.wistia.net/assets/external/iframe-api-v1.js"></script>
@mrsweaters
mrsweaters / remove.sh
Created July 3, 2014 21:08
unbuntu remove files older than X days
find /path/to/files* -mtime +5 -exec rm {} \;
# five represents the number of days.
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
import math
import Image
import Levenshtein
class BWImageCompare(object):
"""Compares two images (b/w)."""
_pixel = 255
@mrsweaters
mrsweaters / git.sh
Last active August 29, 2015 14:04
delete all local branches
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
or
git branch --merged master | grep -v 'master$' | xargs git branch -d
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
end
def pbpaste
`pbpaste`
end