Skip to content

Instantly share code, notes, and snippets.

View songz's full-sized avatar
🎯
Focusing

Song Zheng songz

🎯
Focusing
View GitHub Profile
@songz
songz / ppsdk.md
Last active February 12, 2019 00:03
ppsdk

PayPal Shopping - Web SDK

PayPal Shopping increases conversion. You better believe it.

Implementation

Include

Before using the Web SDK make sure you have required it by adding this tag on every page that you intend to use the SDK. You do this by adding this code snippet in your element.

<head>  
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<script src="https://www.paypal.com/sdk/js?client-id=SB_CLIENT_ID&analytics=custom"></script>  
</head>
export const identity = (a) => a
export const add = (a,b) => a+b
export const sub = (a,b) => a-b
export const mul = (a,b) => a*b
export const identityf = (a) => (() => a)
export const addf = (a) => ((b) => a+b)
export const curry = (f,b) => ((a) => f(a,b))
export const curryr = (f,b) => ((a) => f(a,b))
export const liftf = (f) => ((a) => curry(f,a))
export const twice = (f) => ((a) => f(a,a))
@songz
songz / gracenote.java
Created July 14, 2013 18:44
GraceNote Android Auto Detect Music
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import com.gracenote.mmid.MobileSDK.GNAlbumIDFileError;
import com.gracenote.mmid.MobileSDK.GNAlbumIDSearchResult;
import com.gracenote.mmid.MobileSDK.GNAudioConfig;
import com.gracenote.mmid.MobileSDK.GNAudioSourceDelegate;
import com.gracenote.mmid.MobileSDK.GNAudioSourceMic;
// Works on simple data structures, did not test on more complex cases
// defined here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
const stringify = (jsobj) => {
const typ = typeof(jsobj);
if(typ==='string') return `"${jsobj}"`;
if(typ==='number' || typ==='boolean') return `${jsobj}`;
let [start, result, ending] = ['', '', ''];
if(jsobj.length === undefined) {
start = "{";
const checkCirc = (cur, next=cur.next) => {
if(cur === next) return true;
if(!next || !next.next || !next.next.next) return false;
return checkCirc(cur.next, next.next.next);
}
@songz
songz / question2.js
Created October 20, 2017 01:33
Biggest children
const bfs = (lev=[], prolific) => {
if(!lev.length) return prolific;
const n = lev.shift();
if(!prolific || prolific.children.length > n.children.length)
prolific = n;
return bfs(lev.concat(n.children));
}
@songz
songz / curry.js
Created October 20, 2017 01:16
Curry
const curryFunc = (fun, inputs=[]) => {
if(inputs.length == fun.length) return fun(...inputs);
return (...args) => curryFunc(fun, inputs.concat(args));
};
const isInterval = (input, ival, i=0) => {
if(i===input.length) return false;
const curInt = input[i];
if(ival[0] > curInt[0] && ival[0] < curInt[1]
|| ival[1]<curInt[1] && ival[1] > curInt[0]) return true;
return isInterval(input, ival, i+1);
};
@songz
songz / JS Poem
Created August 25, 2017 20:16
Code in JavaScript (Poem)
Code, code JavaScript
What mortal coder
Could convince me otherwise?
New mobile idea
Use react native
So I code in JavaScript
Build a cool website
That’s what its built for!
@songz
songz / keybase.md
Created November 17, 2016 22:11
Songz's keybase verification

Keybase proof

I hereby claim:

  • I am songz on github.
  • I am songz (https://keybase.io/songz) on keybase.
  • I have a public key whose fingerprint is E277 1621 1CF5 CE1E 0700 0ABB CA89 5068 2E3A 8FF3

To claim this, I am signing this object: