Skip to content

Instantly share code, notes, and snippets.

View biilmann's full-sized avatar
💭
Waiting for pod to exist...

Mathias Biilmann biilmann

💭
Waiting for pod to exist...
View GitHub Profile
@biilmann
biilmann / example.tpl
Created March 18, 2013 21:07
Random shuffle for image galleries
<!-- Content with image gallery field called "image_gallery" -->
<pop:content>
<pop:random:gallery field="image_gallery">
<pop:value resize="fill" width="200"/>
<pop:random:gallery>
</pop:content>
@biilmann
biilmann / template.tpl
Created December 3, 2012 19:58
Using an extension to split a textarea into lines
<pop:content>
<select name="sizes">
<pop:utils:split field="sizes">
<option><pop:value/></option>
</pop:utils:split>
</select>
</pop:content>
@biilmann
biilmann / base.js
Created November 12, 2012 18:08
Base CRM
var PipejumpAuth = "NfE7rqWph0LQKsBEOr2O";
var http = require("http");
exports.submit = function() {
var response = http.request({
url: "https://sales.futuresimple.com/api/v1/contacts",
type: "POST",
headers: {"X-Pipejump-Auth": PipejumpAuth},
data: {
@biilmann
biilmann / gist:3882710
Created October 13, 2012 00:57
JRuby ActiveSupport JSON problem
require 'active_support/json'
{}.to_json.encoding
=> #<Encoding:US-ASCII>
@biilmann
biilmann / gist:3881095
Created October 12, 2012 19:43
Jruby json encoding problem
JSON.parse({s: "can’t be blank"}.to_json)
=> {"s"=>"can\xE2\x80\x99t be blank"}
@biilmann
biilmann / README.md
Created October 5, 2012 02:28
Webpop - Stripe Form

Webpop Stripe Extension

This extension lets you easily setup a payment form with strip integration. No credit-card data will ever touch Webpop's servers, so Stripe can take care of just about all the PCI compliance for you.

Using the extension

Sign up with Stripe, and find your credentials (the public key and the secret key.).

@biilmann
biilmann / auth.js
Created September 25, 2012 21:55
Auth grabbing username/password from entries
exports.authenticate = function() {
if (request.request_method !== "POST" || request.params.logout) return null;
if (request.params.username == null || request.params.password == null) return {error: true, success: false};
var entry = site.entries({from: "users", username: request.params.username})[0];
if (!entry) return {error: true, success: false};
if (request.params.username == entry.username && request.params.password == entry.password) {
request.session.authenticated = true;
}
@biilmann
biilmann / nav.js
Created September 23, 2012 15:27
Navigation extension
exports.sections = function() {
var content = site.content();
if (content.permalink == "/") {
// This is the home page
return null;
} else if (content.parent.permalink == "/") {
// this is a top level section
return content.sections();
} else {
// this is a sub section
@biilmann
biilmann / erb_fix.rb
Created September 21, 2012 22:21
Fix for thread safety issue with ERB
# Monkey patch to make ERB stop using the global TOPLEVEL_BINDING
ERB.class_eval do
def result(b=binding)
if @safe_level
proc {
$SAFE = @safe_level
eval(@src, b, (@filename || '(erb)'), 0)
}.call
else
eval(@src, b, (@filename || '(erb)'), 0)
@biilmann
biilmann / From stdout
Created September 18, 2012 00:11
IndexOutOfBoundsException
Error during failsafe response: ActionView::Template::Error
/Users/mbc/.rbenv/versions/jruby-1.7.0-preview2/lib/ruby/gems/shared/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb:1:in `___sers_mbc__rbenv_versions_jruby_______preview__lib_ruby_gems_shared_gems_actionpack_______lib_action_dispatch_middleware_templates_rescues__request_and_response_erb__5260782_43834_0'
org/jruby/RubyBasicObject.java:1673:in `__send__'
org/jruby/RubyKernel.java:2064:in `send'
/Users/mbc/.rbenv/versions/jruby-1.7.0-preview2/lib/ruby/gems/shared/gems/actionpack-3.0.6/lib/action_view/template.rb:135:in `render'
/Users/mbc/.rbenv/versions/jruby-1.7.0-preview2/lib/ruby/gems/shared/gems/activesupport-3.0.6/lib/active_support/notifications.rb:54:in `instrument'
/Users/mbc/.rbenv/versions/jruby-1.7.0-preview2/lib/ruby/gems/shared/gems/actionpack-3.0.6/lib/action_view/template.rb:127:in `render'
/Users/mbc/.rbenv/versions/jruby-1.7.0-preview2/lib/ruby/gems/shared/gems/actionpac