Skip to content

Instantly share code, notes, and snippets.

View hojberg's full-sized avatar
🔮
Building UIs for Unison

Simon Højberg hojberg

🔮
Building UIs for Unison
View GitHub Profile
<?php
/*
Template Name: Page with downloads
*/
?>
<?php the_post(); ?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
<div id="mainContent">
<!-- anchor -->
<a class="button_init normal" onclick="$('pre_button').hide(); $('add_quick_switch_form').show();" type="button"><span>&nbsp;Add..</span><em>&nbsp;</em></a>
<!-- button -->
<button class="button_init normal" onclick="" type="submit"><span>&nbsp;Update User</span><em>&nbsp;</em></button>
var app = wrench.appify({
init: function () {
// this will run after in the boot up process initiated by app.run();
},
users: {
list: route("users/list/").to(function () {
// fetch all the users and show them on the page
}),
# this assert
assert ActionMailer::Base.deliveries.present?
# gives this error when running tests
NoMethodError: undefined method `deliveries' for #<TMail::Mail:0x1094e3a90>
/test/unit/user_test.rb:69:in `test_should_create_token_and_email'
(function () {
W.GET("/", function () {
$('#app').html("Hello World");
});
W.GET("#users", function () {
$('#app').html("users");
});
# http://en.wikipedia.org/wiki/Bank_card_number
CARDTYPES = {
:visa => /^4(?!571|917|913|508|844|17500)[0-9]{12,15}$/,
:mastercard => /^5(?!4130380)[1-5][0-9]{14}$/,
:dinersclub => /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
:amex => /^3[47][0-9]{13}$/,
:discover => /^6(?:011|5[0-9]{2})[0-9]{12}$/,
:visadankort => /^4571[0-9]{12}$/,
:dankort => /^5019[0-9]{12}$/,
:eurocardbyinvitation => /^54130380\d{8}/,
# Classical
class Animal
color: 'brown'
sleep: (minutes) ->
"sleeping for " + minutes + " minutes"
class Horse extends Animal
legs: 4
gallop: ->
"galloping happily"
@hojberg
hojberg / sandboxtesting2.js
Created February 13, 2010 12:29
how to make testing possible of sandboxed api #2
(function () {
var PublicAPI = window.PublicAPI = {};
PublicAPI.publicFunction = function (foo) {
PrivateAPI.privateFunction(foo);
return 'bar';
};
var PrivateAPI = {};
PrivateAPI.privateFunction = function (foo) {
@hojberg
hojberg / sandboxtesting1.js
Created February 13, 2010 12:27
how to make testing possible of sandboxed api #1
(function () {
var PublicAPI = window.PublicAPI = {};
PublicAPI.publicFunction = function (foo) {
PrivateAPI.privateFunction(foo);
return 'bar';
};
var PrivateAPI = {};
PrivateAPI.privateFunction = function (foo) {
// Simplified example
App.Controllers.Sales = Object.create(App.Controllers.Master, {
all: function () {
// Find all method on Sale initiates a callback when data has returnes
App.Models.Sale.findAll(function () {
// render method on $ initiate a callback when the template has been loaded in the dom
$('contentarea').render("sales/all", function (sales) {
// Pure template autoRender method finds some id and auto loops over and array
$('#id-of-a-list-of-sales').autoRender(sales);