Skip to content

Instantly share code, notes, and snippets.

View bit-dragon's full-sized avatar
🏠
Working from home

Jorge García bit-dragon

🏠
Working from home
View GitHub Profile
@bit-dragon
bit-dragon / nav-list-bootstrap.rb
Created May 2, 2012 01:25
simple-navigation render for twitter bootstrap nav-list and divider
#require 'simplenavigation'
class ListBootstrap < SimpleNavigation::Renderer::Base
def render(item_container)
list = item_container.items.inject([]) do |list, item|
if item.html_options[:opts]
if item.html_options[:opts][:nav_header]
list << li_header(item)
elsif item.html_options[:opts][:divider]
list << li_divider(item)
elsif item.html_options[:opts][:icon]
@bit-dragon
bit-dragon / gist:2870549
Created June 4, 2012 20:04
Basic structure of Jekill
all: install
install:
@echo Installing the basic structure
@mkdir -p _includes _layouts _posts _site
@touch _layouts/default.html _layouts/post.html
@touch _posts/2007-10-29-why-every-programmer-should-play-nethack.md
@touch _posts/2009-04-26-barcamp-boston-4-roundup.md
@touch index.html _config.yml
@echo Done
@bit-dragon
bit-dragon / post.html
Created June 7, 2012 19:55
Plugin to truncate and add an anchor "read more" in the posts of jekyll
<div class="">
<div class="entry">
<h2 class="title"><a href="{{ post.url }}">{{ post.title }}</a></h2>
<div class="byline">Escrito el {{ post.date | date:"%d/%m/%Y" }}</div>
<div class="body">
{% if hide_extended %}
{% if post.readmore %}
{{ post.content | truncate }}
<a href="{{ post.url }}/#more" class="more-link"><span class="readmore">Read more»</span></a>
find ./ -name filename | xargs sed -i 0 "s/original/replace/g"
@bit-dragon
bit-dragon / runtest.sh
Last active October 10, 2015 21:08
Run test with an correct order
#! /bin/bash
clear
echo "Running the rspec sorted correctly"
find spec -type f -name '*_spec.rb' | sort | xargs rspec
@bit-dragon
bit-dragon / spec_helper.rb
Created September 26, 2012 05:41
RSpec configuration for Rails Engine application
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../dummy/config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'factory_girl_rails'
require 'database_cleaner'
require 'shoulda/matchers/integrations/rspec'
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
@bit-dragon
bit-dragon / remove on git
Created October 1, 2012 18:43
Remove many files on git
git ls-files --deleted -z | xargs -0 git rm
@bit-dragon
bit-dragon / .vimrc
Created October 17, 2012 23:47
VIMRC
call pathogen#infect()
" Tabs
set shiftwidth=2
set tabstop=2
set vb
" Highlight
set hlsearch!
@bit-dragon
bit-dragon / .vim
Last active October 11, 2015 19:38
.vim
├── autoload
│   └── pathogen.vim
├── bundle
│   ├── ctrlp.vim
│   ├── gundo
│   ├── nerdcommenter
│   ├── nerdtree
│   ├── quicktask
│   ├── scss-syntax.vim
@bit-dragon
bit-dragon / ObserverPattern.js
Last active December 10, 2015 01:18
(Observer Pattern) PubSub on javascript
var publisher = {
subscribers: {
any: [] // Event type: subscribers
},
subscribe: function (fn, type) {
type = type || 'any';
if (typeof this.subscribers[type] === 'undefined') {
this.subscribers[type] = [];
}