Skip to content

Instantly share code, notes, and snippets.

View rnaud's full-sized avatar
🤷‍♂️
My computer is so slow it hertz.

Arnaud Ferreri rnaud

🤷‍♂️
My computer is so slow it hertz.
View GitHub Profile
$(".search.themes li input").change(function() {
var classes = []
$(".search.themes li input:checked").each(function(){
console.log($(this).siblings(".box"))
var classList = $(this).siblings(".box").attr('class').split(/\s+/);
$.each( classList, function(index, item){
if (item != 'box') {
classes.push(item)
}
StyleStats!
┌──────────────────────────┬────────────────────────┐
│ Size │ 132.4KB │
├──────────────────────────┼────────────────────────┤
│ Rules │ 1040 │
├──────────────────────────┼────────────────────────┤
│ Selectors │ 1446 │
├──────────────────────────┼────────────────────────┤
│ Simplicity │ 71.92% │
├──────────────────────────┼────────────────────────┤
SELECT
drivers.id,
drivers.first_name,
(SELECT COUNT(*) FROM order_deliveries INNER JOIN picking_sets ON order_deliveries.batch_id = picking_sets.id WHERE order_deliveries.pay_shopper_if_canceled = 'f' AND picking_sets.driver_id = drivers.id) as deliveries_count,
(SELECT COUNT(*) FROM order_deliveries INNER JOIN picking_sets ON order_deliveries.batch_id = picking_sets.id WHERE order_deliveries.pay_shopper_if_canceled = 'f' AND order_deliveries.id IN (SELECT order_delivery_id FROM order_issues) AND picking_sets.driver_id = drivers.id) as deliveries_with_issues_count
FROM drivers;
@rnaud
rnaud / Game card 9.js
Created February 20, 2011 13:32
Logic problem
var unshift = Array.prototype.unshift;
var splice = Array.prototype.splice;
var grid = [];
var used = [];
var new_grid = [];
grid.push([{type:"p", head : 1},{type:"c", head : 1},{type:"a", head : 2},{type:"o", head : 2}]);
grid.push([{type:"o", head : 1},{type:"a", head : 2},{type:"c", head : 2},{type:"p", head : 1}]);
grid.push([{type:"c", head : 1},{type:"p", head : 2},{type:"o", head : 2},{type:"a", head : 1}]);
grid.push([{type:"p", head : 1},{type:"c", head : 2},{type:"o", head : 2},{type:"a", head : 1}]);
@rnaud
rnaud / checkgrid.html
Created February 20, 2011 14:43
Check the values given by asterix.js
<!doctype html>
<html>
<head>
<style>
#solution {
width: 600px;
margin: 0 auto;
}
@rnaud
rnaud / puzzle_solver.rb
Created February 21, 2011 00:29
I'm only finding a 6 card deck
require 'json'
class Array
def rotate n
a =dup
n.times do a << a.shift end
a
end
end
@rnaud
rnaud / omniauth_callbacks_controller.rb
Created April 11, 2011 07:00
My Onmiauth callback controller.
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_filter :beta
def facebook
@user = User.find_for_facebook_oauth(env["omniauth.auth"], current_user)
if @user
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
@rnaud
rnaud / gist:1009976
Created June 6, 2011 09:13
ListView with embed Gallery
package com.rnaud.karma;
import java.util.ArrayList;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
date = $('meta[name=next_sale]').attr("content");
end_date = Date.parse(date);
remaining_time = end_date - now;
if (remaining_time > 0) {
$("#box5").html('<div id="box_timer">Ivan est un gros anuf</div>');
} else {
setInterval("updateTimer()", 1000);
}
@rnaud
rnaud / attribute_serializer.rb
Created September 11, 2011 13:36
Attribute Serializer, serializeable, with fix for default values.
module AttributeSerializer
module ActiveRecordExtensions
module ClassMethods
def serializeable(serialized, serialized_accessors={})
serialize serialized, serialized_accessors.class
serialized_attr_accessor serialized, serialized_accessors
default_serialized_attr serialized, serialized_accessors
end