Skip to content

Instantly share code, notes, and snippets.

View marram's full-sized avatar

Mahmoud Arram marram

View GitHub Profile
@marram
marram / gist:69fb0a953c77b6db4ca8
Last active August 12, 2020 22:02
AES256 Encryption / Decryption using Python
# Copyright 2015 Bluecore, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
class PullQueueWorker(Command):
""" @num_tasks: The number of tasks to execute at a time.
"""
# The queue that this work is invoked from. This is a PUSH queue.
# It is used by the base_class to determine how to schedule a command.
# It is different from the queue that the worker reads the tasks from
queue_name = None
pull_queue_name = None
# The target machine
target = None
queue:
- name: default
rate: 500/s
bucket_size: 100
retry_parameters:
task_retry_limit: 3
min_backoff_seconds: 1
max_backoff_seconds: 5
max_doublings: 0

Keybase proof

I hereby claim:

  • I am marram on github.
  • I am marram (https://keybase.io/marram) on keybase.
  • I have a public key whose fingerprint is 2DB6 6EAA 760E 19AB B0D6 B3D8 85BA 8EF6 8D85 5B20

To claim this, I am signing this object:

@marram
marram / keen.formula.js
Created November 20, 2013 04:21
Rate charts for Keen.IO
/**
* Divide two Keen series.
* by @marram for TriggerMail
*/
Keen.RateChart = function(numerator, denominator, chartOptions, element){
this.numerator = numerator;
this.denominator = denominator;
this.options = chartOptions;
this.__numdata = {};
this.__dendata = {};
@marram
marram / theme.html
Created October 22, 2013 02:17 — forked from soemarko/theme.html
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@marram
marram / gist:1511931
Created December 22, 2011 21:26
Fetching picks in parallel
def fetch_picks(games, users):
""" Fetches picks for a given list of games and users
"""
key_names = []
for user in users:
key_names.extend([Pick.make_key_name(user, game) for game in games])
# Fetch in parallel, 1k at a time
picks = []
for slice in miscutils.split_list(key_names, 1000):
@marram
marram / gist:1511873
Created December 22, 2011 21:12
key names for picks
class Pick(db.Model):
# Models a user's prediction of which team will win a game.
user = db.ReferenceProperty(User)
game = db.ReferenceProperty(Game)
picked_team = db.ReferenceProperty(Team)
@classmethod
def make_key_name(cls, user, game):
user_key = str(user.key())
game_key = str(game.key())
@marram
marram / gist:1511113
Created December 22, 2011 17:30
Pseudo code for querying picks
friends_picks = []
for friend in friends:
for game in games:
pick = get_pick(friend, game)
if pick:
friends_picks.append(pick)
@marram
marram / game_models.py
Created December 22, 2011 17:28
Simple models for a game and a pick
class Game(db.Model):
team = db.ReferenceProperty(Team)
home_team = db.ReferenceProperty(Team)
start_time = db.DateTimeProperty
class Pick(db.Model):
# Models a user's prediction of which team will win a game.
user = db.ReferenceProperty(User)
game = db.ReferenceProperty(Game)
picked_team = db.ReferenceProperty(Team)