Skip to content

Instantly share code, notes, and snippets.

@thenoseman
thenoseman / fof-rulestate.js
Last active January 26, 2017 13:36
Form-O-Fill : Reading the runtime state in before functions
var rules = [{
"name": "The default rule",
"url": "https://form-o-fill.github.io/tutorial/tour-1.html",
"autorun": true,
"before": function(resolve, context) {
console.warn("Rule manually triggered? %s", context.state.ruleManuallyTriggered);
console.warn("Rule automatically triggered? %s", context.state.ruleAutomaticallyTriggered);
console.warn("Rule part of workflow? %s", context.state.ruleRunningInWorkflow);
resolve();
},
// Since this is a Angular1 add don't use "autorun" since the app won't
// be completely initialized when Form-O-Fill runs.
// If you must use "autorun" please check "Match rules only when all assets are loaded" in settings :)
// or use "content" matching and "automatic rematch".
var rules = [{
"url": "https://secure.sonnet.ca/#/quoting/auto/vehicle_details",
"name": "https://secure.sonnet.ca/#/quoting/auto/vehicle_details",
"fields": [{
// #month-1Option0 = January, #month-1Option1 = February, ...
"selector": "#month-1Option0",
@thenoseman
thenoseman / fof-amazon-infringment-fill.js
Created September 13, 2016 19:42
fof-amazon-infringment-fill.js
var rules = [{
"url": "https://www.amazon.com/gp/help/reports/infringement",
"name": "Amazon - Report Infringments",
"before": function(resolve) {
var asinsInput = prompt("Enter a comma or newline sep. list of ASINS");
var asins = asinsInput.trim().split(/[\t\n,]/);
resolve(asins);
},
"fields": [{
"selector": "#inputASIN",
@thenoseman
thenoseman / fof-extract-param-from-url.js
Created September 13, 2016 09:10
Form-O-Fill : Extract and use a URL GET parameter
var rules = [{
// Go to https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=rainbow+pony
// URL parameters are: url=search-alias%3Daps&field-keywords=rainbow+pony
"url": /www.amazon.com/,
"name": "Demo : Extract parameters from URL",
"fields": [{
"selector": "input[name=field-keywords]",
"value": function($element) {
// Construct via this nice helper : https://developer.mozilla.org/de/docs/Web/API/URLSearchParams
var params = new URLSearchParams(window.location.search);
@thenoseman
thenoseman / hash_core_ext.rb
Created June 23, 2016 09:21
Add #deep_find and #deep_transform_values and #deep_transform_keys to Hash
class Hash
def deep_transform_values(&block)
_deep_transform_values_in_object(self, &block)
end
def deep_transform_values!(&block)
_deep_transform_values_in_object!(self, &block)
end
def deep_find(key)
@thenoseman
thenoseman / copy_from_engine_to_app_task.rb
Created June 15, 2016 14:00
Rake task to copy assets from engine to app without sprockets involved
require "rake/tasklib"
class CopyToAppRakeTask < ::Rake::TaskLib
attr_accessor :app
def initialize(app = nil)
self.app = app
define
end
@thenoseman
thenoseman / thenoseman-arduino-eclipse-product-broken-avr-ar-params.patch
Created January 13, 2016 09:38
"Fix" broken archiver in arduino eclipse plugin / product
diff --git a/it.baeyens.arduino.core/src/it/baeyens/arduino/toolchain/ArduinoGnuMakefileGenerator.java b/it.baeyens.arduino.core/src/it/baeyens/arduino/toolchain/ArduinoGnuMakefileGenerator.java
index 8921518..dac70d7 100644
--- a/it.baeyens.arduino.core/src/it/baeyens/arduino/toolchain/ArduinoGnuMakefileGenerator.java
+++ b/it.baeyens.arduino.core/src/it/baeyens/arduino/toolchain/ArduinoGnuMakefileGenerator.java
@@ -5,6 +5,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.lang.Exception;
import java.util.ArrayList;
@thenoseman
thenoseman / patch-edid.rb
Created October 28, 2015 19:44 — forked from adaugherity/patch-edid.rb
Generate a patched monitor definition file with forced RGB. Might solve display resolution issues for external monitors on macbooks
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@thenoseman
thenoseman / simeonc-teardown-in-fof.js
Created October 9, 2015 19:09
TeardownContent function in FoF
var rules = [{
// This demonstrates:
// - usage of setupContent
// - usage of context.storage in setupContent/teardownContent/value function
// - the fact that all three functions have the same context available
"url": /20-teardown-content/,
"name": "Teardown content function",
"setupContent": function() {
context.storage.set("setBySetupContent", "setBySetupContent");
},
@thenoseman
thenoseman / openssl pkcs8 -topk8 -nocrypt -in privkey.pem -out privkey2.pem 76
Created October 1, 2015 09:07
generate a valid pem file for chrome extension packing
openssl genrsa -out privkey.pem 768
openssl pkcs8 -topk8 -nocrypt -in privkey.pem -out privkey2.pem