Skip to content

Instantly share code, notes, and snippets.

View KATT's full-sized avatar
🐱

Alex / KATT KATT

🐱
View GitHub Profile
@KATT
KATT / Stack Trace.js
Created October 29, 2010 09:35
Stack trace...
[WARN] attempted to load: TiUIWebViewProxy
[ERRProjectNameOR] The application has crashed with an unhandled exception. Stack trace:
0 CoreFoundation 0x03749b7c __exceptionPreprocess + 156
1 libobjc.A.dylib 0x0389940e objc_exception_throw + 47
2 ProjectName 0x0008bec4 -[TiModule createProxy:forName:context:] + 768
3 CoreFoundation 0x036ba5cd __invoking___ + 29
4 CoreFoundation 0x036ba4a1 -[NSInvocation invoke] + 145
5 ProjectName 0x00034e3d -[KrollMethod call:] + 736
6 ProjectName 0x0003473b KrollCallAsFunction + 327
7 ProjectName 0x001f6b06 _ZN2TI16TiCallbackObjectINS_8TiObjectEE4callEPNS_10TiExcStateEPS1_NS_7TiValueERKNS_7ArgListE + 550
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
User = require('./UserSchema');
var FriendsSchema = new Schema({
users : [User.ObjectId],
confirmed : { type: Boolean, default: false, index: true },
created : {type: Date, default: Date.now},
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
hashlib = require('hashlib');
var SAFE_COLS_TO_RETURN = function() {
return {
_id:1,
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
UserSchema = require('./User').UserSchema;
var FriendRequest = new Schema({
from : {type: ObjectId, index:true}, // Why does not UserSchema.ObjectId work here, instead of ObjectId?
to : {type: ObjectId, index:true},
@KATT
KATT / CustomerController.php
Created September 14, 2011 08:02
Non-working loginAction()
<?php
// Include parent
require_once 'Mage/Adminhtml/controllers/CustomerController.php';
class MyNamespace_CustomerLogin_CustomerController extends Mage_Adminhtml_CustomerController {
function loginAction() {
$customerID = (int) $this->getRequest()->getParam('id');
@KATT
KATT / NSString+Distance.h
Created November 27, 2011 17:10
NSString+Distance category (using ARC)
//
// NSString+Distance.h
//
// Created by Alexander Johansson on 2011-11-27.
// Based on http://stackoverflow.com/q/5684973/590396
//
#import <Foundation/Foundation.h>
@interface NSString (Distance)
<?php
/**
* Check if content is JSON
*
* @param string $content
* @return boolean
*/
function w3_is_json($content) {
return json_decode($content) !== NULL;
}
// Ajax Get. Cached. And aborts current request
var get = (function($) {
var xhr;
var xhrURL;
var cache = {};
return function(url, callback, jsonp) {
url += ((url.indexOf('?') === -1) ? '?' : '&');
url += jsonp ? 'callback=?' : 'ajax=1';
if (url == xhrURL && xhr.readystate != 4) {
// Already loading stuff, wait for it to finish
if( !window.location.hash && window.addEventListener && document.documentElement.clientWidth <= 500 ){
window.addEventListener( "load",function() {
setTimeout(function(){
window.scrollTo(0, 1);
}, 0);
});
}

Nice ordered list, but hard to maintain

  1. First item
  2. Second item
  3. Third item

Ugly ordered list

  1. First item
  2. Second item