Skip to content

Instantly share code, notes, and snippets.

View andrewkowalik's full-sized avatar
👋

Andrew Kowalik andrewkowalik

👋
View GitHub Profile
import mock
class foobar(object):
def show_me(self):
print('the money')
no_spec_mock = mock.MagicMock()
no_spec_mock.foobar.called
class Foobar(serializers.ModelSerializer):
company_type = serializers.SerializerMethodField('get_company_type')
company_code = serializers.Field(source='id')
class Meta:
model = Customer
fields = ('id')
def get_company_type(self):
return 'consumer'
@andrewkowalik
andrewkowalik / keybase.md
Created February 27, 2014 16:46
keybase.md

Keybase proof

I hereby claim:

  • I am infecto on github.
  • I am drewkowalik (https://keybase.io/drewkowalik) on keybase.
  • I have a public key whose fingerprint is 2EED E04E E044 665C 751A 3A32 4B19 3130 F0B3 7E3E

To claim this, I am signing this object:

@andrewkowalik
andrewkowalik / gist:5950249
Created July 8, 2013 16:20
Log all Backbone.js events in a given model/collection
that.listenTo(that.model.get('lists'),'all', function(en) {
console.log(en);
});
https://github.com/addyosmani/backbone-fundamentals
@andrewkowalik
andrewkowalik / test
Last active December 18, 2015 21:29
bind examples
function bind(func, object) {
return function () {
return func.apply(object, arguments);
};
}
Function.prototype.myBind = function (context) {
var that = this;
return function () {
return that.apply(context, arguments);
@andrewkowalik
andrewkowalik / .sqliterc
Created June 12, 2013 18:24
sqlite3 defaults, save in home directoy
.headers on
.mode column
@andrewkowalik
andrewkowalik / gist:5702775
Created June 4, 2013 00:51
SQLZoo SELECT from Nobel Tutorial #8 solution using single join, no sub-query
SELECT DISTINCT a.yr
FROM nobel a
LEFT OUTER JOIN nobel b
ON a.yr=b.yr
AND b.subject NOT IN ('Economics','Literature','Medicine','Peace','Physics')
WHERE b.subject IS NULL
AND a.subject = 'Physics'
@andrewkowalik
andrewkowalik / chess stalemate
Created May 22, 2013 17:35
Chess stalemate moves
# c2 c4
# h7 h5
# h2 h4
# a7 a5
# d1 a4
# a8 a6
# a4 a5
# a6 h6
# a5 c7
@andrewkowalik
andrewkowalik / gist:5625633
Last active December 17, 2015 14:39
Josephus Problem, add one to method return.
def josephus(count, skip)
#catch errors
return 0 if count == 1
#base case
return count-1 if skip == 1
#generally calls base case
if skip>count
return (josephus(count-1,skip)+skip) % count