Skip to content

Instantly share code, notes, and snippets.

@ZenCocoon
ZenCocoon / gist:724366
Created December 1, 2010 22:36
Handling French date format in Ruby
## Try 1
# How could I get the following working nicely
Date.strptime("Ven 13 Mai. 2011, 16h00", "%a %d %b %Y, %Hh%M")
# I've tried to update Date::ABBR_DAYNAMES as follow
I18n.locale = :fr
Date::ABBR_DAYNAMES = I18n.t('date.abbr_day_names')
Date::ABBR_MONTHNAMES = I18n.t('date.abbr_month_names')
@ZenCocoon
ZenCocoon / gist:703998
Created November 17, 2010 20:17 — forked from dhh/gist:29752
config.action_controller.asset_host = Proc.new do |source, request|
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com"
ssl_host = "https://asset1.backpackit.com"
if request.ssl?
case
when source =~ /\.js$/
ssl_host
when request.headers["USER_AGENT"] =~ /(Safari)/
non_ssl_host
@ZenCocoon
ZenCocoon / gist:660594
Created November 3, 2010 00:30
With SQL, how to achieve the following goal
CREATE TABLE `users` (
`id` int(11) DEFAULT NULL,
`email` varchar(255) CHARACTER SET latin1 DEFAULT NULL,
`born_at` varchar(255) CHARACTER SET latin1 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `users` (`id`,`email`,`born_at`) VALUES ('1','[email protected]','1980-01-01');
INSERT INTO `users` (`id`,`email`,`born_at`) VALUES ('2','[email protected]','1980-01-02');
INSERT INTO `users` (`id`,`email`,`born_at`) VALUES ('3','[email protected]','1980-01-01');
INSERT INTO `users` (`id`,`email`,`born_at`) VALUES ('4','[email protected]','1980-01-03');
(function() {
var gs = document.createElement('script'), gsc = document.createElement('div'), interval;
gs.type = 'text/javascript'; gs.async = true; gsc.id = 'getsatisfaction';
gs.src = document.location.protocol + '//s3.amazonaws.com/getsatisfaction.com/javascripts/feedback-v2.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(gs);
(document.getElementsByTagName('body')[0]).appendChild(gsc);
interval = setInterval(function() {
if (window.GSFN !== undefined) {
new GSFN.feedback_widget({
config.status: creating arm-linux-eabi-fake.rb
executable host ruby is required. use --with-baseruby option.
make: *** [.rbconfig.time] Error 1
<div id="the_div">
<ul id="the_list">
<li id="the_item">Click me!</li>
</ul>
</div>
<p id="log"></p>
<script type="text/javascript" charset="utf-8">
function log(string){
var Math2 = function() {
function sin(num) {
console.log('Compute');
return Math.sin(num);
}
return {
sin: sin
}
}();
// Example call for functional version:
function logCar(object) {
return "I'm a " + object.color + " " + object.make
}
logCar({ color: 'blue', make: 'BMW' });
// Example call for OO version:
var Car = function(make, color) {
this.make = make;
var countdown = (function() {
var index;
function log(){
console.log(index);
}
function iterate(){
log();
if(index>1) setTimeout(iterate, 1000);
def url_escape(string)
string.gsub(/([^ ;\/?:@=#&a-zA-Z0-9_.-]+)/n) do
'%' + $1.unpack('H2' * $1.size).join('%').upcase
end.tr(' ', '+')
end