Skip to content

Instantly share code, notes, and snippets.

View aleksi-niiranen's full-sized avatar

aleksi-niiranen

View GitHub Profile
@aleksi-niiranen
aleksi-niiranen / README.md
Last active November 29, 2015 22:14
Joulukortti

What you need

  • Java
  • Clojure

Usage

Download source file

To start REPL

java -cp clojure-1.7.0.jar clojure.main

Uri uri = new Uri("https://soludigital1.sharepoint.com/sites/dev-aleksi/_api/web/getavailablewebtemplates(lcid=1033)");
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Method = "GET";
request.Accept = "application/json;odata=verbose";
request.Headers.Add("Authorization", "Bearer " + accessToken.AccessToken);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream()))
{
return reader.ReadToEnd();
@aleksi-niiranen
aleksi-niiranen / addAccountSnippet.java
Created September 26, 2012 12:57
Android sync provider
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
String[] requiredFeatures, Bundle options) throws NetworkErrorException {
Bundle reply = new Bundle();
Account account = new Account("LunchBuddy", "com.blogspot.fwfaill.lunchbuddy.account");
AccountManager am = AccountManager.get(mContext);
boolean accountCreated = am.addAccountExplicitly(account, null, null);
if (accountCreated) {
reply.putString(AccountManager.KEY_ACCOUNT_NAME, "LunchBuddy");
reply.putString(AccountManager.KEY_ACCOUNT_TYPE, "com.blogspot.fwfaill.lunchbuddy.account");
@aleksi-niiranen
aleksi-niiranen / MainActivity.java
Created August 6, 2012 21:31
Android confirm dialog
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
// omitted irrelevant imports
public class MainActivity extends FragmentActivity {
private static final String TAG = "ConfirmDialogSample.MainActivity";
private static final int DELETE_DIALOG = 0;
@Override
@aleksi-niiranen
aleksi-niiranen / SomeActivity.java
Created July 9, 2012 19:11
Loading view popup in Android
public class SomeActivity extends Activity {
// make it a field so we can dismiss it when the activity pauses.
// otherwise the window will leak and cause and exception when the activity no longer exists
private PopupWindow mPopup;
public void showPopup() {
View popupView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.indeterminate_progress, null);
Display display = getWindowManager().getDefaultDisplay();
// getWidth() and getHeight() are deprecated and we should use getSize() but it's available on API level 13 and up
mPopup = new PopupWindow(popupView, display.getWidth(), display.getHeight());