Skip to content

Instantly share code, notes, and snippets.

View maedi's full-sized avatar

maedi

View GitHub Profile
@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>
@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
@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"
@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>
@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()
@mrrooijen
mrrooijen / filters.coffee
Created October 28, 2012 11:41
Batman.js Even/Odd CSS trick for iterations.
Batman.mixin Batman.Filters,
indexOf: (set, iteration) -> set?.toArray().indexOf(iteration)
isEven: (input) -> input % 2 == 0
@mrrooijen
mrrooijen / example.html
Created October 21, 2012 20:36
Batman.js data-foreach with index.
<!-- Show the <hr /> if the `account.viewIndex` is greater than `0` -->
<!-- Note: The `gt` function is a custom filter I made, see the `helpers.js.coffee` file -->
<div data-foreach-account="currentUser.accounts | withIndex">
<hr data-showif="account.viewIndex | gt 0" />
<span data-bind="account.email"></span>
</div>
@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
@loopj
loopj / batman-layoutcontroller.coffee
Created October 8, 2012 21:44
Batman.js controller which adds rails-style layouts to controllers
class Batman.LayoutController extends Batman.Controller
render: (options = {}) ->
layout = options.layout ? @layout ? Batman.helpers.underscore(@get('routingKey'))
if layout
# Prefetch the action's view in parallel
source = options.source || Batman.helpers.underscore(@get('routingKey') + '/' + @get('action'))
Batman.View.store.prefetch source
# Fetch the layout's view and apply context