Skip to content

Instantly share code, notes, and snippets.

View skimbrel's full-sized avatar

Sam Kimbrel skimbrel

View GitHub Profile
ExpectedMethodCallsError: Verify: Expected methods never called:
0. V
1. e
2. r
3. i
4. f
5. y
6. :
7.
8. E
@skimbrel
skimbrel / gist:4170751
Created November 29, 2012 17:53
what the fuck
with mock.patch.object(tests.util, 'datetime', mock.Mock(wraps=datetime)) as mock_datetime:
mock_datetime.utcnow.side_effect = mock_now
# in some module
class Foo(object):
pass
# somewhere else
from some_module import Foo
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
Branch origin/master set up to track local branch iphone-contacts.
If you wanted to make 'iphone-contacts' track 'origin/master', do this:
git branch -d origin/master
git branch --set-upstream-to origin/master
In [2]: re.compile(u'[\U0001f300-\U0001f5ff]')
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-2-1a8eff581d46> in <module>()
----> 1 re.compile(u'[\U0001f300-\U0001f5ff]')
/Users/sam/bamboo-env/lib/python2.7/re.pyc in compile(pattern, flags)
188 def compile(pattern, flags=0):
189 "Compile a regular expression pattern, returning a pattern object."
--> 190 return _compile(pattern, flags)
[14:33:02] <skimbrel> i'm working on implementing an oembed (http://oembed.com/) endpoint for my app. it has to accept a full URL as argument and return some information about the resource. since i already have a route that matches the urls that this will be getting, how do i reuse pyramid's dispatch to extract a matchdict from it?
[14:33:34] <skimbrel> i.e. i have an incoming request to the API that looks like this: http://www.flickr.com/services/oembed/?url=http%3A//www.flickr.com/photos/bees/2341623661/
[14:34:03] <skimbrel> and i want to run the url param through the pyramid dispatch and get the resulting view and matchdict
sa.Index('idx_auth_type_access_token',
user_auth_table.c.auth_type,
user_auth_table.c.access_token,
mysql_length=512)
@skimbrel
skimbrel / gist:6544078
Created September 12, 2013 21:32
Node's REPL needs some work
$ node
> process.nextTick(function() {null.lol;})
undefined
>
repl:1
(process.nextTick(function() {null.lol;})
^
TypeError: Cannot read property 'lol' of null
at repl:1:35
at process._tickCallback (node.js:415:13)
@skimbrel
skimbrel / gist:6732130
Created September 27, 2013 17:35
OS X paste shortcuts for vim
" Dump things into OS X paste buffer
vmap <leader>c :w !pbcopy<CR><CR>
nnoremap <leader>c :.w !pbcopy .<CR><CR>
@skimbrel
skimbrel / gist:6732288
Last active December 24, 2015 02:39
twiml dial example
from twilio import twiml
r = twiml.Response()
with r.dial() as d:
d.number('+14155551234', url='http://example.com')
unicode(r) # u'<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number url="http://example.com/">+14155551234</Number></Dial></Response>'