This file contains hidden or 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
// Create a thread pool | |
private ExecutorService mThreadPool = Executors.newSingleThreadExecutor(); | |
// Execute a new Runnable on a background Thread | |
Future f = pool.submit(new Runnable() { | |
public void run() { | |
while (true) { | |
// We're running! | |
Log.d(TAG, "."); | |
This file contains hidden or 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
#!/bin/bash | |
for i in *.png ; do | |
mv "$i" "ic_menu_${i##*[0-9]_}"; | |
done |
This file contains hidden or 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
// List all security providers | |
for (Provider p : Security.getProviders()) { | |
Log.d(TAG, String.format("== %s ==", p.getName())); | |
for (Provider.Service s : p.getServices()) { | |
Log.d(TAG, String.format("- %s", s.getAlgorithm())); | |
} | |
} |
This file contains hidden or 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
package com.geoloqi.android.sdk.util; | |
import java.util.Random; | |
/** | |
* <p>This class will efficiently generate insecure random | |
* alpha-numeric Strings.</p> | |
* | |
* <p>Source largely based on | |
* <a href="http://stackoverflow.com/a/41156/772122">this example</a> |
This file contains hidden or 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
#!/usr/bin/python | |
""" | |
A Geoloqi socket client demo. | |
:author: Tristan Waddington | |
""" | |
import sys | |
import time | |
import socket |
This file contains hidden or 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
package com.geoloqi.android.sdk.util; | |
import java.util.concurrent.TimeUnit; | |
/** | |
* A simple class for timing short lived events. | |
* | |
* @author Tristan Waddington | |
*/ | |
public class Timer { |
This file contains hidden or 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
public classd MyActivity extends Activity implements OnClickListener { | |
private LQService mService; | |
private boolean mBound; | |
private SampleReceiver mLocationReceiver = new SampleReceiver(); | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
} |
This file contains hidden or 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
LQSession session = mService.getSession(); | |
// Get the current user's profile | |
session.runGetRequest("account/profile", new OnRunApiRequestListener() { | |
@Override | |
public void onSuccess(LQSession session, HttpResponse response) { | |
// Consume the response! | |
// ... | |
JSONObject json = new JSONObject(EntityUtils.toString(response.getEntity())); | |
} |
This file contains hidden or 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
time = "10 minutes ago" | |
if ((distance_moved *since* time) < 200): | |
# Possibly return a 420 or 429 response code? Possibly not a 429, | |
# since we might want to use that for actual API request rate limiting. | |
# | |
# http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#420 | |
response = { | |
"error": "back_off", | |
"error_message": "...", | |
"latitude": 125.45, |
This file contains hidden or 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
# Loop over each object and either update or create. | |
try: | |
obj = MyObject.objects.get(pk=id) | |
obj.value1 = 1 | |
obj.value2 = 2 | |
except MyObject.DoesNotExist: | |
obj = MyObject(value1=1, value2=2, ...) | |
# Update the object |