Skip to content

Instantly share code, notes, and snippets.

@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)
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 / 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)
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
new AsyncTask<Void, Void, String>() {
@Override
public String doInBackground(Void... params) {
String result = new String();
return result;
}
@Override
public void onPostExecute(String response) {
}
int[][] scaleImageData(int[][] sourceData, int scaleFactor) {
int[][] doubleSource = new int [sourceData.length * scaleFactor][soureData[0].length * scaleFactor];
for(int i = 0; i < sourceData.length; i++){
for(int j = 0; j < sourceData[i].length; j++){
for(int k = 0; k < scaleFactor; k++){
for(int z = 0; z < scaleFactor ; z++)
doubleSource[i * scaleFactor + k][j * scaleFactor +z] = sourceData[i][j];
@jakewilson801
jakewilson801 / adpater
Created August 21, 2014 20:35
generic adapter android
package com.itv.util;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
public class DataDelegateAdapter<T> extends BaseAdapter {
private DataAdapterDelegate<T> delegate;
private boolean shouldLoadMoreData = true;
@jakewilson801
jakewilson801 / cache
Created September 9, 2014 23:47
Great shared prefs cache
public class PersistentStore {
private static final String SHARED_PREFERENCES = "tvtag_PS_ATGAR";
private static final String SYNC = "sync";
private static SharedPreferences getSharedPreferences(Context context) {
return context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE);
}
private static SharedPreferences.Editor getSharedPreferencesEditor(Context context) {
-module(bot).
-behaviour(gen_server).
-export([start_link/0]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
start_link() ->
gen_server:start_link({local,?MODULE},?MODULE, [], []).
init([]) -> {ok, []}.
public static <T,U> Observable<Response<T>> createRequest(U data, Func1<U, Call<T>> endpoint){
return Observable.create(new Observable.OnSubscribe<Response<T>>() {
@Override
public void call(Subscriber<? super Response<T>> subscriber) {
if (isThereInternetConnection()) {
Call<T> request = endpoint.call(data);
try {
Response<T> response = request.execute();
int code = response.code();
if (response.isSuccess()) {