This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void render() { | |
Gdx.gl.glClearColor(1, 1, 1, 1); | |
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); | |
renderer.setView(camera); | |
renderer.render(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 0; i < images.length(); i++) { | |
JSONObject object = images.optJSONObject(i); | |
if (object != null) { | |
mAdapter.add(object.optString("description")); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |