Skip to content
View game.rb
def generate_berger_schedule(teams: 8, rounds: 1)
matches = []
team_sequence = (1..(teams - 1)).to_a
(1..rounds).each do |round|
team_sequence_for_round = []
games = []
if round.even?
team_sequence_for_round = Array.new(team_sequence)
View game.rb
def generate_round_robin_balanced_schedule(teams: 8, rounds: 1)
matches = []
(1..rounds).each do |round|
team_sequence = [0] # the first team is fixed
offset = round % (teams - 1)
(1..(teams - 1)).each do
offset = 1 if offset >= teams
offset = (teams - 1) if offset == 0
team_sequence << offset
View git-stats.sh
#!/bin/bash
IFS=$'\n'
names=`git log --no-merges --all --since="3 months ago" --format='%aN' | sort -u`
printf "%-20s %10s %10s %10s\n" "Name" "Chng Files" "Lns Insert" "Lns Delete"
printf "%-20s %10s %10s %10s\n" "--------------------" "----------" "----------" "----------"
for n in ${names}; do
gitstat=`git log --no-merges --all --shortstat --since="3 months ago" --author="${n}" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {printf "%10s %10s %10s", files, inserted, deleted }'`
View Gemfile
group :development, :test do
gem 'guard'
gem 'guard-minitest'
gem 'terminal-notifier-guard', '~> 1.6.1'
end
View create.js
// W3C/Safari
var n = new Notification('Notification Title', {'body': 'Details on the notification...'});
// WebKit
var n = webkitNotifications.createNotification('not_used.png', 'Notification Title', 'Details on the notification...');
n.show();
View scoped_id.rb
# First create a column on the parent object to keep track of the next scoped_id:
class CreateProjects < ActiveRecord::Migration
def change
create_table :projects do |t|
...
t.integer :bugs_sequence
...
end
end
View apache.conf
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
View 1_ar_without_callbacks.rb
class Issue < ActiveRecord::Base
def project=(p)
write_attribute :project_id, p # doesn't work
# Code that does not belong
if p.security(:private)
p.audit_log :change, self
end
end
View index.html
<html>
<head>
<title>Web Notifications</title>
<script type="text/javascript">
var send_notification = function() {
if (window.webkitNotifications && navigator.userAgent.indexOf("Chrome") > -1) {
console.log("Web Notifications are supported with the WebKit API");
View index.html
<html>
<head>
<title>Sample Grid</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var Grid = function() {
Something went wrong with that request. Please try again.