Skip to content

Instantly share code, notes, and snippets.

View jampola's full-sized avatar

James Bos jampola

View GitHub Profile
@jampola
jampola / friendly_date_range.js
Created November 1, 2016 06:30
Friendly Date Ranges (FreeCodeCamp)
function makeFriendlyDates(arr) {
dateArr = [];
months = {
'01':'January','02':'February','03':'March',
'04':'April','05':'May','06':'June',
'07':'July','08':'August','09':'September',
'10':'October','11':'November','12':'December'
};
@jampola
jampola / update_inventory.js
Last active November 1, 2016 06:31
Inventory update (FreeCodeCamp)
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
curArr.forEach(function(data){
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
jampola / randompassword.py
Created September 7, 2016 05:05
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:
password.append(chr(randint(97,122)))
elif r == 2:
password.append(str(randint(0,9)))
@jampola
jampola / gist:0073b8d14dc8d8a3668e716bed44cf9f
Created April 11, 2016 02:05
Update Java Alternatives (Debian)
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
@jampola
jampola / gist:fc847b0d60d382040696
Created September 17, 2015 06:27
Simple yahoo weather
# -*- coding: utf-8 -*-
#!/usr/bin/python
import urllib2
import json
import time
import os
import sys
import pprint
class weatherData:
@jampola
jampola / alarmclock.py
Last active May 12, 2021 14:10
Fully functioning mp3/wav/ogg playing Alarm Clock (PyGTK and Gst)
#!/usr/bin/python
'''
jamesbos [at] gmail [dot] com - originally shared at https://gist.github.com/jampola/ad3995e227dc46cfe069
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 gist.github.org 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
jampola / clock.py
Last active June 25, 2024 15:33
Simple clock using PyGTK and GObject.timeout_add()
#!/usr/bin/python
from gi.repository import Gtk, GObject
from datetime import datetime
class MainWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="app")
self.box = Gtk.Box(spacing=6)
self.add(self.box)