This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Canonical location: https://gist.github.com/kljensen/4434992 | |
########################################################## | |
# | |
# This is a shell script for keeping a journal that is | |
# * plaintext, | |
# * time-stamped, | |
# * encrypted, and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We need to create Array.extract if it doesn't already exist | |
class Array | |
# Delete some of our items and return (or "extract") a new array holding the deleted items. | |
# Very similar to partition, but instead of returning copies, it modifies the original list | |
def extract | |
extracted = [] | |
# reverse our deletion so indexes don't get messed up while we're deleting | |
(length - 1).downto(0) do |idx| | |
item = self[idx] | |
extracted << delete_at(idx) if yield(item) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# each_with_index is useful, so why not inject_with_index? | |
module Enumerable | |
def inject_with_index(memo) | |
each_with_index {|obj, idx| memo = yield(memo, obj, idx)} | |
memo | |
end | |
end | |
def passes_lun?(cardnum) | |
digits = cardnum.gsub(/\D/,'').reverse.split('').map(&:to_i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CODE_FOUND_AT = "https://gist.github.com/1320074 " | |
CREATED_BY = " Created by [email protected]" | |
LONGLINE = 630 | |
-- Use this function to perform your initial setup | |
function setup() | |
print(string.format(CODE_FOUND_AT..CREATED_BY)) | |
iparameter("dimension",0,5) | |
iparameter("sides",3,6) | |
lentab = {0,0, 630, 500, 450, 450 } | |
dirtab = {0,0, -120, -90, -72, -60} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'base64' | |
class Object | |
def e64 str | |
Base64.encode64(str).chomp | |
end | |
def d64 str | |
Base64.decode64 str | |
end | |
def rot13 str | |
rotN(13,str) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Each scrap would at least define its inputs, outputs and markup. | |
// Additionally, it would contain any scrap-specific functionality. | |
// Like Rails partials, they could be chained together to build | |
// higher-level functionality. | |
var user_form = Scrap.define({ | |
input: { | |
model: 'hash containing the current state of the user being edited', | |
collection: 'array of all the *other* users, for uniqueness checking', | |
}, | |
output: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var user_dialog = Dialog.define({ | |
input: { | |
edit: 'boolean telling us whether we are editing or adding (default)', | |
model: 'hash containing the current state of the user being edited', | |
collection: 'array of all the *other* users, for uniqueness checking', | |
ok_location: 'bottom (default) or top of the dialog box' | |
}, | |
output: { | |
ok: 'boolean as to whether the user okayed their changes or not', | |
model: 'hash containing the updated state of the user being edited' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var user_dialog = Dlg.run({ | |
markup: [{ | |
div: {id: 'user_dialog', ui: { | |
table: [ | |
{tr: [ | |
{td: {_class:'field_name', value:'Name'}}, | |
{td: [ | |
{input: {type:'text', id:'name', size:40, | |
validation: 'cannot_be_blank'}}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Markup generated from simple_markup.js --> | |
<div id='user_dialog'> | |
<table> | |
<tr> | |
<td class='field_name'>Name</td> | |
<td> | |
<input type='text' id='name' size=40 /> | |
<span id='err_msg_for_name' class='err_msg' /> | |
</td> | |
</tr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example markup for user edit dialog. Simple tags, with no specified class or id | |
// just contain an array holding their nested markup. More complex ones hold a hash | |
// with tag fields and a "ui" field holding their nested markup. This data would be | |
// recursed over to generate the expected HTML markup. | |
var markup = { | |
div: {id: 'user_dialog', ui: { | |
table: [ | |
{tr: [ | |
{td: {_class:'field_name', value:'Name'}}, | |
{td: [ |