Skip to content

Instantly share code, notes, and snippets.

class MyModel < ApplicationRecord
TOKEN_CHARS = 'ybndrfg8ejkmcpqxt1wisza345h769'
before_create :generate_token
# Generates random token leaving out numbers and letters that might be ambiguous and that might
# result in words some people find offensive.
def self.typeable_token(length = 8)
length.times.map do
TOKEN_CHARS[SecureRandom.random_number(TOKEN_CHARS.length)]
TYPES = {
'c' => 'coin',
'w' => 'wall'
}
def map_to_list(map)
list = []
map.strip!.gsub!(/\n\s*/, "\n")
def vector_to_coordinates(distance, angle_in_degrees)
angle_in_radians = angle_in_degrees * Math::PI / 180
x = (distance * Math.cos(angle_in_radians)).round
y = (distance * Math.sin(angle_in_radians)).round
[x, y]
end
require "test/unit"
class TestVectorConversion < Test::Unit::TestCase
loadAPI(1);
host.defineController("Roger Linn Design", "LinnStrument", "1.0", "B7DD06CB-63BA-4902-879E-050B09D3058F");
host.defineMidiPorts(1, 1);
host.addDeviceNameBasedDiscoveryPair(["LinnStrument MIDI"], ["LinnStrument MIDI"]);
function init()
{
host.getMidiInPort(0).setMidiCallback(onMidi);
// On iPhone and iPod Touch we add a nice dynamic 3D parallax effect by
// updating the perspective origin depending on device tilt.
if (/iPhone|iPod/.test(navigator.platform) && 'ondevicemotion' in window) {
;(function() {
var value,
element = $('div.doors ul').get(0),
values = {x: [0,0,0], y: [0,0,0]}, // Keep the 3 most recent values.
index = 0,
choices = { // Lookup table to normalize based on device orientation.
x: {'0': ['x', -1], '90': ['y', 1], '180': ['x', 1], '-90': ['y', -1]},
@tvandervossen
tvandervossen / stimulus_notes.md
Last active May 5, 2018 09:21
Quick guide for people who want to add stimulus.js to a Rails 5.2 app but who haven’t used much Modern JavaScript

How to add stimulus.js to a Rails 5.2 app

This might also work or Rails 5.1, but I haven’t tried that yet.

Add the webpacker gem to your Gemfile:

# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker'

Then run (assuming you’re on macOS and using Homebrew):

@tvandervossen
tvandervossen / stimulus_notes.md
Created April 11, 2018 17:47
Quick guide to add stimulus.js to a Rails 5.2 app if you haven’t used much Modern ™ JavaScript before

Add stimulus.js to a Rails 5.2 app

According to https://github.com/rails/webpacker you should:

Add the webpacker gem to your Gemfile:

# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker'

Then run (assuming you’re on macOS and using Homebrew):

@tvandervossen
tvandervossen / gist:50897e4c0ad40b162b033da1f17b7867
Created March 10, 2018 18:02
Trying to understand the motivation behind the BEM class naming convention
In https://css-tricks.com/bem-101/ the following CSS is given as an exampke:
/* Block component */
.btn {}
/* Element that depends upon the block */
.btn__price {}
/* Modifier that changes the style of the block */
.btn--orange {}
@tvandervossen
tvandervossen / read_any_encoding.rb
Created May 22, 2017 13:15
Read and convert any text file to UTF-8 in Ruby
require 'tedrahcu'
data = IO.binread(path)
encoding = Tedrahcu.detect(data)
data.force_encoding(encoding).encode!('UTF-8', invalid: :replace, undef: :replace, replace: '', universal_newline: true)

Ons Medicatiecontrole versie 0.9.1

Controleverzoeken worden nu bij voorkeur aan collega’s binnen je team toegewezen.

Daarnaast zijn er een aantal verbeteringen gedaan aan de performance en stabiliteit. Daarnaast zijn de volgende specifieke problemen verholpen:

  • Op sommige apparaten kwam de preview bij het maken van de foto niet helemaal overeen met de uiteindelijk gemaakte foto. Dit probleem is verholpen, de preview bij het maken van een foto zou nu ook altijd vierkant moeten zijn.
  • Bij het bekijken van een controle in het dossier van de client op Internet Explorer 11 werden de foto’s niet weergegeven. Dit zou nu ook in Internet Explorer 11 moeten werken.
  • Na het updaten of opnieuw installeren neemt de app nu de huidige beschikbaarheid over van de server.