Skip to content

Instantly share code, notes, and snippets.

@gronnbeck
gronnbeck / gist:3155694
Created July 21, 2012 12:19
Build a request with custom cookie header... Trying to..
NSURL *url = [NSURL URLWithString:@"ws://localhost:8080/api/v0/_sync"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
NSString *u = @"ewogICAgImlzX2FkbWluIjogZmFsc2UsIAogICAgInVzZXJfaWQiOiAzMTAwNTIwMTg3LCAKICAgICJlbWFpbCI6ICJub25fYWRtaW5AaG9vcGxhLm5vIiwgCiAgICAiZGF0YSI6IG51bGwsIAogICAgIm9yZ2FuaXphdGlvbnMiOiBbCiAgICAgICAgWwogICAgICAgICAgICAxOTE0NzgzNjkzLCAKICAgICAgICAgICAgIm9yZ2FuaXphdGlvbjE3NSIsIAogICAgICAgICAgICB0cnVlCiAgICAgICAgXQogICAgXQp9";
NSMutableDictionary *cookieProperties = [NSMutableDictionary dictionary];
[cookieProperties setObject:@"u" forKey:NSHTTPCookieName];
[cookieProperties setObject:u forKey:NSHTTPCookieValue];
[cookieProperties setObject:@"localhost" forKey:NSHTTPCookieDomain];
[cookieProperties setObject:@"localhost" forKey:NSHTTPCookieOriginURL];
[cookieProperties setObject:@"/" forKey:NSHTTPCookiePath];
@gronnbeck
gronnbeck / gist:3155773
Created July 21, 2012 13:01
Skjer noe feil når jeg prøver å bruke WS mot serveren
* Beskrivelse *
Prøver å få koblet til _sync-endpointet via WS. Men det er ikke ut til å fungere som det skal.
* Prosedyre *
1. Auth via REST, mottar Cookie
2. Oppretter WS med _sync endpoint med Cookie fra (1)
3. Får beskjed om at oppkobling med WS var vellykket
4. Klienten sender {"subscribe":{"events":{"2090034406":0}}} til serveren
5. Klienten venter lenge, får ikke noe svar
6. Klienten får beskjed om at socketen lukket seg, uten en error melding.
@gronnbeck
gronnbeck / gist:3159958
Created July 22, 2012 15:14
Traceback fra når jeg prøver å få ticket
2012-07-22T15:13:08,505 [ERROR] [hoopla.sync ] Unhandled exception in messageReceived. Traceback follows
Traceback (most recent call last):
File "/Users/gronnbeck/Development/hoopla/backend/hoopla/sync.py", line 157, in messageReceived
yield self._handle_subscribe(message['subscribe'])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/defer.py", line 1020, in _inlineCallbacks
result = g.send(result)
File "/Users/gronnbeck/Development/hoopla/backend/hoopla/sync.py", line 170, in _handle_subscribe
if organization_ids - set(id for id, identifier, is_admin in self.get_current_user().get('organizations')):
TypeError: 'NoneType' object is not iterable
@gronnbeck
gronnbeck / gist:3160076
Created July 22, 2012 15:52
Debug outprint
2012-07-22 17:52:06+0200 [HTTPConnection,1,127.0.0.1] Using ws spec (draft 17)
2012-07-22 17:52:06+0200 [HTTPConnection,1,127.0.0.1] Someone connected {u'user_id': 3907156748, u'is_admin': True, u'email': u'admin@hoopla.no', u'organizations': [], u'data': None}
2012-07-22 17:52:06+0200 [HTTPConnection,1,127.0.0.1] Received {"subscribe":{"events":{"1177052212":0}}}
2012-07-22 17:52:06+0200 [HTTPConnection,1,127.0.0.1] bumping timer
2012-07-22 17:52:06+0200 [HTTPConnection,1,127.0.0.1] Handling subscribe.
2012-07-22 17:52:06+0200 [HTTPConnection,1,127.0.0.1] Waiting for event_hose
2012-07-22 17:52:06+0200 [-] Organization IDs for events: set([])
2012-07-22 17:52:06+0200 [-] Subscribing to {u'1177052212': 0}
2012-07-22 17:52:06+0200 [-] Getting missing events for {1177052212: 0}
2012-07-22 17:52:06+0200 [-] Finding tickets and beeps for 1177052212 with txid >= 0
2012-07-22 18:55:48+0200 [connection] Got NOTIFY: Notify(81115, 'beeps', '{"txid_min": 2880, "rows": [{"event_id": 884605232, "beeped": "2012-07-22 18:55:48.564031+02", "data": null, "ticket_id": 225309442757, "txid": 2880}], "txid": 2880}')
2012-07-22 18:55:48+0200 [connection] Got a beeps-event
2012-07-22T16:55:48,778 [ERROR] [hoopla.listeners ] Unhandled exception in _keep_listening. Traceback follows
Traceback (most recent call last):
File "/Users/gronnbeck/Development/hoopla/backend/hoopla/listeners.py", line 100, in _keep_listening
except Excpetion as e:
NameError: global name 'Excpetion' is not defined
2012-07-25T07:15:35,701 [ERROR] [hoopla.sync ] Unhandled exception in messageReceived. Traceback follows
Traceback (most recent call last):
File "/Users/gronnbeck/Development/hoopla/backend/hoopla/sync.py", line 178, in messageReceived
yield self._handle_beeps(message['beeps'])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/internet/defer.py", line 1018, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/python/failure.py", line 350, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/Users/gronnbeck/Development/hoopla/backend/hoopla/sync.py", line 196, in _handle_beeps
yield self._write_beeps(beeps)
➜ ~ curl -c /tmp/hoopla -b /tmp/hoopla -D- -X PATCH $DEV_API_URL/organizations/1141995721/users -d '{"user_id": 4050666423, "data": null, "is_admin": true }'
HTTP/1.1 405 Method Not Allowed
Content-Length: 131
Content-Type: application/json; charset=utf-8
Server: cyclone/1.0-rc10
{
"msg": "specify user_id to update. use POST without user_id to add new member",
"ok": false,
"error": "BadMethod"
old_string = "fuckdsfsf dsknsfsd kjh jkh jkh jkh gf"
new_string = []
count = 0
words = 0
last = 0
for a in old_string.split(" "):
words = words + 1
if (count + len(a) > 80): continue
new_string.append("".join(a[last, words]))
last = words
#if STAGING
#if TARGET_IPHONE_SIMULATOR
NSString *baseString = @"www.hoopladev.no/";
#else
NSString *baseString = @"www.hoopladev.no/";
#endif
#else
#if DEVELOP
#if TARGET_IPHONE_SIMULATOR
NSString *baseString = @"dev.hoopla.no/";
from sys import stdin, stderr
import traceback
class Node:
def __init__(self):
self.barn = {}
self.posi = []
def bygg(ordliste):
hashmap = {}