Skip to content

Instantly share code, notes, and snippets.

View onyekaa's full-sized avatar

Onyeka Aghanenu onyekaa

View GitHub Profile
@onyekaa
onyekaa / swap.py
Last active August 29, 2015 14:27
Get the highest and lowest possible number if you could only swap one number at a time.
def swap(num):
# convert the number to a string so that we can split into a list
# and get the index for each
old_arr = list(str(num))
# empty list where we'll push the newly swapped numbers for comparison
new_arr = []
# we then loop through the length of the list of numbers and get the
# index, pairing it up with the next index in line
# for instance: for index 0, we pair it with 1, then 0 with 2 etc.
for i, val in enumerate(old_arr):
@onyekaa
onyekaa / swap.js
Last active August 29, 2015 14:27 — forked from xolubi/swap.js
function swap(n) {
var arr = n.toString().split(''); // convert number to string then split into array
if (arr.length > 2) {
var swap_list = []; // arrary to push newly swapped numbers
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr.length; j++) {
if (i != j) {
new_arr = arr.slice(0); // copy old array
from __future__ import absolute_import, print_function, unicode_literals
from django.db import models, transaction
from django.utils import six
from django.apps import apps
from django.core.exceptions import FieldDoesNotExist
try:
# Django 1.7
from django.contrib.admin.utils import NestedObjects
except ImportError:
# Django < 1.7
def find(key, dictionary):
for k, v in dictionary.iteritems():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
for d in v:
for result in find(key, d):
@onyekaa
onyekaa / SketchSystems.spec
Last active August 20, 2018 11:08
Hospital Manager
Hospital Manager
Open App
login -> Homepage
Homepage
system -> Accounts
Accounts
Ejected
STOP -> Stopped
Stopped*
STOP -> Ejected
PLAY -> Playing
REWIND -> Rewinding
FAST_FORWARD -> FastForwarding
Active
STOP -> Stopped
PLAY -> Stopped
@onyekaa
onyekaa / ocr.py
Created April 18, 2019 12:36
OCR Experiment
# import the necessary packages
from PIL import Image
import pytesseract
import argparse
import cv2
import os
import csv
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()