Skip to content

Instantly share code, notes, and snippets.

View balance.kt
import java.util.*
fun main(args : Array<String>) {
val numBalances = readLine()!!.toInt()
val balances = (1 .. numBalances).map {
val leftLine = readLine()!!.split(' ')
val rightLine = readLine()!!.split(' ')
Balance(leftLine[0].toInt(), if (leftLine.size == 2) leftLine[1].toInt() else -1,
rightLine[0].toInt(), if (rightLine.size == 2) rightLine[1].toInt() else -1)
Jackyjjc / gist:9707dab983dd1d403bf5
Created Dec 24, 2014
scene2d List with keyboard navigation
View gist:9707dab983dd1d403bf5
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
View gist:db0bea2d295481307c9d
/*Add these to MainActivity on create*/
final DrawerLayout drawerLayout = (DrawerLayout) findViewById(;
final ListView drawerList = (ListView) drawerLayout.findViewById(;
drawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, new String[]{"Rooms"}));
drawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) {
/*you need to write this function, depends on what you want it to do when you click an item on the drawer*/
View gist:a5d0878de327d2a9d66b
//on the backend object you can call
void createUser(String userName);
void createRoom(User user, LatLng latLng, int accuracy, String roomName, int roomRadius);
void listRooms(User user, LatLng latLng, int accuracy);
void sendMessage(User user, Room room, String message);
//need to implement these to get information from the backend
public void onConnected() {
View gist:1705d202974b446ec56f
int main(int argc, char** argv) {
int n, c;
int retVal;
if((retVal = scanf("%d %d", &n, &c)) != 2) {
printf("only scan in %d items\n", retVal);
return 1;