Skip to content

Instantly share code, notes, and snippets.

public class Password{
public static void main(String args[]){
log(isValidPassword("Cookies123%");//Should print true
log(isValidPassword("Cookies");//Should print false
log(isValidPassword("Cookies12");//Should print false
log(isValidPassword("");//Should print false
log(isValidPassword(null);//Should print false
log(isValidPassword("c");//Should print false
@jakewilson801
jakewilson801 / expressions.java
Last active January 4, 2016 07:09
expressions expressions expressions
int one = 1; //int = integer(datatype) one = name of varible
int two = 2; // ^^
// = is how you assign a value to a varible
// boolean = datatype(true or false) whichIsGreater is the name
// one > two = expression that will evaulate to true or false
boolean whichIsGreater = (one > two);
System.out.println(whichIsGreater); // will print false
// I wrapped the expression in parens because that's the order of ops thing (PEMDAS)
int temp = 100; //This value could be read in from a GUI
if(temp >= 90){
System.out.println("It's pretty hot it's greater than 90 degrees");
}else if(temp <= 90 && temp >= 75){
System.out.println("It's under 90 but over 75");
}else if(temp <= 75 && temp >= 50){
System.out.println("It's under 75 but over 50");
}else if(temp <= 50 && temp >= 33){
System.out.println("It's under 50 but over 33");
}else{
@jakewilson801
jakewilson801 / gist:8485357
Created January 18, 2014 02:28
gettin' coookies in the command line
yell(){
n=$(( $RANDOM % 5 ));
case $n in
0)
echo "WHEATIESSSS BOX"
;;
1)
echo "BISCUITTSSSSSS"
;;
2)
@jakewilson801
jakewilson801 / gist:7969095
Created December 15, 2013 04:58
How to parse json using GSON
public Summary summaryData;
AsyncHttpClient client = new AsyncHttpClient();
client.get("http://i.tv/getmesomesuperawesomedata", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
Type listType = new TypeToken<Summary>() {}.getType();
summaryData = (Summary) new Gson().fromJson(response, listType);
//now summary data will be in memory from a json string
//no more traversing json objects to get the data we need this call does all that magic
@jakewilson801
jakewilson801 / test
Created September 11, 2013 03:50
I got 99 problems and a bit aint one
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String args[]) {
System.out.println(getC(2));
System.out.println(getC(3));
@jakewilson801
jakewilson801 / crap
Created July 11, 2013 04:47
My attempt and reading in a relation-database like file with id's
items = new ArrayList<Item>();
for(String s : lines){
String[] data = s.split("|");
items.add(new Item(Integer.parseInt(data[0]), data[1],data[2], new ArrayList<Item>()));
}
for(int i =0; i< lines.size(); i++){
String[] temp = lines.get(i).split("|");
List<Integer> ids = new ArrayList<Integer>();
String[] temp2 = temp[3].split(",");
@jakewilson801
jakewilson801 / gist:5552207
Created May 10, 2013 03:24
Rollin my own hash map. College c++ style :)
//
// main.cpp
// HashMap
//
// Created by Jacob Wilson on 2/28/12.
// Copyright (c) 2012 Weber State. All rights reserved.
//
#include <iostream>
@jakewilson801
jakewilson801 / gist:5552206
Created May 10, 2013 03:23
Good ol binary tree stuff
//
// main.cpp
// Trees
//
// Created by Jacob Wilson on 3/27/12.
// Copyright (c) 2012 Weber State. All rights reserved.
//
#include <iostream>
#include <string>
@jakewilson801
jakewilson801 / gist:5552201
Created May 10, 2013 03:22
Good ol sorting stuff from school
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
class ArraySort {
public:
ArraySort(int size);