Skip to content

Instantly share code, notes, and snippets.

View smalleel's full-sized avatar

Lee Ball smalleel

  • Google
View GitHub Profile
from random import randint
def shuffle(array):
"""Implementation of a Fisher-Yates shuffle."""
for item in array:
curr_index = array.index(item)
rand_index = randint(array.index(item), len(array) - 1)
array[curr_index], array[rand_index] = array[rand_index], array[curr_index]
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
Makefile creation failed
**************************************************************************
No source for ruby-2.0.0-p648 provided with debugger-ruby_core_source gem.
@smalleel
smalleel / wiki.py
Last active January 27, 2018 03:49
#!/usr/bin/env python3
"""
When this script is called, it tweets "Someone wants to fuck (Wikipedia article title)".
Crontab: 0,30 * * * * /usr/bin/python3 /home/pi/bots/wiki.py
Demo: https://twitter.com/wikifuckbot
"""
import tweepy
import wikipedia
#!/usr/bin/env python3
"""
Compares the length of two random wikipedia articles, then tweets the result.
Crontab: 10,40 * * * * /usr/bin/python3 /home/pi/bots/wikicompare.py
Demo: https://twitter.com/wikicomparebot
Concept: @mcclure111
Implementation: @C_L_Ball
"""
@smalleel
smalleel / percent-through-year.js
Created March 29, 2017 07:09
Calculate how far you are in the year as a percent.
// See me run at: https://jsfiddle.net/catleeball/yhuars47/2/
// Based on: http://stackoverflow.com/a/26426761/2873090
Date.prototype.isLeapYear = function() {
var year = this.getFullYear();
if ((year & 3) != 0) return false;
return ((year % 100) != 0 || (year % 400) == 0);
};
Date.prototype.getDOY = function() {
@smalleel
smalleel / pasteWithKeystrokes.au3
Created September 29, 2017 20:08
pasteWithKeystrokes
#include <Misc.au3>
; via https://stackoverflow.com/questions/7936831/convert-clipboard-to-keystroke
HotKeySet("^v","ClipboardToKeystroke")
While 1
Sleep(30) ; If you forget this, your program takes up max CPU
WEnd
Func ClipboardToKeystroke()
@smalleel
smalleel / typeClipboard.ahk
Created October 1, 2017 06:34
Type clipboard contents
^+v::SendRaw %clipboard%
#!/usr/bin/env python3
"""
Iterates over CSV of grocery data, tweeting each row
Crontab: 0,15,30,45 * * * * /usr/bin/python3 /home/cat/bots/UPC_bot.py
"""
import sys
import tweepy
import linecache