This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var yourself = { | |
fibonacci: function(n) { | |
return this._fib(n)[0] | |
}, | |
_fib : function(n) { | |
if (n === 0) { | |
return [0, 1] | |
} else { | |
let half = this._fib(Math.floor(n / 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Martin Wezowski: | |
"We need to be visioneers, empathic and human". | |
| | | |
| | * <- linear growth (what is in heads) | |
| / * | |
| * / | |
| * / | |
| * / | |
| * ____/ <- exponential growth (real life) | |
| * ______/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import cProfile | |
import pstats | |
import StringIO | |
import random | |
import string | |
def make_unique_orig(list=[]): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
(1) Create pair of oAuth 1.0 keys with "Desktop" types. Allow permissions for time and financial reports. | |
(2) Download ``odesk_meter.py`` from https://github.com/kipanshi/odesk_meter | |
(3) In the shell run the follwing: | |
""" | |
from odesk_meter import get_client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern mod std; | |
extern mod docopt; | |
use send_map::linear::LinearMap; | |
use io::{ReaderUtil, WriterUtil}; | |
/// Reads whole stream and outputs it as string | |
fn read_whole_stream_to_str(input_stream: io::Reader) -> ~str { | |
let mut buf = ~[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cProfile | |
from django.template.defaultfilters import floatformat as floatformat_django | |
from django.contrib.humanize.templatetags.humanize import intcomma as intcomma_django | |
num = 100000 | |
float_num = 1 / 3.0 | |
def floatformat(value, places=2): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def refresh(instance): | |
"""Select and return instance from database. | |
Usage: ``instance = refresh(instance)`` | |
""" | |
return instance.__class__.objects.get(pk=instance.pk) | |
def update(instance, **data): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _Stub(object): | |
"""Class for creating stub object. | |
For internal use. | |
""" | |
def __getattribute__(self, *args, **kwargs): | |
return self | |
def next(self): | |
raise StopIteration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SettingsContextManager(object): | |
"""Allow to change ``settings.*`` in ``with`` context.""" | |
def __init__(self, *settings_tuples): | |
self.settings = dict(settings_tuples) | |
self.orig_settings = dict([(key, getattr(settings, key)) | |
for key in self.settings]) | |
def __enter__(self, *args, **kwargs): | |
[setattr(settings, key, self.settings[key]) | |
for key in self.settings] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script needs to be run from inside the project folder | |
# since it needs access to settings.py | |
# | |
# DISCLAMER: Use _only_ on local dev installation! | |
DB_NAME=`python -c "import settings; print settings.DATABASES['default']['NAME']"` | |
DB_USER=`python -c "import settings; print settings.DATABASES['default']['USER']"` | |
DB_PASS=`python -c "import settings; print settings.DATABASES['default']['PASSWORD\ | |
']"` |
NewerOlder