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
@Sephi-Chan
Sephi-Chan / todo.md
Created February 15, 2013 08:49
Todo list du nouveau JeuWeb.

Todo list du nouveau JeuWeb

  • Intégration du design de Kaoji ;
  • Création d'une vue (depuis une recherche) ;
  • Affichage du nombre de sujets non lus à côté du nom de la vue ;
  • Gestion des lu/non lu dans la messagerie privée ;
  • Abonnement à une discussion ;
  • Notifications par mail et sur le site ;
  • Ajout de tags à une recherche par autocomplete (http://textextjs.com/) ;
  • Recherche avancée (par auteur, date et mot-clé) ;
class Watchlist
# Will generate SELECT * FROM users WHERE id IN(SELECT user_id FROM watchlistings WHERE item_id = ...)).
# Instead of two queries (one to pluck the ids, the other to get the watchlistings.
def self.users_watching(item)
ids = Watchlisting.where(item_id: item.id).select(:user_id)
User.where(id: ids)
end
def initialize(user)
@user = user
class BuyWeaponTest < ActiveSupport::TestCase
test "User buys a weapon" do
mp5 = WeaponType.create('mp5', gold: 40)
ak47 = WeaponType.create('ak47', gold: 100)
argo = User.create(name: 'Argo', gold: 100)
argo_mp5 = Weapon.create(weapon_type: mp5, user: argo)
UserBuysWeapon.new(user, ak47).perform!
assert_equal ak47, argo.weapon.weapon_type, "User's new weapon should be a AK-47"

Seelies — Roadmap

V 0.1

  • Connexion & inscription ;
  • Création d'un appel aux armes pour un format donné (admin) ;
  • S'inscrire à une partie pour un format donné en invitant d'autres joueurs ;
  • Voir la liste des invitations (reçues et envoyées) ;
  • Accepter/décliner une invitation ;
frequency = 50/1000 # 50 ms
loop do
moving_objects = Ship.all + Projectile.all
moving_objects.each do |moving_object|
moving_object.move
moving_object.collisions.each do |collision|
collision.object.collides_with(collision.other_object)
end
window.inGroupsOf = function(array, number, fillWith) {
fillWith = fillWith || null;
var index = -number, slices = [];
if (number < 1) return array;
while ((index += number) < array.length) {
var s = array.slice(index, index + number);
while(s.length < number)
s.push(fillWith);
-module(sector).
-export([ start/0, loop/1 ]).
-record(ship, { x, y }).
start() ->
io:format("Hello world!~n"),
Ship = #ship{ x = 1, y = 2 },
OtherShip = #ship{ x = 2, y = 2 },
Ships = [ Ship, OtherShip ],
spawn(?MODULE, loop, [ Ships ]).
@Sephi-Chan
Sephi-Chan / routes.rb
Created May 8, 2012 16:44
Generating routes VS Writing routes by hand
Application::Application.routes.draw do
get '/my_favorites', to: 'favorites#my_index'
resources :users do
resources :favorites, only: [ :index ]
end
resources :favorites, only: [ :destroy ]
namespace :bookmarklet do
class Views.ProfileSummary extends Backbone.View
template: JST['side_bar/profile_summary']
events:
'click .favorites' : 'goToFavorites'
render: ->
html = @template
currentUser: Store.get('currentUser')
render: ->
$html = $(@template(vehicle: @vehicle))
$groups = $html.filter('.groups')
_(@groups).each (group)=>
subview = new App.Views.AttributesGroup(group: group, vehicle: @vehicle)
$groups.append(subview.render().el)
$(@el).html($html)
@