Skip to content

Instantly share code, notes, and snippets.

View jobelenus's full-sized avatar

John Obelenus jobelenus

View GitHub Profile
def main():
smugmug = auth()
c = get_csv_reader()
headers = c.next()
del headers
counter = 0
try:
for row in c:
print '.',
sys.stdout.flush()
if num_days <= 3:
if order_is_shipping:
price = model.three_day_rate * qty
else:
price = model.four_day_rate * qty
elif num_days == 4:
price = model.four_day_rate * qty
elif num_days > 4:
days_amount = max(0, self._calculate_price_for_days(num_days-4, qty=qty, model=model))
price = (model.four_day_rate * qty) + days_amount
@jobelenus
jobelenus / gist:7568669
Last active December 28, 2015 21:59
I don't get an exception from doing this... nor do I see the log file on the db server (which has facilities.conf set up)
import loghog, logging
LOGHOG_APP_NAME = 'lenspro-dev'
LOGHOG_HOST = '192.168.3.10'
LOGHOG_PORT = '5577'
LOGHOG_SSL = {
'pemfile': '/etc/loghogd/certs/lp-demo-web.pem',
'cacert': '/etc/loghogd/certs/lp-demo-db0-ca.cert'
}
h = loghog.LoghogHandler(LOGHOG_APP_NAME, host=LOGHOG_HOST, ssl_info=LOGHOG_SSL, port=LOGHOG_PORT, print_debug=True)
r = logging.LogRecord('foo', logging.WARN, '/', 'TESTING', None, None, None)
SELECT
*,
(
6371 * acos(cos(radians(%s)) * cos(radians(latitude)) *
cos(radians(longitude) - radians(%s)) +
sin(radians(%s)) * sin(radians(latitude)))
) as distance
* 83aa0ab (HEAD, origin/feature-internal-url, feature-internal-url) match indent to the first character of first arg
* 1a9c5fb lint white-space fix
* 5289727 lint white-space fix
* a097bbf re-working `use_internal_url` in declaration, adding test case for endpoint variable
* c1f4aec variable endpoint url
* 9109a57 (trunk) Merge remote-tracking branch 'upstream/trunk' into trunk
|\
| * 7fc910a (upstream/trunk) Update CHANGES.
| * 58f3722 Adding/Removing instances from targetpool requires a list. This fixes a bug with attaching/detaching nodes from loadbalancers. (Attach/Detach wasn't working)
| * b6f0ce8 Update upgrade notes.
import os
from compressor.conf import settings
class DynamicManifestStorageMixin(object):
"""
Use this Mixin to dynamically name the manifest file which will prevent
problems surrounding CDN edges/TTL and purge commands taking minutes
"""
def get_available_name(self, name):
def get_offline_manifest_filename():
output_dir = settings.COMPRESS_OUTPUT_DIR.strip('/')
return os.path.join(output_dir, settings.COMPRESS_OFFLINE_MANIFEST)
_offline_manifest = None
def get_offline_manifest():
global _offline_manifest
jezdez: if cloudfront is such a pain, maybe we have to bite the bullet
[1:06pm] jobelenus: well.. as you were saying earlier the trouble of a "dynamic" manifest file is how to determine and store the name…
[1:06pm] jezdez: I'd then prefer the format manifest.<md5-of-content>.json and then store the name in the cache
[1:06pm] jezdez: it sucks but I can't think of a better way
[1:06pm] jobelenus: my latest thought is: "well this manifest file is really just a key->value pair… and we need persistence… why isn't this in the DB"
[1:07pm] jezdez: because there is no guarentee there will be a database
[1:07pm] jobelenus: hrmm

Keybase proof

I hereby claim:

  • I am jobelenus on github.
  • I am jobelenus (https://keybase.io/jobelenus) on keybase.
  • I have a public key whose fingerprint is 60D7 508C 21E4 30DC EEFC 5044 9BE9 7BF3 3E26 854F

To claim this, I am signing this object:

def get_product(self, instance):
if isinstance(instance, django_models.Model):
return instance.product
else:
try:
return api.TransientProduct(instance.product)
except:
return api.TransientProduct(instance['product'])