Skip to content

Instantly share code, notes, and snippets.

View dhartwich1991's full-sized avatar
🖥️
Working :)

Daniel Hartwich dhartwich1991

🖥️
Working :)
View GitHub Profile
@dhartwich1991
dhartwich1991 / schedule.rb
Created March 28, 2019 11:59
A simple and configurable round robin scheduling algorithm written in Ruby
class RoundRobinSchedule
players = %w[a b c]
def schedule(players, pool_size:)
players = players.shuffle
pools = players.each_slice(pool_size).to_a
players.push(nil) if players.size.odd?
pools.size.times do |index|
pool = pools[index]
@dhartwich1991
dhartwich1991 / LICENSE
Last active March 18, 2019 13:53
This license applies to all public gists https://gist.github.com/dhartwich1991
MIT License
Copyright (c) [2019] [Daniel Hartwich]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@dhartwich1991
dhartwich1991 / Gemfile
Created November 25, 2018 14:12
gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
@dhartwich1991
dhartwich1991 / deploy.sh
Created November 25, 2018 11:14
deploy script
#!/bin/bash
# Get the lastest state from remote
git pull
# if dependencies changed we need to install them again
bundle install --deployment --without development test
# Compile new assets and run any eventual migrations
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
# Round representation that immediately schedules all games that belong to it after creation.
class Round < ApplicationRecord
belongs_to :tournament
has_many :matches
after_create :generate_matches
def generate_matches
if round_number == 1
@dhartwich1991
dhartwich1991 / Schema.rb
Last active November 25, 2018 10:55
Match Schema
create_table "matches", force: :cascade do |t|
t.integer "home_score"
t.integer "away_score"
t.integer "home_player_user_id"
t.integer "away_player_user_id"
t.integer "winner_user_id"
t.integer "round_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "first_pokemon", default: 1
@dhartwich1991
dhartwich1991 / DataBindingIdlingResource.kt
Last active December 13, 2018 15:32
DataBindingIdlingResource complete
package de.freenet.databinding
import android.databinding.DataBindingUtil
import android.databinding.ViewDataBinding
import android.support.test.espresso.IdlingResource
import android.support.test.rule.ActivityTestRule
import android.support.v4.app.FragmentActivity
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
package de.freenet.databinding
import android.databinding.DataBindingUtil
import android.databinding.ViewDataBinding
import android.support.test.espresso.IdlingResource
import android.support.test.rule.ActivityTestRule
import android.support.v4.app.FragmentActivity
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
@dhartwich1991
dhartwich1991 / xing_device_grading.csv
Last active September 17, 2018 09:01
XING Device Grading July 2018
# Device Current Usage(%)
1 Samsung Galaxy S7 (G930F) 15.84%
2 Samsung Galaxy S8 (G950F) 8.53%
3 Samsung S6 (SM-G920f) 6.36%
4 Samsung Galaxy S7 Edge (G935F) 4.86%
5 Samsung S5 (SM-G900F) 3.32%
6 Samsung S6 Edge (SM-G925F) 2.73%
@dhartwich1991
dhartwich1991 / second_graph.xml
Last active June 28, 2018 08:07
Second Screen navigation graph xml
<?xml version="1.0" encoding="utf-8"?>
<navigation android:id="@+id/third_feature_graph"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
app:startDestination="@id/secondFeatureFragment">
<fragment
android:id="@+id/secondFeatureFragment"
android:name="com.jdapplications.second_feature.SecondFeatureFragment"