Skip to content

Instantly share code, notes, and snippets.


Prince Odame Odame

View GitHub Profile
# 3 ways to give change for 4
# with denomination 1 and 2
# 1+1+1+1, 1+1+2, 2+2.
# 1+1+2 == 2+1+1
# count_change(4, [1,2]) # => 3
# count_change(10, [5,2,3]) # => 4
# count_change(11, [5,7]) # => 0
Odame /
Last active Apr 4, 2019 — forked from ArsalRaza/
Extract Audio from Video, Mute Video, Crop Video from start, Crop Video from end Android MediaMuxer - JAVA
import android.annotation.SuppressLint;
import android.util.Log;
import java.nio.ByteBuffer;

Access macOS localhost from IE or Edge within Parallels Desktop

This issue is so infuriating that I'm going to take some time to write about it.

  1. MOST IMPORTANT. Your local development server must be bound to IP address Some do this by default, but many don't. You need to make sure that you run your local server with correct IP bindings. You may need to provide additional flags to your serve commands e.g. polymer serve --hostname domain.local, hugo serve --bind If you use a named domain like domain.local, it has to be defined in /etc/hosts and pointing at

  2. My Parallels setting is using Shared Network, nothing special there.

  3. Open macOS Terminal and type ifconfig. Look for the value under vnic0 > inet. It is typically

Odame /
Last active Oct 23, 2018
Service for accessing a MySQL database in a Flask application, where all db calls in a single request must use a single db connection
# coding: utf-8
Service for accessing a MySQL database in a flask application, where all db calls in a single request must use a single db connection.
Uses the Borg pattern, with state stored in a thread local (g), in NOT order to leak state across multiple threads
import logging as log
import MySQLdb as mDb
from functools import wraps
from flask import g
Odame / ranking.js
Created Aug 5, 2018
Solution to test question in form.
View ranking.js
* Sort an array of objects based on ranking
* @param {{name: String, ranking: Number}[]} objectArray
const sortByRanking = (objectArray) => {
return objectArray.sort((obj1, obj2) => obj1.ranking-obj2.ranking);
Odame /
Created Jun 22, 2017 — forked from robcowie/
Memory-efficient, streaming query generator with MySQLdb
from MySQLdb.cursors import SSDictCursor
def iterate_query(query, connection, arraysize=1):
c = connection.cursor(cursorclass=SSDictCursor)
while True:
nextrows = c.fetchmany(arraysize)
if not nextrows:
Odame /
Created Jan 28, 2017 — forked from kristopherjohnson/
Methods for generating ISO 8601 timestamps in Java/Android
package net.kristopherjohnson.util;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
* Methods for dealing with timestamps