Skip to content

Instantly share code, notes, and snippets.

View davidwessman's full-sized avatar

David Wessman davidwessman

View GitHub Profile
@davidwessman
davidwessman / update-next.yml
Last active July 29, 2022 15:15
Action to upgrade Gemfile.next.lock
name: Update next
on:
pull_request:
paths:
- "Gemfile.lock"
jobs:
update:
runs-on: ubuntu-20.04
module Minitest
module Reporters
# Based on https://github.com/kern/minitest-reporters/blob/master/lib/minitest/reporters/progress_reporter.rb
# Tries to adhere to https://testanything.org/tap-specification.html
class TapReporter < DefaultReporter
def report
super
puts("TAP version 13")
puts("1..#{tests.length}")
@davidwessman
davidwessman / .circleci-config.yml
Created August 13, 2017 14:54
CircleCI 2.0 setup
version: 2
jobs:
build:
working_directory: ~/mowers
docker:
- image: circleci/ruby:2.4.1-node
environment:
PGHOST: 127.0.0.1
PGUSER: mower
RAILS_ENV: test
const calendar = {
initialize() {
const calendars = document.getElementsByClass('fullcalendar');
Array.from(calendars).forEach(function(cal) {
const place = cal.dataset.place;
cal.html(''); // Remove any previous calendar
cal.fullCalendar({
eventSources: [{ url: '/events/feed.json?place=' + place }],
other_options:...
});
@davidwessman
davidwessman / Systemd for Sidekiq
Created June 14, 2017 14:11
Systemd setup for Sidekiq with Capistrano
# Setup Sidekiq for rails on Debian
# This setup uses systemd to start via terminal but also via the deploy system Capistrano.
# The reload-task will not actually reload the service, but is used to prepare Sidekiq for shutdown
# There exists two services to allow for both staging and production environment.
# The application uses different redis databases by using different numbers to connect,
# i.e. localhost:6379/0 or :6379/1, which are set in each applications environment variables.
# Any questions about the configuration? Hit me up
# David Wessman, Lund , 2016-09-07, [email protected]
class OrderItem < ActiveRecord::Base
belongs_to :product, required: true
belongs_to :order, required: true
has_one :user, through: :order
validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 }
validate :user_limited
before_save :finalize
def unit_price
development:
adapter: mysql2
encoding: utf8
database: db/app_development
username: root
password:
host: localhost
production:
adapter: mysql2
@davidwessman
davidwessman / black_and_white.py
Last active November 23, 2015 17:31
Black and white plots in Python.
def setAxLinesBW(ax):
"""
Take each Line2D in the axes, ax, and convert the line style to be
suitable for black and white viewing.
"""
MARKERSIZE = 3
COLORMAP = {
'b': {'marker': None, 'dash': (None,None)},
'g': {'marker': None, 'dash': [5,5]},
@davidwessman
davidwessman / export_example.m
Created November 16, 2015 19:45
Export Matlab figure as PDF
% This needs to be set to be able to print
fig = figure;
% If you want multiple plots in the figure
hold on;
I = 0:1:9;
blue = [0, 0.048, 0.143, 0.129, 0.236, 0.333, 0.479, 0.512, 0.582, 0.678];
red = [0, 0.095, 0.106, 0.171, 0.156, 0.227, 0.270, 0.300, 0.366, 0.384];
plot(I, blue,'+b')
@davidwessman
davidwessman / import_matlab.tex
Last active December 10, 2015 07:57
Import Matlab to LaTeX
% https://www.ctan.org/pkg/listings
\usepackage[procnames]{listings}
\usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
% Python style for highlighting
\newcommand\matlabstyle{\lstset{
language=Matlab