Skip to content

Instantly share code, notes, and snippets.

Prince Odame Odame

Block or report user

Report or block Odame

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 count_coins.py
# 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
Odame / AudioExtractor.java
Last active Apr 4, 2019 — forked from ArsalRaza/VideoUtils.java
Extract Audio from Video, Mute Video, Crop Video from start, Crop Video from end Android MediaMuxer - JAVA
View AudioExtractor.java
import android.annotation.SuppressLint;
import android.media.MediaCodec;
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.media.MediaMetadataRetriever;
import android.media.MediaMuxer;
import android.util.Log;
import java.io.IOException;
import java.nio.ByteBuffer;
View access-mac-localhost-from-parallels-desktop-ie-edge.md

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 0.0.0.0. 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 0.0.0.0. If you use a named domain like domain.local, it has to be defined in /etc/hosts and pointing at 0.0.0.0.

  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 10.211.55.2.

@Odame
Odame / db_service.py
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
View db_service.py
# 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
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
Odame / mysqldb_query_generator.py
Created Jun 22, 2017 — forked from robcowie/mysqldb_query_generator.py
Memory-efficient, streaming query generator with MySQLdb
View mysqldb_query_generator.py
from MySQLdb.cursors import SSDictCursor
def iterate_query(query, connection, arraysize=1):
c = connection.cursor(cursorclass=SSDictCursor)
c.execute(query)
while True:
nextrows = c.fetchmany(arraysize)
if not nextrows:
break
@Odame
Odame / TimestampUtils.java
Created Jan 28, 2017 — forked from kristopherjohnson/TimestampUtils.java
Methods for generating ISO 8601 timestamps in Java/Android
View TimestampUtils.java
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
You can’t perform that action at this time.