Skip to content

Instantly share code, notes, and snippets.

@wvengen
wvengen / list.unlist.js
Last active December 24, 2015 10:29
listjs templateEngine adding a css class instead of removing rows; based on JuliusR's work, see https://github.com/foodcoops/foodsoft/pull/180
// for use with listjs 0.2.0
// https://github.com/javve/list.js
// PROBABLY UNFINISHED CODE
List.prototype.templateEngines.unlist = function(list, settings) {
var h = window.ListJsHelpers;
// start with standard engine, override specific methods afterwards
this.superClass = List.prototype.templateEngines.standard;
@wvengen
wvengen / screenshots.rb
Last active August 29, 2015 14:07
Foodsoft screenshot generation (prototype)
# Generate screenshots for documentation (initial prototype)
# store file in spec/integration/
# run with rspec: `rspec spec/integration/screenshots.rb`
# please note that this uses the db_seeds branch from pr foodcoops#315
require_relative '../spec_helper'
require 'fileutils'
SCREENSHOT_DIR = Rails.root.join('doc/user/screenshots')
describe 'screenshots', :type => :feature do
@wvengen
wvengen / extend.sh
Last active January 8, 2024 23:28
Extend non-HiDPI external display above HiDPI internal display
#!/bin/sh
# extend non-HiDPI external display on DP* above HiDPI internal display eDP*
# see also https://wiki.archlinux.org/index.php/HiDPI
# you may run into https://bugs.freedesktop.org/show_bug.cgi?id=39949
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/883319
EXT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^eDP | head -n 1`
INT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^DP | head -n 1`
ext_w=`xrandr | sed 's/^'"${EXT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
@wvengen
wvengen / tddium.rake
Last active August 29, 2015 14:09
Rake task for Heroku deployment on Solano CI
# lib/tasks/tddium.rake
#
# Rake task for Heroku deployment on Solano CI
#
# Pushes successful CI builds on the staging branch to Heroku.
# Set HEROKU_APP_NAME and HEROKU_API_KEY in the environment
# and add the worker's SSH public key the Heroku app's accepted keys.
#
# Enjoy! -- wvengen
@wvengen
wvengen / scanner.rb
Last active February 22, 2024 13:31
Hack to use Android phone as barcode scanner for pc
#!/usr/bin/env ruby
#
# Hack to use Android phone as barcode scanner for pc.
#
# Installation and setup:
# * Enable usb debugging on your Android phone
# * Make sure you have an Android SDK installed
# * Make sure xdotool is installed (apt-get has it) http://www.semicomplete.com/projects/xdotool/
# * Build and install https://github.com/majido/clipper
# * Start service: `adb shell su -c \'am startservice ca.zgrs.clipper/.ClipboardService\'`
@wvengen
wvengen / delegate_assign.rb
Created January 7, 2015 12:08
Active Record mixin to also delegate setters
# Also delegate setters with Rails.
#
# If you find yourself wanting to use this, please look at nested attributes first.
# http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
# When that doesn't fit, you may consider the approach shown here.
#
# Example:
#
# class User < ActiveRecord::Base
# include DelegateAssign
@wvengen
wvengen / install_scrapyd.sh
Last active May 31, 2019 07:27
Installation script for scrapyd
#
# Installation script for scrapyd on Debian/Ubuntu
# http://scrapyd.readthedocs.org/
#
# - Latest scrapyd from Scrapy package repository
# - Password protection with http basic auth
# - HTTPS with self-signed certificate
# - Works on Amazon EC2
#
FQDN=scrapy.example.com
@wvengen
wvengen / create_artifact_bundle_for_maven_central.sh
Last active August 29, 2015 14:18
Create artifact bundle for Maven Central upload
#!/bin/sh
#
# I found the instructions for setting up Maven Central upload in pom.xml too involved.
# This does the job as well, though it requires manually uploading it in Maven Central's
# web interface as an artifact bundle.
#
# Usage:
# 1. Make sure your project is ready and the release version checked out
# 2. Change GPGKEY to point to your key in this script
# 3. Run this script in the directory containing pom.xml
@wvengen
wvengen / genbooks.rb
Last active August 29, 2015 14:26
HTML Book matrix generator
#!/usr/bin/env ruby
#
# Basic script to retrieve book metadata.
#
# Usage: genbooks.rb <isbn> [<isbn> [...]] >books.json
# Outputs json file with book metadata, for use as input to genpage.rb
#
# TODO
# - add bol.com
# - add amazon.com books
@wvengen
wvengen / select2-freeform.png
Last active December 23, 2015 15:45
Form input to choose from existing values, while allowing to add new ones (based on select2).
select2-freeform.png