Java Developer since: 1997 >
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TasksController < ApplicationController | |
| def update | |
| if @task.update_attributes(params[:task]) | |
| tracker = TaskTracker.new(@task.previous_changes) | |
| TaskPusher.new(tracker, socket_id).push_changes | |
| TaskMailSender.new(tracker, current_user).deliver_email | |
| # success response | |
| else | |
| # failure respond | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Here is a simple jQuery plugin to make a table header fixed on top when window is scrolled. | |
| Using the code from twitter bootstrap documentation page, this code is customized for table header. | |
| Create the table with following layout - | |
| <table class="table-fixed-header"> | |
| <thead class="header"> | |
| <tr> | |
| <th>Column 1</th> | |
| <th>Column 2</th> | |
| <th>Column 3</th> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: binary | |
| # Removes any bytes from a string that are not valid UTF-8 | |
| class Cleaner | |
| attr_reader :bytes, :buffer, :outstanding | |
| def self.clean(str) | |
| new.tap { |c| c << str }.to_s | |
| end |
This is a general overview (from memory) of the steps I used to install graphite (http://graphite.wikidot.com) on OS X Lion. I think the steps are in order but YMMV. Please fork and fix if you find an error.
brew install python
$ python --version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns sudoku | |
| (:refer-clojure :exclude [==]) | |
| (:use clojure.core.logic)) | |
| (defn get-square [grid x y] | |
| (for [x (range x (+ x 3)) | |
| y (range y (+ y 3))] | |
| (get-in grid [x y]))) | |
| (defn init [grid [pos value]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --colour | |
| -I app |
# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # sample class to mock and test against | |
| class Thing | |
| def foo | |
| bar | |
| end | |
| def bar | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # giftube – Generates an animated gif from a YouTube url. | |
| # | |
| # Usage: | |
| # | |
| # giftube [youtube url] [minute:second] [duration] | |
| # | |
| # ex. | |
| # |