Skip to content

Instantly share code, notes, and snippets.

View Sephi-Chan's full-sized avatar

Romain Tribes Sephi-Chan

  • Nîmes, France
View GitHub Profile
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
➜ Seelies git:(master) cloc app/models --by-file
37 text files.
37 unique files.
0 files ignored.
http://cloc.sourceforge.net v 1.60 T=0.09 s (428.2 files/s, 6597.3 lines/s)
--------------------------------------------------------------------------------------------
File blank comment code
--------------------------------------------------------------------------------------------
app/models/dispatcher.rb 15 3 49
#!/usr/bin/env ruby
require File.expand_path('../../config/environment', __FILE__)
require 'thor'
class PlayersCommand < Thor
desc :add, 'Add a player with the given name.'
method_option :force, desc: 'Delete the player if it already exists.', type: :boolean, default: false
def add(name)
existing_player = Player.find_by_name(name)
@Sephi-Chan
Sephi-Chan / convoy_spec.rb
Created January 13, 2015 17:52
Struct prototyping
require 'spec_helper'
RSpec.describe Convoy do
it 'has wayponts' do
Convoyy = Struct.new(:waypoints) do
def replace_waypoint(old_waypoint_step_number, new_waypoints)
waypoints
.select { |waypoint| old_waypoint_step_number <= waypoint.step_number }
.map { |waypoint| waypoint.active = false }
We couldn’t find that file to show.
class Stater
def initialize(*roles)
@state = 0
@roles = roles
end
def current
@roles[@state % @roles.size]
@Sephi-Chan
Sephi-Chan / minify_resources.rb
Created April 12, 2011 22:42
Package and minify Javascript and CSS files.
#!/usr/bin/env ruby
module MinifyResources
CSS_BLOB = 'public/blob.css'
CSS_DIR = 'public/css'
CSS_LIST = 'public/css/manifest.txt'
CSS_FILES = File.exists?(CSS_LIST) ? IO.read(CSS_LIST).scan(/\S+/) : Dir.chdir(CSS_DIR){ Dir['*.css'] }
JS_BLOB = 'public/blob.js'
JS_DIR = 'public/js'
@Sephi-Chan
Sephi-Chan / server.js
Created May 2, 2011 20:33
HTTP request with Node
var body = JSON.stringify({
uuid: item.uuid
}),
options = {
host: settings.callback.hostname,
port: settings.callback.port,
path: settings.callback.path,
method: 'POST',
headers: {
'X-PQS-Secret-Key': settings.callback.secretKey,
@Sephi-Chan
Sephi-Chan / server.js
Created May 2, 2011 21:21
ProductionQueue server
var settings = {
callback: {
hostname: '127.0.0.1',
port: 4567,
path: '/finish_production',
secretKey: 'my-super-secret-key'
}
}
var http = require('http'),
class Array
# Count occurences of values in the array.
# Return it as a hash.
#
# [1, 1, "foo", :bar, 1, :bar].count_occurrences # => {1 => 3, "foo" => 1, :bar => 2}
def count_occurrences
h = self.group_by { |x| x }
Hash[h.map { |k, v| [ k, v.length ] } ]
end
end