Skip to content

Instantly share code, notes, and snippets.

View shaundon's full-sized avatar

Shaun Donnelly shaundon

View GitHub Profile
@shaundon
shaundon / button_toggle_left_right.css
Created September 18, 2012 20:18
Button toggle left and right states
.button_toggle.left {
border-radius: 2px 0px 0px 2px;
}
.button_toggle.right {
border-radius: 0px 2px 2px 0px;
}
@shaundon
shaundon / button_toggle_left_right_margin.css
Created September 18, 2012 20:34
Button toggle left and right states with margin
.button_toggle.left {
border-radius: 2px 0px 0px 2px;
margin-right:-5px;
}
.button_toggle.right {
border-radius: 0px 2px 2px 0px;
margin-left:-5px;
}
@shaundon
shaundon / search_box.html
Created September 19, 2012 18:18
Search Box
<input type="search" id="search" style="width:90px;" placeholder="Click Me!" />
@shaundon
shaundon / search_box_jquery.cs
Created September 19, 2012 18:23
jQuery code to bind to a search box
$(document).ready(function(){
$("#search").bind({
focus: function() {
$(this).animate({ width:200 }, 300);
},
blur: function() {
$(this).animate({ width:90 }, 300);
}
});
});
@shaundon
shaundon / firehose.rb
Created September 20, 2012 08:19
A simple Ruby script to connect to Twitter's streaming API and return tweets matching a search term in real time.
# Tweet Stream. Uses the 'tweetstream' gem.
# Asks for a keyword, and monitors tweet for that keyword.
require 'tweetstream'
# Ask for keyword.
print "Keyword: "
keyword = gets.chomp()
TweetStream.configure do |config|
@shaundon
shaundon / gist:4984247
Last active December 13, 2015 22:28
Function for searching the text of some elements and hiding elements that don't match the search terms. Prerequisites: jQuery, and a CSS class 'visible' that allows your elements to display (this is then toggled on/off)
function FilterResults(query) {
// Remove whitespace.
query = $.trim(query);
// Add an 'OR' for regex syntax.
query = query.replace(/ /gi '|');
$('selector for each element to search').each(function () {
@shaundon
shaundon / skeleton.html
Last active December 23, 2015 06:09
A skeleton HTML page, with spaces for adding custom CSS and JavaScript, and a number of external JavaScript, stylesheets and fonts added but commented out, allowing you to choose which ones you require. This is mainly for building quick demos of things.
<!doctype html>
<!--
Shaun Donnelly (hello@sdonnelly.co.uk)
This is a skeleton HTML page.
Copy it, then use it to make HTML demos and other things.
In the <head>, there are a number of commented out
@shaundon
shaundon / json_to_csv.js
Created September 19, 2013 15:27
JSON to CSV converter.
function JsonToCsv(json) {
var csv = '';
// Begin with the header row, using
// the keys as headings.
for (var key in json[0]) {
csv += key + ',';
}
@shaundon
shaundon / gist:7805684
Created December 5, 2013 14:09
A loading indicator that jumps down from the top of the page when it has the class 'visible'.
#global-loading {
background: lighten(#ff0, 35%);
@include borderBottomRadius(3px);
@include boxShadow((0 0 5px rgba(#000, .5)));
color: #333;
color: rgba(#000, .4);
font-size: 24px;
font-weight: bold;
left: 50%;
height: 70px;
@shaundon
shaundon / server.rb
Created December 6, 2013 09:37
A very simple Sinatra server. Used for serving pages locally. I mainly use this for hosting functional mockups on my system.
require 'sinatra'
set :port, 4567
set :public_folder, File.dirname(__FILE__) + '/'
get '/' do
File.read('index.html')
end