Skip to content

Instantly share code, notes, and snippets.

View pegli's full-sized avatar

Paul Mietz Egli pegli

View GitHub Profile
/**
* This file was auto-generated by the Titanium Module SDK helper for Android
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*
*/
package com.example.androidextension;
@pegli
pegli / ComObscureOverlaytestDerpView.m
Created August 28, 2013 18:29
label overlay example
#import "ComObscureOverlaytestDerpView.h"
@implementation ComObscureOverlaytestDerpView
- (void)initializeState
{
label = [[UILabel alloc] initWithFrame:CGRectZero];
label.text = @"hello, world!";
label.backgroundColor = [UIColor greenColor];
[self addSubview:label];
@pegli
pegli / gist:5951901
Last active December 19, 2015 11:59
prototype methods for attachment management
module.exports.afterModelCreate = function(Model) {
Model = Model || {};
Model.prototype.idAttribute = '_id'; // true for all TouchDB documents
Model.prototype.config.Model = Model; // needed for fetch operations to initialize the collection from persistent store
Model.prototype.attachmentNamed = function(name) {
var doc = db.documentWithID(this.id);
if (doc) {
return doc.currentRevision.attachmentNamed(name);
@pegli
pegli / setup.coffee
Last active December 19, 2015 07:38
common kanso setup that includes a validation function
# assumes you have "load": "setup" in your kanso.json
module.exports =
views: require './views'
lists: require './lists'
validate_doc_update: (newDoc, oldDoc, userCtx, secObj) =>
if newDoc._deleted == true
throw { forbidden: 'Docs live forever!' }
@pegli
pegli / gist:5749878
Created June 10, 2013 15:55
emit doc keys in couchdb map function
function(doc) {
for (var i in doc) {
if (i[0] != '_' && doc.hasOwnProperty(i)) {
emit(parseInt(i), null);
}
}
}
@pegli
pegli / MyProxy.java
Last active December 16, 2015 21:59
pass a native function call to a KrollFunction invocation
public void doSomething() {
}
@Kroll.method
public void foogle(KrollFunction callback) {
final MyProxy self = this;
callback.call(this.getKrollObject(), new Object[] {
new KrollFunction() {
public Object call(KrollObject krollObject, Object[] args) {
self.doSomething();
@pegli
pegli / gist:5447998
Last active December 16, 2015 14:20
couchbase-lite-ios internal replication failure
16:12:24.722| Logging mode 2 enabled in domains: {CBL_Router, CBL_URLProtocol, CBLReplication, ChangeTracker, Sync, SyncVerbose}
16:12:24.725| Sync: ReplicatorManager scanning existing _replicator docs...
16:12:24.751| Sync: ReplicatorManager done scanning.
16:12:29.849| Sync: CBL_Puller[http://lite.couchbase./source/] STARTING ...
16:12:29.849| CBLBasicAuthorizer initWith <http://lite.couchbase./source/>
16:12:29.954| Sync: CBL_Puller[http://lite.couchbase./source/]: Going online
16:12:29.954| Sync: CBL_Puller[http://lite.couchbase./source/]: postProgressChanged (0/0, active=1 (batch=0, net=1), online=1)
16:12:29.954| SyncVerbose: CBL_Puller[http://lite.couchbase./source/]: GET _local/235aa4ef8704428da3bcd63596f7efc7269d840f
16:12:29.957| Sync: CBL_Puller[http://lite.couchbase./source/]: postProgressChanged (0/0, active=1 (batch=0, net=1), online=1)
16:12:29.957| CBLReplication: CBLReplication[from http://lite.couchbase./source/]: mode=3, completed=0, total=0 (changed=1)
@pegli
pegli / back.js
Created April 22, 2013 16:51
Alloy page curl animation example
function curlDown(e) {
$.back.close({ transition: Ti.UI.iPhone.AnimationStyle.CURL_DOWN });
}
@pegli
pegli / index.tss
Created March 27, 2013 00:24
header/content/footer example
".container": {
backgroundColor:"white"
},
"#header": {
top: 0,
height: 40,
backgroundColor: 'yellow'
},
@pegli
pegli / eventRow.js
Last active December 14, 2015 13:09
var args = arguments[0] || {};
var event = args.event;
var parent = args.parent;
$.addEventListener('swipe', function(e) {
parent.swipe(e);
}