Skip to content

Instantly share code, notes, and snippets.


James Bos jampola

View GitHub Profile
jampola / friendly_date_range.js
Created Nov 1, 2016
Friendly Date Ranges (FreeCodeCamp)
View friendly_date_range.js
function makeFriendlyDates(arr) {
dateArr = [];
months = {
jampola / update_inventory.js
Last active Nov 1, 2016
Inventory update (FreeCodeCamp)
View update_inventory.js
function updateInventory(curArr, newArr) {
// All inventory must be accounted for or you're fired!
// using an object so we can assign k'v values
var curObj = {};
var returnArr = [];
var arr = [];
// add to obj so we can access k,v's
from random import randint, randrange
number = [randrange(1,9) for x in range(4)]
guesscount = 1
def game(guess):
cows = 0
bulls = 0
global guesscount
if guess != ''.join(str(x) for x in number):
jampola /
Created Sep 7, 2016
Generate a random password based user selected length. (upper,lower letters, numbers and symbols)
from random import randint
def main(passlen = 8):
password = []
for x in range(0,passlen):
r = randint(1, 4)
if r == 1:
elif r == 2:
jampola / gist:0073b8d14dc8d8a3668e716bed44cf9f
Created Apr 11, 2016
Update Java Alternatives (Debian)
View gist:0073b8d14dc8d8a3668e716bed44cf9f
Download/tar xvfz oracle java (somewhere like /opt/java is fine)
# update-alternatives --install /usr/bin/java java /path/to/oracle/install/java 1000
# update-alternatives --install /usr/bin/javac javac /path/to/oracle/install/javac 1000
# update-alternatives --config java
# update-alternatives --config javac
View gist:fc847b0d60d382040696
# -*- coding: utf-8 -*-
import urllib2
import json
import time
import os
import sys
import pprint
class weatherData:
jampola /
Last active May 12, 2021
Fully functioning mp3/wav/ogg playing Alarm Clock (PyGTK and Gst)
jamesbos [at] gmail [dot] com - originally shared at
Fully functioning alarm clock. Very primitive I know but this shows how basic events and
"threading" within pygtk[1] and media playback in gst[2] works. The main reason for sharing this on is so
it is searchable via google.
Include a an mp3 file called "alarm.mp3" in the same directory as this file OR supply the
/path/to/whatever.mp3/wav/ogg that you wish to play.
jampola /
Last active Jul 10, 2022
Simple clock using PyGTK and GObject.timeout_add()
from gi.repository import Gtk, GObject
from datetime import datetime
class MainWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="app") = Gtk.Box(spacing=6)