Skip to content

Instantly share code, notes, and snippets.

View AlSquire's full-sized avatar

Arnaud Lécuyer AlSquire

View GitHub Profile
@AlSquire
AlSquire / commands.rb
Last active September 10, 2021 10:32
Now exists as a gem: https://github.com/AlSquire/commands - Display a menu of commands defined in ./commands.yml in the current directory, so you can have a simple cheatsheet AND a quick launch by project :)
#!/usr/bin/env ruby
# Put this file in your PATH and give it execution rights, run to have a commands.yml example.
# Alias it and/or remove .rb extension for convenience.
# Usage:
# commands.rb [ALIAS_OR_NUMBER [ARGS]]
# TODO: stdin and stdout for shell compatibility (useful?)
require 'readline'
require 'yaml'
@AlSquire
AlSquire / yo.rb
Created November 7, 2016 11:44
Tech talk classes ruby
class Card
include Comparable
NUMBERS = 1..13
COLORS = [:coeur, :carreau, :trefle, :pique]
attr_accessor :number, :color
def initialize(number, color)
@number = number
@AlSquire
AlSquire / app.js
Last active August 29, 2015 14:18
/**
* Welcome to Pebble.js!
*
* This is where you write your app.
*/
var UI = require('ui');
var ajax = require('ajax');
function fetchJSON(url) {
@AlSquire
AlSquire / monsters.json
Last active August 29, 2015 14:16
Monster Hunter4 Helper
{
"Akantor":"Water: X, Dragon: XXX",
"Basarios":"Fire: X, Water: XX, Thunder: X, Ice: X, Dragon: XX",
"Ruby basarios":"Fire: X, Water: X, Thunder: X, Ice: XX",
"Brachydios":"Water: XX, Ice: X",
"Raging brachydios":"Water: X, Ice: XX",
"Cephadrome":"Water: X, Thunder: XX, Ice: XXX",
"Congalala":"Fire: XX, Water: X, Thunder: X, Ice: X",
"Emerald congalala":"Fire: X, Water: XX, Thunder: X, Ice: XXX",
"Daimyo hermitaur":"Fire: XXX, Thunder: XXX, Ice: X",
@AlSquire
AlSquire / index.html
Last active December 17, 2015 14:20
* Moved to https://github.com/AlSquire/GW2Dash * GW2 APIs + AngularJS example. Demo here: http://gw2api-angularjs.herokuapp.com/
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>GW2API - AngularJS</title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-resource.min.js"></script>
<script src="script.js"></script>
@AlSquire
AlSquire / weblapine.coffee
Last active December 15, 2015 09:59
Script for Hubot (http://hubot.github.com/) to use with my Weblapine (https://github.com/AlSquire/WebLapine). Needs WEBLAPINE_URI (ie: http://mylapine.net) and WEBLAPINE_IRC_NETWORK_NAME (ie: freenode) env variables to work.
# Description:
# Ouai WebLapine ! See https://github.com/AlSquire/WebLapine
#
# Commands:
# anything with http://www.example.com - Saved to WebLapine
# hubot links - The Weblapine uri for the current irc channel
# hubot addlog <quote> - Record <quote>
# hubot log - Random quote
# hubot log + - Details about the last displayed quote (more + for deeper history)
# hubot log <term> - Search quotes for <term>
@AlSquire
AlSquire / ar_example.rb
Last active December 14, 2015 00:19
Exemple d'active record du pourquoi que c'est bien
# Disons qu'on a deux tables
#
# users
# - id
# - name
# - extra
#
# comments
# - id
# - user_id
# * I think some attr should be filtered by controllers,
# while others by models (ie. computed values, as counter_cache)
# * Casting http params should not be the model direct responsibility ("1" => true, urg)
# * Using multiple controllers for a same model would be more convenient
# * I would love controllers to be more declarative
class Comment < ActiveRecord::Base
belongs_to :user # user_id (integer)
belongs_to :post # post_id (integer)
# title (string)
@AlSquire
AlSquire / gist:929379
Created April 19, 2011 19:29
Terminitor sample
window do
before { run 'cd /Users/arnaud/yooplr' }
run "autotest -cf"
end
window do
before { run 'cd /Users/arnaud/yooplr' }
tab "mate .",
# Growl autotest module I use with Rails 3 RC Test::Unit
module Autotest::Growl
def self.growl(title, msg, img = nil)
cmd = "growlnotify -n autotest -m \"#{msg}\" \"#{title}\""
cmd += " --image \"#{img}\"" if img
system cmd
end