Skip to content

Instantly share code, notes, and snippets.

View maedi's full-sized avatar

maedi

View GitHub Profile
@protrolium
protrolium / YouTube API — getting video thumbnail
Created February 5, 2014 19:57
YouTube API — getting video thumbnail
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
@ddemaree
ddemaree / application.js.coffee
Created June 12, 2011 21:54
Simple Google Maps API v3 integration in CoffeeScript, with non-JS Static Maps fallback
#= require jquery
#= require jquery_ujs
#= require lib/modernizr
#= require lib/jquery.lettering
#= require_tree .
$ ->
$('*[data-googlemap]').googleMap()
true
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@scottjehl
scottjehl / jqm-self-init-a-widget.js
Created July 8, 2011 14:29
Self-init a jQuery Mobile plugin
// First, let's define a widget/plugin called "foo"
// Either using jQuery's $.fn plugin namespace, for simple stateless plugins...
$.fn.foo = function(){
// In this scope, this refers to the element on which the plugin foo() was called
// manipulate it and return this at the end, so it can be chainable
};
@nternetinspired
nternetinspired / output-articles-by-collection.liquid
Last active April 25, 2021 02:17
Loop through Jekyll collections and output their content as sections and articles
{% comment %}
Loops though every collection you defined in _config.yml and grabs the pages they contain; outputting title and full text with good basic html semantics.
Use page.excerpt instead of page.content to grab the first paragraph, blog list style. Markdownify is optional, depends how you authored content in your collections; I typically use Markdown.
{% endcomment % }
{% for collection in site.collections %}
{% assign name = collection.label %}
<section>
@fcalderan
fcalderan / rakefile.rb
Last active March 25, 2018 04:30
This code iterates through every .html file contained in a given folder and, for each template found, it looks for every image (<img>) contained (with Nokogiri gem) in the document. Then it dynamically calculates the image size (with fastimage gem) adding the “height” and “width” attributes. Finally it saves the template. Colorize gem is only us…
# Tested on Ruby v.1.9.3 - Author: Fabrizio Calderan, 3.14.2013
#
# Install these gems with
# $> sudo gem install fastimage nokogiri colorize
#
# Then copy this source into a file named “rakefile” and run with
# $> rake
#
require "fastimage"
require "nokogiri"
@mrrooijen
mrrooijen / README.md
Created October 16, 2012 22:19
Ruby Environment On Mountain Lion

Ruby Environment On Mountain Lion

A quick and easy step-by-step guide to get your Ruby environment up and running again after a fresh install of Mountain Lion. I messed up my installations a few times and figured I'd just put out a Gist once and for all to get this sucker working in one go.

The Steps

First go ahead and install either XCode to get ahold of the Command Line Tools. Or, if you prefer not to install XCode, simply download the latest version directly. This only requires you to provide your Apple ID and password to sign in. You do not need a developers license.

  1. Download the Command Line Tools
  • Or install them through XCode via the preference panel
@mdp
mdp / ajax.coffee
Created February 2, 2012 22:54
Backbone AJAX Rails CSRF token hack
app.csrf_token = $('meta[name="csrf-token"]').attr('content')
$.ajaxSetup
beforeSend: (xhr, settings) ->
return if (settings.crossDomain)
return if (settings.type == "GET")
if (app.csrf_token)
xhr.setRequestHeader('X-CSRF-Token', app.csrf_token)
@gugahoi
gugahoi / app.js
Last active December 11, 2015 19:18
keyUp filter function
App.Filter = Ember.TextField.extend({
keyUp: function() {
var array = App.Movies.FIXTURES;
for (var i = array.length - 1; i >= 0; i--) {
var name = array[i].name,
id = array[i].id,
movie = App.Movies.find(id);
if(name.toLowerCase().indexOf(this.get('value')) !== -1){
movie.set('isHidden', false);
} else {
anonymous
anonymous / someMixin.coffee
Created November 6, 2012 00:35
Dashboard.Mixins={}
Batman.mixins.someMixin =
initialize: ->
$(@).hide().fadeIn()
show: (addToParent) -> $(@).fadeIn()
hide: (removeFromParent) -> $(@).fadeOut()