Skip to content

Instantly share code, notes, and snippets.

@Override
public boolean tap(float x, float y, int count, int button) {
// where x and y are tap inputs
Vector3 touchPoint = new Vector3(x, y, 0);
camera.unproject(touchPoint);
game.play((int) touchPoint.x, (int) touchPoint.y);
return true;
}
private static final int WHITE = -1;
private static final int EMPTY = 0;
private static final int BLACK = 1;
public void play(int x, int y) {
if (board[x][y] == EMPTY) {
board[x][y] = currentPlayer;
currentPlayer *= -1;
}
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
renderer.setView(camera);
renderer.render();
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
renderer.setView(camera);
renderer.render();
SpriteBatch batch = renderer.getSpriteBatch();
batch.begin();
JSONObject response = new JSONObject(EntityUtils.toString(
new DefaultHttpClient().execute(
new HttpGet(params[0])).getEntity(), "UTF-8"));
if (response.optBoolean("success", false)) {
return response.getJSONObject("response").getJSONArray("photos");
} else {
Log.w(TAG, "Request failed. Details: " + response.toString(2));
}
for (int i = 0; i < images.length(); i++) {
JSONObject object = images.optJSONObject(i);
if (object != null) {
mAdapter.add(object.optString("description"));
}
}
private static final String SNAPR_URL = "http://sna.pr/api/search/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1);
setListAdapter(adapter);
new Downloader(adapter).execute(SNAPR_URL);
}
@smaspe
smaspe / .profile
Created October 28, 2013 18:48 — forked from anonymous/.profile
source ~/git-completion.bash
source ~/git-prompt.sh
export RES='$(if [[ $? = 0 ]]; then echo -e "\e[0;32m\xe2\x9c\x94\e[m"; else echo -e "\e[0;31m\xe2\x9c\x98\e[m"; fi;)'
export PS1="$RES \e[1;36m\t\e[m\e[0;33m(\u)\e[m\e[40m\e[37m\w\e[m\e[1;35m\$(__git_ps1)\e[m\n\$ "
alias l='ls'
alias ll='ls -l'
alias less='less -N'
import itertools
letters = "acdegilmnoprstuw"
value = 25180466553932
def hsh(s):
return reduce(lambda h, char: h * 37 + letters.index(char), s, 7)
def unhash(val):
return unhash(val / 37) + letters[val % 37] if val > 7 else ''
@smaspe
smaspe / UriTest.java
Created October 22, 2015 18:16
Tests on Uri query parameters
import android.net.Uri;
import android.test.InstrumentationTestCase;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class UriTest extends InstrumentationTestCase {
public void testQueryParameters() throws UnsupportedEncodingException {
Uri uri = Uri.parse("http://domain.com/test?single_value=1");