Skip to content

Instantly share code, notes, and snippets.

View radzhome's full-sized avatar

Rad W radzhome

  • Ottawa
View GitHub Profile
"""
Write a function that given a list of non negative integers, arranges them such that they form the largest possible number. For example, given [50, 2, 1, 9], the largest formed number is 95021.
You application should be run from the command line using a single command. For example:
# $ python ./largest.py 100 3 67 9
# $ sbt "run 100 3 67 9"
"""
#!/usr/bin/env python
import re
from collections import OrderedDict
ONETHS = {
'first': '1ST', 'second': '2ND', 'third': '3RD', 'fourth': '4TH', 'fifth': '5TH', 'sixth': '6TH', 'seventh': '7TH',
'eighth': '8TH', 'ninth': '9TH'
}
TEENTHS = {
'tenth': '10TH', 'eleventh': '11TH', 'twelfth': '12TH', 'thirteenth': '13TH',
@radzhome
radzhome / card_utils.py
Last active April 27, 2016 01:10
Credit card utilities, useful functions
"""Card utilities for use with Payment Gateway classes, transaction processing"""
from __future__ import unicode_literals
import re
import logging
import datetime
VISA_CC = 'Visa' # Visa
MASTERCARD_CC = 'MasterCard' # MasterCard
@radzhome
radzhome / N by N Grid JS
Created March 25, 2016 19:44
N by N Grid JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>P2</title>
<style type="text/css">
table.gridTable, table.gridTable td { border: 1px solid black; }
.u-paddedBottom { padding-bottom: 15px; }
</style>
</head>
@radzhome
radzhome / Color Boxes JS
Created March 25, 2016 19:43
Color Boxes JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>P1</title>
<style type="text/css">
.grid-box {
width: 100px;
height: 100px;
border: 1px solid #000;
# Nicely titled province and state names
STATES_PROVINCES = (
('AL', u'Alabama'),
('AK', u'Alaska'),
('AS', u'American Samoa'),
('AZ', u'Arizona'),
('AR', u'Arkansas'),
('CA', u'California'),
('CO', u'Colorado'),
('CT', u'Connecticut'),
# Nicely titled country names.
COUNTRIES = (
('AF', u'Afghanistan'),
('AX', u'\xc5land Islands'),
('AL', u'Albania'),
('DZ', u'Algeria'),
('AS', u'American Samoa'),
('AD', u'Andorra'),
('AO', u'Angola'),
('AI', u'Anguilla'),
@radzhome
radzhome / elevator.py
Created July 25, 2015 17:25
An elevator sim, next steps add multiple elevators, use rabbitmq?
"""single elevator shaft simulation, so queues are all in 1 elevator """
import time
import random
AVAILABLE_FLOORS = [-1, 0, 1, 2, 3, 4, 5, 6, 7] # 0 = basement 1 (B1), -1 = B2
FIRST_FLOOR = AVAILABLE_FLOORS[0]
LAST_FLOOR = AVAILABLE_FLOORS[-1]
AVAILABLE_DIRECTIONS = ['up', 'down']
/* REXX */
/* To connect a certificate to keyrings same was as another */
/* certificate, pretty much duplicate its keyring usage as */
/* that of an existing Nov 2010 */
/*outtrap racdcert site and ca output*/
/* Your label will be located from the below query so make sure it */
/* contains what you need!*/
x = OUTTRAP('strRacfLs.')
Address TSO 'RACDCERT SITE LIST'
/* rexx */
/* LMP KEY Duplicates Summary*/
/* August 2008, functional comparisons working */
/* Input file has to be unnummed, use unnum on file before running */
/*******************************
/* SAME PROD CODE AND xxx! */
/*******************************
INDSN="PS0601.CACOMMON.ALL.PPOPTION(KEYS)"
CALL Initialize