This file contains 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
/** | |
* Redy - a prototype for a ruby like javascript. | |
* Parts of this software are derived from JS.Class by James Coglan. | |
* | |
* | |
* This file is licensed under the Ruby licenense. | |
* Copyright 2008. Victor Hugo Borja <vic.borja gmail.com> | |
*/ | |
Redy = { |
This file contains 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
require 'rubygems' | |
require 'rake' | |
require 'rake/testtask' | |
require File.expand_path('../lib/mongomapper_id2/version', __FILE__) | |
Rake::TestTask.new(:test) do |test| | |
test.libs << 'lib' << 'test' | |
test.pattern = 'test/{functional,unit}/**/*_test.rb' | |
end |
This file contains 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
# config/initializers/clear_logs.rb | |
# This snippet simply clears your logs when they are too large. | |
# Large logs mean looooong search in TextMate. You know it :) | |
# Every time you run rails server or rails console it checks log sizes | |
# and clears the logs for you if necessary. | |
if Rails.env.development? | |
MAX_LOG_SIZE = 2.megabytes | |
This file contains 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
// I mean, seriously, localStorage is supported even by your mum. How about instead of | |
// casing the feature out, you give users in-memory (stale) storage instead? | |
// If they close your application, they deserve to lose data anyway. | |
// if (!('localStorage' in window)) { | |
if (!Modernizr.localstorage) { | |
window.localStorage = { | |
_data : {}, | |
setItem : function(id, val) { return this._data[id] = String(val); }, | |
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; }, |
This file contains 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
#!/bin/sh | |
# A pre-commit hook for git to lint JavaScript files with jshint | |
# @see https://github.com/jshint/jshint/ | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
This file contains 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
license: gpl-3.0 | |
redirect: https://observablehq.com/@d3/modifying-a-force-directed-graph |
This file contains 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
<?php | |
// Example code how to eliminate getter and setter methods | |
// with traits introduced from PHP 5.4 | |
trait Accessors { | |
public function __get($name) { | |
if ($this->r_property[$name]) | |
return $this->$name; | |
else | |
trigger_error("Access to read protected property"); |
This file contains 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 Array | |
def diagonals | |
[self, self.map(&:reverse)].inject([]) do |all_diags, matrix| | |
((-matrix.count + 1)..matrix.first.count).each do |offet_index| | |
diagonal = [] | |
(matrix.count).times do |row_index| | |
col_index = offet_index + row_index | |
diagonal << matrix[row_index][col_index] if col_index >= 0 | |
end | |
all_diags << diagonal.compact if diagonal.compact.count > 1 |
This file contains 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
# Was asked how I keep my zshrc config sync'd between my computers with Dropbox | |
# Add a new directory in your Dropbox (or use an existing one) | |
mkdir -p ~/Dropbox/ohmyzsh | |
# move existing file to Dropbox | |
mv ~/.zshrc ~/Dropbox/ohmyzsh/zshrc | |
# symlink file back to your local directory | |
ln -s ~/Dropbox/ohmyzsh/zshrc ~/.zshrc |
This file contains 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
require "faraday" | |
require 'typhoeus' | |
conn = Faraday.new(:url => 'http://httpstat.us') do |builder| | |
builder.request :url_encoded | |
builder.response :logger | |
builder.adapter :typhoeus | |
end | |
conn.in_parallel do |
OlderNewer