Skip to content

Instantly share code, notes, and snippets.

View AlexLamson's full-sized avatar

Alex Lamson AlexLamson

View GitHub Profile
@AlexLamson
AlexLamson / Prob17.java
Last active December 21, 2015 05:28
Originally created for euler problem 17 (https://projecteuler.net/problem=17), this translates numbers to words. Ex. 37 => thirty seven Ex. 123456 => one hundred twenty three thousand four hundred fifty six The highest it can currently reach is 1 million. To do: 1. make it go higher (decillion) 2. clean up a little 3. load the number in chunks o…
import java.math.BigInteger; //http://docs.oracle.com/javase/6/docs/api/java/math/BigInteger.html
public class Prob17
{
public static BigInteger oneHundred = new BigInteger("100");
public static BigInteger oneThousand = new BigInteger("1000");
public static BigInteger tenThousand = new BigInteger("10000");
public static BigInteger oneMillion = new BigInteger("1000000");
public static void main(String[] args)
@AlexLamson
AlexLamson / NiceColors.java
Created October 1, 2013 21:03
Random pleasant color generator, translated to java. Theory taken from http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
public class NiceColors
{
public static int colorPos = 0;
//use golden ratio to create pleasant colors
//http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
public static Color betterNiceColor()
{
double goldenRatioConj = (1.0 + Math.sqrt(5.0)) / 2.0;
float hue = new Random().nextFloat();
@AlexLamson
AlexLamson / what_to_wear.py
Last active August 29, 2015 14:21
Little python script that prints what to wear by checking the weather in your location
import json
import urllib2
import sys
def internet_on():
try:
response=urllib2.urlopen('http://173.194.204.105',timeout=1)
return True
except urllib2.URLError as err: pass
return False
@AlexLamson
AlexLamson / color.sh
Created June 25, 2016 23:50
Bash script that colors some given input text using ANSI escape codes
#color.sh
#Usage:
# ./color.sh somecolor some text to be colored
#ex. ./color.sh lightblue hello world
color='\033[0m'
nocolor="\033[0m"
case "$1" in
black) color="\033[0;30m";;
@AlexLamson
AlexLamson / commands.txt
Last active November 2, 2021 16:40
List of useful terminal commands for a beginner. Sorted approximately by difficulty & usefulness.
Commands
---------------
man # MANual for command
ls # LiSt files (-l more information, -R recursive)
cd # Change Directory (if no folder, go home)
pwd # Print Working Directory
mkdir -p # MaKe DIRectory (-p create missing parent directories)
touch # create file
rm -fr # ReMove directory and all its contents
[TAB key] # press tab key to autocomplete filename or command
import sys, pygame
from pygame import Rect
from pygame.locals import *
size = width, height = 640, 480
pos = (0, 0) #mouse position
inital_drag_pos = (0, 0)
dragging = False
@AlexLamson
AlexLamson / random_cow.sh
Created March 10, 2017 22:52
Make a random cow say "Hello"
#sudo apt install -yqqq figlet cowsay
figlet -f $(ls /usr/share/figlet/*.flf | shuf -n1) "Hello" | cowsay -n -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
@AlexLamson
AlexLamson / readme.md
Last active March 18, 2017 02:02 — forked from endolith/readme.md
How to stream a webcam to a web browser in Ubuntu

Grr this took hours to figure out. I was trying to install MJPG-streamer and running VLC command lines and all this crap but nothing worked.

First install motion:

~> sudo apt-get install motion

Then create a config file:

~> mkdir ~/.motion

~> nano ~/.motion/motion.conf

@AlexLamson
AlexLamson / rasp-pi-umass-eduroam.md
Last active March 8, 2023 15:59
How to connect to UMass Eduroam wifi with a Raspberry Pi running Raspbian

How to connect Raspberry Pi to UMass Eduroam

Open up a terminal and move into the directory holding the wpa_supplicant config file.

cd /etc/wpa_supplicant

You may want to backup your config file before you do anything just in case.

sudo cp wpa_supplicant.conf ~/Desktop/wpa_supplicant.conf
@AlexLamson
AlexLamson / backup-rescuetime.py
Last active May 6, 2020 19:08
A simple python script to backup rescuetime data every month
#!/usr/bin/python3
# backup-rescuetime.py: Backup all of last month's rescuetime data
#
# Columns are Date,Time Spent (seconds),Number of People,Activity,Category,Productivity
# Rows are hourly breakdowns of the activities done
#
# Must have directory called 'rescuetime_data' in same directory as script
#
# Sample crontab entry to backup at 6AM on the 1st of every month:
# 0 6 1 * * python3 ~/rescuetime/backup-rescuetime.py