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
<?php
function parsePageSignedRequest() {
if (isset($_REQUEST['signed_request'])) {
$encoded_sig = $payload = null;
list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
$sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
$data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true));
return $data;
}
return false;
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe("xfbml.render", function() { // przy wyrenderowaniu
FB.Event.subscribe("edge.create", function(targetUrl) { // przypisz click
@meeDamian
meeDamian / flikrGallery.js
Last active December 14, 2015 19:49
version one million seven thousand and twenty one
(function( $ ){
var defaults = {
flickrApiUrl: 'http://api.flickr.com/services/feeds/photos_public.gne',
flickrApiParameters: {
format: 'json'
},
template: 'div.content > a.template'
};
do {
try {
some_new_great_idea();
great_success = true;
} catch( UtterFailure uf ) {
improve_or_change_idea_based_on( uf, ++experience );
continue;
}
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
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;
@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
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 );
function proceed() {
if( active ) {
var args = Array.prototype.slice.call(arguments, 0);
(args.shift()).apply(null, args);
}
return active;
}
// 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