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
@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?
[
{
"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"
},
// init
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
// put
sp.edit()
.putString("date", "" + System.currentTimeMillis())
.apply();
// get
String date = sp.getString("date", null);
// dodajesz gdzieś raz do bibliotek
function goforit() {
if( active ) {
var args = Array.prototype.slice.call(arguments, 0);
(args.shift()).apply(null, args);
}
return active;
}
// funkcje do uruchomienia
function proceed() {
if( active ) {
var args = Array.prototype.slice.call(arguments, 0);
(args.shift()).apply(null, args);
}
return active;
}
var Teleport = function() {};
Teleport._rixits = "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "-_";
Teleport.numberToHash = function( n ) {
if( isNaN(Number(n)) || n===null || n===Number.POSITIVE_INFINITY || n<0 ) throw "The input is not valid";
n = Math.floor( n );
@meeDamian
meeDamian / Math.toString(64).js
Created June 10, 2013 14:32
Convert number to it's base-64 representation, and reverse it. It is NOT THE SAME as Base64 encoding!
var Base64 = function(){};
Base64._rixits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_";
Base64.toHash = function( n ) {
if( isNaN(Number(n)) || n===null || n===Number.POSITIVE_INFINITY || n<0 ) throw "The input is not valid";
n = Math.floor( n );
var result = '';
do result = this._rixits.charAt(n%64) + result;
while( n=Math.floor(n/64) );
return result; // String
package com.mtgox.api;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.Mac;
function f(n){var m=Math,s=m.sqrt(5),g=(1+s)/2,p=m.pow;return m.round((p(g,n)-p(1-g,n))/s);} // accurate version
var m=Math,s=m.sqrt(5),g=(1+s)/2,p=m.pow,f=function(n){return m.round((p(g,n)-p(1-g,n))/s)}; // accurate w/pre-calculating
function f(n){var m=Math,s=m.sqrt(5),g=(1+s)/2,p=m.pow;return((p(g,n)-p(1-g,n))/s);} // inaccurate version
var m=Math,s=m.sqrt(5),g=(1+s)/2,p=m.pow,f=function(n){return((p(g,n)-p(1-g,n))/s)}; // inacurate w/pre-calculating
do {
try {
some_new_great_idea();
great_success = true;
} catch( UtterFailure uf ) {
improve_or_change_idea_based_on( uf, ++experience );
continue;
}