Skip to content

Instantly share code, notes, and snippets.

View dsl-boilerplate.md

DSL Boilerplate

We want something like this:

class LakeSuperior
  include LakeDSL

  lake_name 'Lake Superior'
 fish 'trout'
View waft.js
// moved to: https://codepen.io/motine/pen/RwgrdOx
@motine
motine / cleanup_job.rb
Last active Apr 22, 2021
Simple Rails Monitoring
View cleanup_job.rb
# services/monitoring/cleanup_service.rb
class Monitoring::CleanupService
def self.run
Monitoring::Measurement.where("recorded_at < ?", 3.months.ago).delete_all
end
end
# let this service run nightly
View biorad.json5
// mind the casing: camelCase
// we use floats and integers not strings
// we use null where appropriate
// in regard to 4. "standardized analysis names": when we define a standard format, let's make sure to also standardize this
// similar for 5. "standardized instrument names": let the homogenization layer take care of this and make sure we define standard names for instrument types
{
"name": "GE20_RT3168-3171-3173-3175_20200626_JRU_Prof",
"instrument": "LightCycler480",
"instrumentId": 6078,
"instrumentName": "Prof_6078",
@motine
motine / gist:8af309be7db58b76eb9b571b703acfa6
Created Jul 15, 2020
spec/support/config_capybara.rb
View gist:8af309be7db58b76eb9b571b703acfa6
require 'capybara'
require 'capybara/rspec'
# please see notes in README.md
Capybara.server_host = '0.0.0.0'
Capybara.server_port = '56556'
Capybara.app_host = 'http://localhost:56556'
Capybara.register_driver(:host_chrome) do |app|
caps = Selenium::WebDriver::Remote::Capabilities.chrome('goog:chromeOptions' => {'w3c' => false}, 'browserName' => 'chrome') # we need to set w3c to false so uploads do work; see https://github.com/SeleniumHQ/selenium/issues/7666 and https://stackoverflow.com/questions/58296774/ruby-selenium-webdriver-3-142-6-unable-to-upload-file-due-to-seleniumwebdriv
driver = Capybara::Selenium::Driver.new(app, browser: :remote, url: 'http://host.docker.internal:9515', desired_capabilities: caps)
@motine
motine / Hello.vue
Last active Mar 28, 2020
Rollup multi page bundles
View Hello.vue
<template>
<div class="hello">Hello {{ name }}.</div>
</template>
<script>
export default {
data() { return { name: 'Manfred' } }
}
</script>
View check_lines.rb
BASE_PATH = File.expand_path("~/Repositories/beauty")
LINE_LENGTH_THRESHOLD = 150
above, total = 0, 0
Dir[File.join(BASE_PATH, "**/*.rb")].each do |path|
contents = File.readlines(path)
above += contents.count { |line| line.length > LINE_LENGTH_THRESHOLD }
total += contents.size
end
@motine
motine / simple_matplot_without_x.py
Last active Mar 23, 2016
Matplotlib example (no X needed)
View simple_matplot_without_x.py
# install: `dnf install python-matplotlib` under Fedora 23
# example inspired by: http://matplotlib.org/users/screenshots.html
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t, s)
@motine
motine / README.md
Last active Oct 12, 2021
Redis Pub/Sub with Python (notes for my collegue)
View README.md

Redis Pub/Sub with Python

Overview:

  • Redis supports PUB/SUB
  • It supports pattern matching. Clients may subscribe to glob-style patterns in order to receive all the messages sent to channel names matching a given pattern.

Prerequisites

Assuming Fedora 23.

@motine
motine / project.c
Last active Sep 18, 2015
use STA to print a number.
View project.c
#include "sketchbook.h"
void setup() {
}
void draw() {
int result = 77; // this would be your solution
// use the following code to output the result
char buffer[100];
sprintf(buffer, "%i", result);