Skip to content

Instantly share code, notes, and snippets.

@ollieglass
ollieglass / artsy.css
Created Jan 21, 2021
Custom stylesheet for artsy.net
View artsy.css
[class^="Lightbox__DeepZoomContainer"] > [class^="Box-sc"] {
display:none;
}
header {
display:none;
}
@ollieglass
ollieglass / gist:d1f5a6766544e9d3f42dc44c8c331aef
Created Aug 15, 2018
Sainsbury's Bank Credit Card transaction view to CSV (almost)
View gist:d1f5a6766544e9d3f42dc44c8c331aef
$('tr.no-transaction-details.card').each(function(i, e) {
var $e = $(e);
var s = [$e.find("td[data-coltype='date']").text(),
$.trim( $e.find("td[data-coltype='description']").text() ),
$.trim( $e.find("td[data-coltype='amount']").text() )
];
s = s.join(',');
console.log(s);
})
@ollieglass
ollieglass / python
Created Nov 8, 2016
Increase open file limit
View python
import platform
if platform.system() == 'Windows':
import win32file
win32file._setmaxstdio(2048)
@ollieglass
ollieglass / kelly_colors.py
Last active Aug 10, 2021
Kenneth Kelly's 22 colors of maximum contrast
View kelly_colors.py
# theory - https://eleanormaclure.files.wordpress.com/2011/03/colour-coding.pdf (page 5)
# kelly's colors - https://i.kinja-img.com/gawker-media/image/upload/1015680494325093012.JPG
# hex values - http://hackerspace.kinja.com/iscc-nbs-number-hex-r-g-b-263-f2f3f4-242-243-244-267-22-1665795040
kelly_colors = ['F2F3F4', '222222', 'F3C300', '875692', 'F38400', 'A1CAF1', 'BE0032', 'C2B280', '848482', '008856', 'E68FAC', '0067A5', 'F99379', '604E97', 'F6A600', 'B3446C', 'DCD300', '882D17', '8DB600', '654522', 'E25822', '2B3D26']
@ollieglass
ollieglass / tweet_text.js
Created Aug 30, 2014
Get the text from every tweet on the page
View tweet_text.js
$(".tweet-text").map(function() { return $(this).text(); })
@ollieglass
ollieglass / ticket.rb
Created Aug 4, 2014
Imagine I have tickets that belong to events. As a developer, I only want to access tickets that belong to an event, and I want to safeguard against accessing all tickets (contrived example, but anyway). If event ids start at 0, and I set the default scope to an event_id of -1, then if I forget to set an event (which would select all tickets), I…
View ticket.rb
class Ticket < ActiveRecord::Base
belongs_to :event
default_scope where(event_id: -1)
end
@ollieglass
ollieglass / twitter_search_summary.js
Created Dec 10, 2013
Twitter search summary. 1. search Twitter for something 2. dismiss the promoted Tweet 3. scroll down, and keep scrolling until you've loaded all the tweets 4. open your JavaScript console (alt + cmd + I in Chrome) 5. paste the code below into the console, press enter to run 6. voila. A summary appears at the top of the search results
View twitter_search_summary.js
$(".header-inner").append(
"<h2>Who's shared your links?</h2>"
+ $.map($(".details"), function (x) { return('<a href="' + $(x).attr('href') + '>@' + $(x).attr('href').split("/")[1] + '</a>') } ).join("<br>")
)
@ollieglass
ollieglass / jsbin.EguNoVI.html
Created Oct 17, 2013
Bulk find or create with ember.js This would be simple to do synchronously (foreach... continue if exists). But working with the asynchronous store creates lots of overhead.
View jsbin.EguNoVI.html
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script src="http://code.jquery.com/jquery-2.0.2.js"></script>
<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
<script src="http://builds.emberjs.com/beta/ember-data.js"></script>
<script src="https://rawgithub.com/rpflorence/ember-localstorage-adapter/master/localstorage_adapter.js"></script>
@ollieglass
ollieglass / macros.py
Created Apr 10, 2013
Macros for Django - this snippet, with unused imports removed http://djangosnippets.org/snippets/363/
View macros.py
#
# templatetags/macros.py - Support for macros in Django templates
#
# Author: Michal Ludvig <michal@logix.cz>
# http://www.logix.cz/michal
#
"""
Tag library that provides support for "macros" in
Django templates.
View topsy_tabs.py
import webbrowser
import xmlrpclib
# get posts from wordpress
server = xmlrpclib.ServerProxy('http://ollieglass.com/xmlrpc.php')
result = server.metaWeblog.getRecentPosts('WORDPRESS_BLOG_NAME', 'WORDPRESS_USERNAME', 'WORDPRESS_PASSWORD', 10)
urls = [post['link'] for post in result]
# change into topsy searches
urls = [url.replace('http://', 'http://topsy.com/') for url in urls]