Skip to content

Instantly share code, notes, and snippets.

/*** Wes's Java Cheat Sheet Version 1 ***/
/*** Last Updated 2010-09-11 ***/
/*** Location online http://gist.github.com/576436 ***/
/*
* Hopefully this is a big help for you. I know I could have used something like this.
* This should sum up everything you do in java for at least the first few weeks of it.
* It may not be perfect, but can always add to it or add to it yourself at the link above.
*
* Things that will come afterwards I would need to add to this would be like how to use
/*** Wes's Java Cheat Sheet Version 1 ***/
/*** Last Updated 2010-09-11 ***/
/*** Location online https://gist.github.com/d19a097f3e50580f2bb1 ***/
/*
* Hopefully this is a big help for you. I know I could have used something like this.
* This should sum up everything you do in java for at least the first few weeks of it.
* It may not be perfect, but can always add to it or add to it yourself at the link above.
*
* Things that will come afterwards I would need to add to this would be like how to use
@yareally
yareally / blah.java
Last active December 18, 2015 16:19
int n = 0;
for (String s: array) {
if (s.length > 2 && mapping.containsKey(s)) n++;
}
String[] bigEnough = new String[n];
n = 0;
for (String s: array) {
class MyClass (val id: Int, val name: String) {}
class MyClass () {
var id: Int = 0
var name: String = ""
def MyClass(id: Int, name: String) {
this.name = name
this.id = id
}
@yareally
yareally / Test.scala
Last active December 19, 2015 10:38
scala async/await on android
package com.cc.json2csv
import android.app.Activity
import android.os.Bundle
import play.api.libs.json._
import android.widget.TextView
import android.util.Log
import scala.async.Async.{async, await}
import scala.concurrent.{Await, Future, ExecutionContext, future}
import scala.concurrent.duration._
@yareally
yareally / Test.scala
Last active March 30, 2016 15:45
Basic usage example of Scala's async/await (https://github.com/scala/async) on Android
/*
Copyright (c) 2013 Wes Lanning, http://codingcreation.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
class Greeter {
element: HTMLElement;
span: HTMLElement;
timerToken: number;
constructor(element: HTMLElement) {
this.element = element;
this.element.innerHTML += "The time is: ";
this.span = document.createElement('span');
this.element.appendChild(this.span);
@yareally
yareally / ramdrive.cmd
Last active December 20, 2015 21:39
initialize ram drive
:: Guides and examples can be found at:
:: http://forums.guru3d.com/showthread.php?t=356046
:: Script needs to be set as a system startup batch file (with event schedular, not the "startup directory") with the highest priority and system privilages to work correctly.
:: Init the ramdrive (12GB) in physical memory and format it as ntfs
imdisk -a -s 12G -m R: -p "/fs:ntfs /q /y" -o awe
:: add a page file starting with 96MB and expands to 1536M
swapadd R:\pagefile.sys 96M 1536M
package models;
import java.util.*;
import javax.persistence.*;
import play.db.ebean.*;
import play.data.format.Formats.*;
import play.data.format.Formatters.*;
import play.data.validation.Constraints.*;
@yareally
yareally / FakeLambda.java
Last active December 20, 2015 22:09
Ugly fake Java Lambdas
package helpers;
import java.util.ArrayList;
import java.util.List;
/**
* @author Wes Lanning
* @version 2013-08-01
*/
public class FakeLambda