Skip to content

Instantly share code, notes, and snippets.

View garrettwilkin's full-sized avatar

Garrett Wilkin garrettwilkin

View GitHub Profile
@garrettwilkin
garrettwilkin / timey.py
Created October 31, 2013 03:30
This file gives me the error: $ python timey.py Traceback (most recent call last): File "timey.py", line 3, in <module> print datetime.strptime('2013-10-29T02:03:59Z','%Y-%m-%dT%H:%M:%S%z') AttributeError: 'module' object has no attribute 'strptime'
import datetime
print datetime.strptime('2013-10-29T02:03:59Z','%Y-%m-%dT%H:%M:%S%z'
@garrettwilkin
garrettwilkin / Inconsistent API status codes.
Created October 22, 2013 14:18
The first element is the resp.status_code. The JSON blob is the resp.text. This is a response object from the requests module.
$ python pings_api.py
200 /v2/analytics/posts {"message": "Forbidden", "code": 403, "success": false}
200 /v2/analytics/authors {"message": "Forbidden", "code": 403, "success": false}
200 /v2/search {"message": "missing api key", "code": 500, "success": false}
200 /v2/realtime/posts {"message": "Forbidden", "code": 403, "success": false}
200 /v2/analytics/author/Jeff%20Poor/detail {"message": "Forbidden", "code": 403, "success": false}
200 /v2/analytics/post/detail {"message": "Forbidden", "code": 403, "success": false}
200 /v2/related {"message": "missing api key", "code": 500, "success": false}
403 /v2/shares/posts {"message": "Forbidden", "code": 403, "success": false}
403 /v2/shares/authors {"message": "Forbidden", "code": 403, "success": false}
@garrettwilkin
garrettwilkin / gist:7088146
Created October 21, 2013 17:59
innerHTML fail
// Clears the recommendations div.
function clearResults() {
var recDiv = $("#recommendations");
recDiv.innerHtml = "<p>Recommendations results to appear here.</p>";
console.log('Reset.');
}
@garrettwilkin
garrettwilkin / failing at bootstrap
Last active December 25, 2015 22:09
When I click the "Fly!" button, I see the console.log output. Not so with the "Go!" button. What gives?
JS:
// Callback to populate recommendations div.
callback = function(data) {
recDiv.html("");
$.each(data.data, function(i, datum) {
var thumb = "<div class='thumb'><img src='" + datum.thumb_url_medium + "'></div>",
title = "<div class='title'>" + datum.title + "</div>"
recDiv.append("<div class='post'>"+title+thumb+"</div>");
});
@garrettwilkin
garrettwilkin / Screen cheat sheet
Created October 18, 2013 17:24
Up my screen skills.
screen -S give_the_session_a_name #starts a new session
screen -list #list session
screen -r session_name_pid_thinger # reattach
@garrettwilkin
garrettwilkin / Git workflow
Created October 18, 2013 01:26
Git steps from Raymond.
Not pushing branch
==================
1. git branch feature_name
2. git checkout feature_name
3. vim awesome_file && make awesome_changes
4. git commit --verbose awesome_file
5. git show (review changes briefly)
6. git checkout master
7. git rebase feature_name
8. git pull --rebase origin master
@garrettwilkin
garrettwilkin / Terminal
Created October 16, 2013 19:25
Gollum is hiding, even after installing and adding gem directories to my $PATH. This is mac OSX.
$ which gollum
» ~/Code/Parsely/web.wiki (web+wiki) [master]
$ gem which gollum
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/gollum-2.5.1/lib/gollum.rb
» ~/Code/Parsely/web.wiki (web+wiki) [master]
$ echo $PATH
/usr/local/bin:/usr/local/bin:/Users/gw/.virtualenvs/web+wiki/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin::/usr/local/sbin:/Users/gw/.gem/ruby/1.8::/usr/local/sbin:/Users/gw/.gem/ruby/1.8:/Users/gw/.gem/ruby/2.0.0::/usr/local/sbin:/Users/gw/.gem/ruby/1.8:/Users/gw/.gem/ruby/2.0.0:/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/
» ~/Code/Parsely/web.wiki (web+wiki) [master]
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]
@garrettwilkin
garrettwilkin / terminal output
Created October 5, 2013 15:56
Mac OSX non comprende. Seems like there is no version output option?
airy:rapid-web gw$ easy_install --version
usage: easy_install [options] requirement_or_url ...
or: easy_install --help
error: option --version not recognized
@garrettwilkin
garrettwilkin / virtualenv warning
Created October 4, 2013 19:51
Attempted installing virtualenv. I already have conda install from installing that giant Anaconda package.
gw@airy ~> pip --version
pip 1.4.1 from /Users/gw/anaconda/lib/python2.7/site-packages (python 2.7)
gw@airy ~> sudo pip install virtualenv
Password:
WARNING: using virtualenv with Anaconda is untested and not recommended.
We suggest using the conda command to create environments instead.
For more information about creating conda environments, please see:
http://docs.continuum.io/conda/examples/create.html
airy:PyCodez gw$ pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here