Skip to content

Instantly share code, notes, and snippets.

@imryan
imryan / fizz.js
Last active December 21, 2015 18:18
FizzBuzz in Node.js.
for (var i = 0; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0) {
console.log("FizzBuzz!");
}
else if (i % 3 == 0) {
console.log("Fizz!");
}
else if (i % 5 == 0) {
console.log("Buzz!");
@imryan
imryan / shell2.py
Last active December 23, 2015 08:29
Used at my school to execute shell scripts.
# Python 2 Shell Executor
# September 18, 2013
# Ryan Cohen
import socket, sys
from subprocess import call
def main():
print "\nPython 2 Shell Executor"
ip = socket.gethostbyname(socket.gethostname())
@imryan
imryan / Paint.java
Created October 1, 2013 17:26
CS 2 paint bucket calculator.
import java.util.Scanner;
public class Paint {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
// Declare variables to be used
final int ONE_GAL_PAINT = 350;
double width = 0.0, length = 0.0, height = 0.0, total = 0.0;
@imryan
imryan / Weight.java
Last active December 24, 2015 12:19
Calculates ideal weight for males and females.
import java.lang.*;
import java.util.Scanner;
public class Program
{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
// Declare variables
@imryan
imryan / LabGrade.java
Last active December 24, 2015 16:39
Calculates lab grades in a weird way. For CS 2.
import java.util.Scanner;
public class LabGrade
{
public static void main (String[] args)
{
// Declare constants
double inWeight = 0.6; // in-class weight is 60%
double outWeight = 0.4; // out-of-class weight is 40%
@imryan
imryan / Base.java
Last active December 24, 2015 22:19
Base conversion.
import java.util.*;
public class LabGrade
{
public static void main (String[] args)
{
int base; // the new base
int base10Num; // the number in base 10
int maxNumber; // the maximum number that will fit
@imryan
imryan / Average.java
Created October 8, 2013 16:38
Calculates student average from 5 recent grades.
import java.util.Scanner;
public class Average {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
int grade1 = 0;
int grade2 = 0;
@imryan
imryan / BirthdayGame.java
Last active December 25, 2015 00:29
Stupid birthday game. Makes no sense, but alright.
import java.util.Scanner;
public class BirthdayGame {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
double birthday = 0.0;
@imryan
imryan / PizzaCost.java
Created October 8, 2013 17:09
Determine cost to make pizza.
import java.util.Scanner;
public class PizzaCost {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
double size = 0.0;
double cost = 0.0;
@imryan
imryan / Mileage.java
Created October 9, 2013 17:20
Stupid mileage program.
import java.util.Scanner;
public class Mileage {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
double miles;
double gallons;
double mileage;