This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.util.function.*; | |
import java.util.stream.Collectors; | |
import static java.util.function.Function.identity; | |
public class NonRepeatingLetter { | |
public static void main(String[] args) { | |
findFirstNonRepeatingLetter(args[0], System.out::println); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App stores are fundamental to the success of modern platforms. Tent should have one, especially as decentralisation makes discovery even more difficult. | |
Overview | |
TentCatalog offers discovery, recommendations and one-click installs. | |
Recommendations are based on what the user's followers/followings have installed (if they have also installed TentCatalog) and what 3rd party catalogs recommend as well. | |
Flows | |
User installs TentCatalog. | |
TentCatalog requests read/write permissions of type https://tent.io/contrib/types/post/installation/v1.0 | |
When user installs another app, TentCatalog is notified |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST https://javaapiclient.tent.is/tent/apps/evo05h/authorizations | |
Accept:application/vnd.tent.v0+json | |
Content-Type:application/vnd.tent.v0+json | |
{ | |
"code": "a337d62419901973edeb182234a27739", | |
"token_type": "mac" | |
} | |
Had I included an Authorization header, here's what the normalized request would have been: | |
1349520353 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timestamp=1349386748510 | |
nonce=kaauue7k | |
method=POST | |
uri=/apps/ztfqej/authorizations | |
host=javaapiclient.tent.is | |
port=443 | |
mac_key=d9ab6f3b87a8026e54aa5c971bd39e7c | |
mac_key_id=a:f6f0695f | |
What the Tent Ruby client says I should get: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Two parts: Viewer and Publisher | |
Viewer | |
GET /posts of type Essay (https://tent.io/types/post/essay/v0.1.0) | |
Is notified when a new Essay is POSTed | |
Displays them as a blog | |
Publisher |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// apiSecret and accessToken have already been acquired | |
HttpClient httpClient = AndroidHttpClient.newInstance(""); | |
HttpGet httpGet = new HttpGet(Urls.BASE + "/user"); | |
long utcTimestamp = Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTimeInMillis(); | |
String rawNonce = NONCE_SALT + RANDOM.nextInt(); | |
String nonce = rawNonce.substring(0, Math.min(rawNonce.length(), 35)); | |
String normalisedString = accessToken + "\n" | |
+ utcTimestamp + "\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.moandjiezana.mailapi; | |
import java.util.Date; | |
import java.util.Properties; | |
import javax.mail.Message.RecipientType; | |
import javax.mail.MessagingException; | |
import javax.mail.Session; | |
import javax.mail.Transport; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String convenient(Object o) { | |
return lessConvenient(o, "default"); | |
} | |
public String lessConvenient(Object o, String suffix) { | |
return o.toString() + suffix; | |
} | |
// Unit tests | |
// assume lessConvenient is already tested |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pair and SmartMap in action | |
// Problems: | |
// 1. this gives a compiler warning: "Type safety : A generic array of Pair<String,String> is created for a | |
// varargs parameter" | |
// 2. All second elements of Pairs must be of same type, not even subclasses for it to compile. | |
public class Example { | |
public static void main(String[] args) { | |
SmartMap<String, String> myMap = map(of("key", "value1"), of("key2", "value 1")); | |
System.out.println(myMap.get("key")); |