Skip to content

Instantly share code, notes, and snippets.

View meeDamian's full-sized avatar
👨‍💻
Lightning Networking

Damian Mee meeDamian

👨‍💻
Lightning Networking
View GitHub Profile
// init
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
// put
sp.edit()
.putString("date", "" + System.currentTimeMillis())
.apply();
// get
String date = sp.getString("date", null);
[
{
"name": "Raw Vega Diet",
"recent": [
{
"date": "2013-09-11",
"name": "Potato Soup",
"desc": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
"pic": "http://img4-1.myrecipes.timeinc.net/i/recipes/ck/03142008/potato-soup-ck-223873-l.jpg"
},
@meeDamian
meeDamian / volleyExample.java
Created September 23, 2013 10:14
Simple download JSON example using Volley
Volley.newRequestQueue(this).add(
new JsonObjectRequest(Request.Method.GET, "http://your-url.com/file.json", null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {} // what happens on success?
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {} // what happens on fail?
@meeDamian
meeDamian / ionExample.java
Created September 23, 2013 10:16
Simple download JSON example using koush/Ion
Ion.with(this, "http://your-url.com/file.json")
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if( e!=null ) {} // do stuff on fail
if( json!=null ) {} // do stuff on success
}
});
package com.elimidateapp.android.customs;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.TextView;
public class MyTextView extends TextView {
private boolean allCaps = false;
@meeDamian
meeDamian / MyTextView.java
Last active December 25, 2015 16:39
Just a handy trick to handle lack of `android:textAllCaps="true"` on devices prior to ICS
public class MyTextView extends TextView {
private boolean allCaps = false;
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
if( isLegacy() ) {
allCaps = attrs.getAttributeBooleanValue("http://schemas.android.com/apk/res/android", "textAllCaps", false);
if(allCaps) setText(getText()); // this line is really stupid, but initial setText() is called in TextView constructor, once allCaps isn't yet properly set...
}
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
protected boolean isValidFragment(String fragmentName) {
if (getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.KITKAT) {
throw new RuntimeException(
"Subclasses of PreferenceActivity must override isValidFragment(String)"
+ " to verify that the Fragment class is valid! " + this.getClass().getName()
+ " has not checked if fragment " + fragmentName + " is valid.");
} else {
return true;
}
}
0100000001aca7f3b45654c230e0886a57fb988c3044ef5e8f7f39726d305c61d5e818903c00000000
fd5d010048304502200187af928e9d155c4b1ac9c1c9118153239aba76774f775d7c1f9c3e106ff33c0221008822b0f658edec22274d0b6ae9de10ebf2da06b1bbdaaba4e50eb078f39e3d78014
730440220795f0f4f5941a77ae032ecb9e33753788d7eb5cb0c78d805575d6b00a1d9bfed02203e1f4ad9332d1416ae01e27038e945bc9db59c732728a383a6f1ed2fb99da7a4014
cc952410491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f864104865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a986818a7cb624532f062c1d1f8722084861c5c3291ccffef4ec687441048d2455d2403e08708fc1f556002f1b6cd83f992d085097f9974ab08a28838f07896fbab08f39495e15fa6fad6edbfb1e754e35fa1c7844c41f322a1863d4621353ae
ffffffff0140420f00000000001976a914ae56b4db13554d321c402db3961187aed1bbed5b88ac00000000
angular.module("app.directives", []).directive('pwdMatch', function() {
return {
link: function(scope, elm, attrs) {
var checker;
checker = function() {
return elm.val() === scope.$eval(attrs.pwdMatch);
};
return scope.$watch(checker, function(n) {
return console.log("passwords" + (!n ? " do not" : "") + " match");
});