Skip to content

Instantly share code, notes, and snippets.

View pads's full-sized avatar

Ben Paddock pads

View GitHub Profile
@pads
pads / di-console.js
Created April 16, 2014 10:21
Angular Dependency Injection - Console Access
var injector = angular.element('[data-ng-app="myAppName"]').injector();
var dependency = injector.get('myDependencyName');
dependency.doSomething();
function NewPane(sub, socketuri, dontcache) {
var type = sub.charAt(0),
uri = '/search?q=',
cached = localStorage.getItem('tapas'),
socket, title, el;
cached = (cached && cached.split(',')) || [];
cached.push(sub);
if (!dontcache) {
localStorage.setItem('tapas', cached.join(','));
}
@pads
pads / Tiddler.coffee
Created August 31, 2013 16:40
Learning CoffeeScript the Tiddler way...
class Tiddler
# @ is shorthand for this.title = title
constructor: (@title, @bag) ->
# Other properties attached to prototype
text: ""
tags: []
# toString() function returns properties
# Fat arrow ensures 'this' inside the function is always bound to the instance
@pads
pads / archive_bag.py
Last active December 20, 2015 17:18
Archive tiddlers from one bag to another, based on age.
import logging
from datetime import datetime
from tiddlywebplugins.tiddlyspace.config import config
from tiddlyweb.store import Store
from tiddlyweb.model.tiddler import Tiddler
now = datetime.utcnow()
# Make sure this is writable by the user running this
filename = 'archive-%s-%s-%s.log' % (now.year, now.month, now.day)
@pads
pads / TiddlerInclude.html
Created July 29, 2013 16:12
Quick spike of using an AJAX include pattern to load tiddlers as content in a page, based on tag and title.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ajax Include Spike</title>
</head>
<body>
<div data-tiddlers="fragment">
<div data-tiddler="Fragment2">tiddler two loaded here</div>
<div data-tiddler="Fragment3">tiddler three loaded here</div>
@pads
pads / missing_ldap_users.py
Created July 24, 2013 15:38
Print a list of users not found in an LDAP directory, given a file where each line is a user ID that would map to a valid CN in the LDAP directory.
import ldap
ldap_host = '<host>'
ldap_port = '389'
base_dn = '<ou=something,ou=com>'
username = '<username>'
password = '<password>'
filename = '<file_with_list_of_user_ids>'
@pads
pads / transparency.css
Last active December 18, 2015 16:39
A collection of CSS hacks
/* For IE7 & 8 */
.transparent-black {
/* IE7 needs an element to be positioned in order to apply a transparent background, this is a work-around */
zoom: 1;
background-color: #000;
filter: alpha(opacity=70);
/* Fill the parent container */
position: absolute;
top: 0;
left: 0;
@pads
pads / ts-tiddler-loop.sh
Created May 21, 2013 13:07
This simple script came about as a way to find out what would happen between twikifier and tiddlyspace when testing failure scenarios (such as killing processes randomly).
#!/bin/sh
if [ $# -lt 3 ]; then
echo "Usage: `basename $0` space_url port tiddler_title"
exit 1
fi
SPACE_URL=$1
PORT=$2
TIDDLER=$3
@pads
pads / tiddlywebconfig.py
Last active December 17, 2015 06:48
Backup of my dev instance tiddlyspace config
# A basic configuration.
# `pydoc tiddlyweb.config` for details on configuration items.
config = {
'system_plugins': ['tiddlywebplugins.tiddlyspace'],
'secret': '19ea4f518345d7f89c99a679b5957ebb6efc4b2a',
'twanager_plugins': ['tiddlywebplugins.tiddlyspace'],
'server_host': {
'scheme': 'http',
'host': 'tiddlyspace.org',
@pads
pads / byod.sh
Last active December 17, 2015 04:09
A script to automate the bringing of one's domain over to tiddlyspace
#!/bin/sh
# This script writes a domain name to the Nginx aliases file
# and adds the corresponding tiddler to the MAPSPACE bag.
# Run ./byod.sh without any arguments for usage.
DOMAIN=$1
TARGET_SPACE=$2
WWW_DOMAIN=$3