Skip to content

Instantly share code, notes, and snippets.

View dobesv's full-sized avatar

Dobes Vandermeer dobesv

View GitHub Profile
@dobesv
dobesv / Bouncy.elm
Last active August 29, 2015 14:19
Bouncing ball comparisons
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Signal exposing (..)
import Time
import Mouse
gravity = 40.0
initialState = {
@dobesv
dobesv / index.md
Last active August 29, 2015 14:21
Use LeadPages + Stripe + WordPress + Gravity Forms together

This allows you to set a LeadPages button to pop up a Stripe payment form, and then send the data to your WordPress Gravity Forms (with Stripe Add-On) to capture the payment and record the form submission. This means you can also add other feeds to the same form to add people to a mailing list and so on.

Usage:

  1. You will require WordPress with Gravity Forms and the Gravity Forms Stripe Add-On
  2. Create a form with a credit card field, an email field, a "total" field, and a product "drop down" field.
  3. Mark the product "drop down" field as "Allow field to be populated dynamically" in the Advanced tab
  4. For the product "drop down" it doesn't matter what products you have for this purpose, the values will be filled from this script
  5. Copy the appropriate form and field IDs into the values below
  6. Also fill in the rest of it as you please with links to an image, your product name, price and so on
@dobesv
dobesv / less-rhino-1.1.4.js
Created September 17, 2011 13:28
Rhino compatible version of Less 1.1.4 (LESS is a CSS preprocessor, see https://github.com/cloudhead/less.js)
//
// LESS - Leaner CSS v1.1.4
// http://lesscss.org
//
// Copyright (c) 2009-2011, Alexis Sellier
// Licensed under the Apache 2.0 License.
//
//
// Stub out `require` in rhino
@dobesv
dobesv / test.html
Created September 17, 2011 14:02
Some whitespace relating testing with jadejs
<div class="test"><!-- Adding text using | results in a newline AFTER (not before) each line-->foo
bar
baz
</div>
<div class="test"><!--I thought I could use extra | lines to insert additional whitespace but
this currently outputs | characters into the result.
-->|
foo
|
@dobesv
dobesv / purejsbug.html
Created October 25, 2011 05:17
Example of an issue in the purejs templating engine where a css class that is modified by the directives cannot be used in selector matching
<html>
<head>
<title>Test</title>
</head>
<body>
<div id='container'>
<div class='foo'>
<div class='bar'>
bla
</div>
@dobesv
dobesv / digestFile.js
Created January 3, 2012 08:41
Sample connect/express middleware to add a digest to all file uploads. Useful for change detection, that kind of thing. Also an example of calculating a hash (SHA1 or MD5) on a file.
var crypto = require('crypto'),
fs = require('fs');
/**
* Calculate the digest of a given file as a hex string.
*
* @param filename Name of the file to read
* @param {String} [algo='sha1'] Hash algorithm (e.g. 'md5' or 'sha1')
* @param {function(Exception,String) cb Callback which is invoked with (err,hash)
*/
@dobesv
dobesv / connect-intercept.js
Created January 23, 2012 05:52
Function to intercept the response from the next() call.
var events = require('events');
/**
* When operating as a middleware our "origin" server is the next handler in the chain. This
* patches the given response object so that when the next handler writes to it we treat that
* as a response from the origin server.
*
* This replaces the writeHead, setHeader, removeHeader, write and end methods
* on the given response so that it can store the response in the cache and returns
* an object that be used to listen for the next() handler writing data and to send
@dobesv
dobesv / CoroutineDslPlugin.fan
Created March 2, 2012 16:19
Changes I made to the Fantom compiler module to make it easier to create my DSL
using compiler
class CoroutineDslPlugin : DslPlugin
{
new make(Compiler c) : super(c) {}
override Expr compile(DslExpr dsl)
{
src := dsl.src
loc := dsl.srcLoc
@dobesv
dobesv / MmapBuf.fan
Created March 8, 2012 02:19
Add Buf subclass supporting any kind of java.nio.ByteBuffer (not just MmapByteBuffer)
package fan.sys;
import java.nio.MappedByteBuffer;
public class MmapBuf extends NioBuf {
MmapBuf(File file, MappedByteBuffer mmap) {
super(mmap);
this.file = file;
this.mmap = mmap;
@dobesv
dobesv / CallResolver-unknown-type.patch
Created March 9, 2012 04:54
Handle unknown type during ResolveCall
diff -r 7b06445b390c src/compiler/fan/util/CallResolver.fan
--- a/src/compiler/fan/util/CallResolver.fan Thu Mar 08 16:54:10 2012 -0500
+++ b/src/compiler/fan/util/CallResolver.fan Fri Mar 09 12:53:30 2012 +0800
@@ -71,6 +71,12 @@
ffiCoercion
return result
}
+ catch(UnknownTypeErr err)
+ {
+ expr.ctype = ns.error