Skip to content

Instantly share code, notes, and snippets.

@media all and (max-device-width: 768px) and (orientation:portrait) {
#site { width: 525px; }
nav { float: none; width: 100%; }
}
@media all and (max-device-width: 480px) {
#site { width: 315px; }
.container aside { margin-left: 0; width: 295px; }
nav { float: none; width: 100%; }
}
@andflett
andflett / authusersubscribe.sh
Created August 5, 2011 10:24
Instagram API: Subscribe to your authenticated users' feed
curl -F 'client_id=CLIENT-ID' \
-F 'client_secret=CLIENT-SECRET' \
-F 'object=user' \
-F 'aspect=media' \
-F 'verify_token=userSubscription' \
-F 'callback_url=http://YOUR-CALLBACK/URL' \
https://api.instagram.com/v1/subscriptions/
@andflett
andflett / bookmarks.rake
Created May 8, 2012 22:26
Rake task to import bookmarks and tags (parent folders) from Netscape Bookmark formatted files.
require 'nokogiri'
require 'open-uri'
namespace :bookmarks do
desc '-- Import bookmarks in Netscape Bookmark format'
task :import => :environment do
doc = Nokogiri::HTML(open(File.join(Rails.root, "lib/dump/bookmarks_5_8_12.html")))
# Ensure we're dealing with the correct format
@andflett
andflett / cartography.rb
Created June 23, 2012 00:52
Convert OSGB36 Eastings/Northings Coords to WGS84 Latitude/Longitude
module Cartography
extend self
# Takes OSGB36 Easting/Northing coords
# and returns WGS84 Latitude and Longitude
def en_to_ll(easting, northing)
@OSGB36_ll = to_OSGB36(easting, northing)
to_WGS84(@OSGB36_ll[:latitude], @OSGB36_ll[:longitude])
end
@andflett
andflett / sir-trevor-active-admin.css
Created October 4, 2012 12:36
Make Sir Trevor more presentable in ActiveAdmin
body {
margin: 0;
line-height: 150%;
font-size: 72%;
}
form .sir-trevor {
width: 860px;
margin: 30px auto;
background: #ffffff;
@andflett
andflett / is_json.rb
Created October 4, 2012 15:15
Is JSON for Sir Trevor
require 'json'
class String
def is_json?
begin
!!JSON.parse(self)
rescue
false
end
end
@andflett
andflett / timezoneoverlap.rb
Last active August 29, 2015 14:04
Time zone overlap
host = user = User.new
# Store in real datetime models with timezone data, convert to UTC, and base overlap on current week
# to mitigate the risk of leap years, timezone shifts (summer time) etc.
host.time_zone = "Europe/London"
host.availability = [
ActiveSupport::TimeZone.new(host.time_zone).parse('Wednesday 8am').utc..ActiveSupport::TimeZone.new(host.time_zone).parse('Wednesday 6pm').utc,
ActiveSupport::TimeZone.new(host.time_zone).parse('Friday 8am').utc..ActiveSupport::TimeZone.new(host.time_zone).parse('Friday 6pm').utc,
]
/**
* Soundcloud oEmbed discovery
*/
SirTrevor.Blocks.Soundcloud = (function(){
return SirTrevor.Block.extend({
type: 'Soundcloud',
title: function() { return 'Soundcloud' },
/**
* Mixcloud oEmbed discovery
*/
SirTrevor.Blocks.Mixcloud = (function(){
return SirTrevor.Block.extend({
type: 'Mixcloud',
title: function() { return 'Mixcloud' },
@andflett
andflett / EAPI.class.rb
Created July 27, 2016 17:00
Erply API class with added Bulk requests
require 'json'
require 'net/http'
require 'uri'
class MissingArgumentsException < Exception
end
class VerifyUserException < Exception
end
class EAPI