Skip to content

Instantly share code, notes, and snippets.

View jonathan-irvin's full-sized avatar
🏠
Working from home

Jonathan Irvin jonathan-irvin

🏠
Working from home
View GitHub Profile
@jonathan-irvin
jonathan-irvin / update_puppet.sh
Created October 9, 2012 23:48
Personal Puppet Setup
#!/bin/bash
#Sanity checks
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
#Abort if no git/puppet
command -v git >/dev/null 2>&1 || { echo "I require git but it's not installed. Please install git-core if on debian/ubuntu" >&2; exit 1; }
@jonathan-irvin
jonathan-irvin / BeanCounter.java
Last active August 29, 2015 14:19
Project I did in College
public class BeanCounter {
public static void main(String[] args) {
final int BEANS = 1000;
int[] buckets = new int[8];
int pointer = 0;
for(int i=0;i<BEANS;i++){
for(int level=0;level<9;level++){
@jonathan-irvin
jonathan-irvin / BrutePrime.java
Last active August 29, 2015 14:19
Bruteforce Prime finder in java
public class BrutePrime {
public static void main(String[] args) {
final int END_VALUE = 1000000;
for(int number=2;number<END_VALUE;number++){
boolean isPrime = true;
//check divisors to see isPrime
for(int divisor=2;divisor<number;divisor++){
@jonathan-irvin
jonathan-irvin / Connect4.java
Last active October 15, 2024 10:31
Connect 4 in Java
import java.util.Scanner;
public class Connect4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
char[][] grid = new char[6][7];
//initialize array
@jonathan-irvin
jonathan-irvin / Emirp.java
Last active August 29, 2015 14:19
Emirp Finder
public class Emirp {
public static boolean isPrime(int number){
for (int divisor = 2;divisor < number;divisor++){
if(number % divisor == 0){
return false;
}
}
return true;
}
@jonathan-irvin
jonathan-irvin / intRange.java
Last active August 29, 2015 14:19
Int Range finder in java
import java.util.Scanner;
import java.util.Arrays;
public class IntRange {
public static double range(double[] numbers){
Arrays.sort(numbers);
double result = numbers[numbers.length-1] - numbers[0];
@jonathan-irvin
jonathan-irvin / intReverse.java
Last active August 29, 2015 14:19
Int reverse exercise
import java.util.Scanner;
public class IntReverse {
public static void main(String[] args) {
final int TOTAL_INTS = 10;
Scanner input = new Scanner(System.in);
@jonathan-irvin
jonathan-irvin / Payroll.java
Last active August 29, 2015 14:19
Payroll Project Problem
import java.text.NumberFormat;
import java.util.Scanner;
public class Payroll {
public static void main(String[] args) {
System.out.print("Employee's Name: ");
Scanner input = new Scanner(System.in);
@jonathan-irvin
jonathan-irvin / Min2Years.java
Last active August 29, 2015 14:19
Convert minutes to years
import java.util.Scanner;
public class Minutes2Years {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.print("Enter the number of minutes: ");
Scanner input = new Scanner(System.in);
int minutes;
@jonathan-irvin
jonathan-irvin / Feet2Meters.java
Last active August 29, 2015 14:19
Convert feet to meters
import java.util.Scanner;
public class Feet2Meters {
public static void main(String[] args) {
System.out.print("Enter distance in feet (ft): ");
Scanner input = new Scanner(System.in);
double feet;
feet = input.nextDouble();