Skip to content

Instantly share code, notes, and snippets.

@evanlong
evanlong / info.evanlong.apps.sandbox.plist
Last active February 4, 2016 03:18
poor man's cloud.app
<!-- This file goes in ~/Library/LaunchAgents -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>KeepAlive</key>
<true/>
@evanlong
evanlong / main.py
Created November 29, 2011 04:26
twitter image fetcher
#!/usr/bin/env python
""" Sample calls:
http://twimgproxy.appspot.com/image?screen_name=evanlong
http://twimgproxy.appspot.com/image?user_id=20
"""
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.api.urlfetch import fetch
@evanlong
evanlong / k03.js
Created November 4, 2011 07:56
plane test
navigator.getcurrentposition(function(p){console.info(o)})
@evanlong
evanlong / magic.m
Created October 10, 2011 22:14
makes stuff work
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
}
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
}
class MyClass1 {
private int _fastCounter = 0;
private int _slowCounter = 0;
public synchronized void methodSlow() {
System.out.println("slowCounter.start " + _slowCounter);
try {
Thread.sleep(5*1000);
}
catch(Exception e) {
@evanlong
evanlong / tylerdb.c
Created July 29, 2011 07:14
Tyler DB
#include <stdio.h>
#include <socketshit.h>
int main(int argc, char** argv)
{
while(true) {
int fd = listen(internet);
superbuffer_t buff = read(fd);
write(dbfile, buff);
//fsync(dbfile); //took this out. was slowing me down
@evanlong
evanlong / webapi.py
Created June 7, 2011 00:50
Sample code for dealing with REST apis
import urllib
import re
class WebApiOpener(urllib.FancyURLopener):
'''
Provides a way for HTTP Basic authentication to take place without
prompting the user for a username and password like FancyURLopener
would.
'''
def __init__(self, username, password):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>1 1 1 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@evanlong
evanlong / vtablefun.cpp
Created February 24, 2011 06:15
Showing off vtables for stackoverflow answer.
#include <iostream>
using namespace std;
class A
{
public:
int a1;
int a2;
virtual void A1() { cout << "A->A1" << endl; }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...code to dequeue and setup a UITableViewCell removed...
//retrieve our Core Data representation of the photo
Photo* photo = [Photo photoWithFlickrData:pictObj inManagedObjectContext:context];
if (photo.thumbnail) {
cell.imageView.image = [UIImage imageWithData:photo.thumbnail];
}
else {