Skip to content

Instantly share code, notes, and snippets.

James Robert jiaaro

Block or report user

Report or block jiaaro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View asyncio_example.py
import asyncio
async def sum_queue_vals(q):
result = 0
while True:
val = await q.get()
if val is None:
break
result += val
return result
@jiaaro
jiaaro / setup_local_codebuild_testing.sh
Last active Dec 4, 2018
Set up local testing for codebuild
View setup_local_codebuild_testing.sh
#!/bin/bash
docker --version
if [[ $? != 0 ]]; then
brew cask install docker
fi
echo "Make sure you have $HOME/bin in your PATH"
mkdir -p ~/bin/
curl https://raw.githubusercontent.com/aws/aws-codebuild-docker-images/master/local_builds/codebuild_build.sh > ~/bin/codebuild_build.sh
@jiaaro
jiaaro / async_children_with_cleanup.sh
Last active Oct 1, 2019
Run some commands asynchronously in bash and then make sure to kill the child processes if the user kills the process with CTRL-C (or similar)
View async_children_with_cleanup.sh
#!/bin/bash
trap "exit" INT TERM # Convert INT and TERM to EXIT
trap "kill 0" EXIT # Kill all children if we receive EXIT
# Run stuff in the background
sleep 3 &
sleep 4 &
# Find child processes and wait for them to finish so this script doesn't
View pydub_mixer.py
from pydub import AudioSegment
from pydub.utils import db_to_float
# note: see usage example at the bottom of the gist :)
class Mixer(object):
def __init__(self):
self.parts = []
def overlay(self, sound, position=0):
View combining_mono_audiosegments.py
In [1]: paste
import array
from pydub import AudioSegment
from pydub.generators import Sine, Square
# make two mono sounds (300 Hz tones)
sound1 = Sine(300).to_audio_segment(duration=30000)
sound2 = Square(300).to_audio_segment(duration=30000)
def x():
View App Revenue Output.md

If you've ever wondered what it's be like to "go indie" here is a script with some assumptions that might help you project your income.

Assumptions:

  • You will make a new app every month
  • Apps have a useful life of 3 years (after that they stop earning money)
  • Apps will earn $250 in their launch month
  • Apps will earn $100/mo at first (starting month 2), but that revenue will slowly decline (~50% each year)
  • As you make more apps your brand/mailing list will start to pay dividends (after 4 apps you'll see the numbers above double, after 8 they'll 3x, and so on)

So how would that work out?

View keybase.md

Keybase proof

I hereby claim:

  • I am jiaaro on github.
  • I am jiaaro (https://keybase.io/jiaaro) on keybase.
  • I have a public key ASAmjWlR2gGlcJGuKzzPQ4UDqxXW0WeP-NDoJACLKWKo7go

To claim this, I am signing this object:

@jiaaro
jiaaro / investment_calculator.py
Last active Mar 16, 2016
Calculate the value of your investments and savings at some point in the future
View investment_calculator.py
class Investment(object):
def cash_invested_by_month(self, month):
raise NotImplementedError
def value_in_month(self, month):
raise NotImplementedError
class SingleInvestment(Investment):
def __init__(self, amount, monthly_interest_rate, month=0):
@jiaaro
jiaaro / organism.py
Last active Jan 4, 2016
NOTE: organism.py belongs in a directory "breeder"
View organism.py
#!/usr/bin/env python
import ast
from os.path import isfile
from hashlib import md5
from random import randint, choice
from glob import glob
import re
# scratch area
"""
@jiaaro
jiaaro / _INSTRUCTIONS.md
Last active Jul 16, 2019
Using Swift libraries in Python
View _INSTRUCTIONS.md

Using Swift libraries in Python

So... this is obviously totally, 100%, like for. real. not. supported. by. Apple. …yet?

But still... I thought it was pretty badass. And, seeing how there's already a Swift buildpack for Heroku you could move some slow code into Swift can call it as a library function. But, you know, not in production or anything. That would be silly, right?

Now, having said that, the actual Python/Swift interop may have bugs. I'll leave that as an exercise to the reader.

How to get Python code calling Swift functions:

You can’t perform that action at this time.