Skip to content

Instantly share code, notes, and snippets.

View AlSquire's full-sized avatar

Arnaud Lécuyer AlSquire

View GitHub Profile
source 'http://rubygems.org'
gem 'sinatra'
gem 'sinatra-contrib'
# gem 'nokogiri'
# gem 'builder'
# gem 'rake'
group :production do
gem 'thin'
# Quick script which periodically get an uri and check
# for a matching regexp or block of code, then notifify you.
require "open-uri"
class Watcher
attr_accessor :uri, :sleep_time, :regexp, :check_block
def initialize(uri, sleep_time = nil, regexp = nil, &block)
self.uri = uri
# http://www.codinghorror.com/blog/2010/02/the-nonprogramming-programmer.html#comments
# First comment: But many people don't know how to write simplest programs, such as "how to find the smallest common multiple of two integers".
# So I was wondering how much time it would take me... it was a matter of one or two minutes.
x, y = 12708, 24057
m = [x, y].min
until(x % m == 0 && y % m == 0)
m = m - 1
end
puts m
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-style-type" content="text/css" />
<title>Wii Javascript | AlSquire.net</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js"></script>
<style type="text/css">
# Tricky spaces
def one(*arg)
1
end
puts one # => 1
# Hmm ok.
puts one + 1 # => 2
# So what ?
detach subdirectory:
You want to clone your repository and then use git filter-branch to mark everything but the subdirectory you want in your new repo to be garbage-collected. To clone your local repository:
$ git clone --no-hardlinks /XYZ /ABC
The --no-hardlinks switch makes git use real file copies instead of hardlinking when cloning a local repository. The garbage collection and pruning actions will only work on blobs (file contents), not links.
Then just filter-branch and reset to exclude the other files, so they can be pruned:
require 'rubygems'
require 'activesupport'
# class Hash
module Enumerable
def dig(*keys)
s = self
keys.all? do |key|
s = s[key]
end
"ta mere" / [:bus] # => Ta mère en string sur un arrêt de bus
gem "thoughtbot-shoulda", :lib => "shoulda", :source => "http://gems.github.com" if yes?('Use shoulda gem?')
gem "thoughtbot-factory_girl", :lib => "factory_girl", :source => "http://gems.github.com" if yes?('Use factory_girl gem?')
gem "mocha" if yes?('Use mocha gem?')
gem "haml" if yes?('Use haml gem?')
if yes?('Git init?')
git :init
file '.gitignore', <<-EOF
log
tmp
db/*.sqlite3
# Ok, forget the other method, just use ActiveSupport Inflector (from which version ?)
$KCODE = 'UTF-8' # For Windows.
# But a string with accents typed in the Windows command line will still have a NoMethodError 'normalize'.
require 'rubygems'
gem 'activesupport'
require 'activesupport'
txt = "Hé hoé Huhuh, tu as déjà vu du kawaï sur une adresse@mail.com ? CAPitALE !"