Skip to content

Instantly share code, notes, and snippets.

@drapp
drapp / problem.sql
Created September 5, 2017 16:53
outer join example
db=# select * from books;
bookclub_id | book_id
--------------------------------------+--------------------------------------
22222222-2222-2222-2222-222222222222 | 00000000-0000-0000-0000-000000000000
22222222-2222-2222-2222-222222222222 | 11111111-1111-1111-1111-111111111111
(2 rows)
db=# select * from book_reviews;
bookclub_id | book_id | reviewer_id | rating
--------------------------------------+--------------------------------------+-------------+--------
// The mb prefix stands for maybe
def contrivedExample(mbNumber: Option[Int]): Int = {
val step1 = possiblyNumber.map(number => number + 5)
val step2 = step1.filter(number => number > 0)
step2.getOrElse(0)
}
@drapp
drapp / Catching.scala
Created January 3, 2013 23:59
Free Yourself from the Tyranny of Null
try {
Some(Integer.parseInt(header))
} catch {
case e: NumberFormatException => None
}
@drapp
drapp / AccessTokenMethods.md
Created September 19, 2012 19:20
StackMob AccessToken methods
  • Regular login
GET https://api.mob1.stackmob.com/user/accessToken

Headers:
   X-StackMob-API-Key: <public-key>
   Content-Type: application/x-www-form-urlencoded

Body: username=<username>&password=<password>&token_type=mac&mac_algorithm=hmac-sha-1&redirect_uri=...
@drapp
drapp / Count.m
Created May 2, 2012 21:16
iOS New SDK Feature May 2012
[[StackMob stackmob] count:@"user" withCallback:^(BOOL success, id result) {
if (success) {
// object found, cast result to NSNumber* and continue with processing
} else {
// unable to retrieve object, cast result to NSError* and inspect code & message
}
}];
@drapp
drapp / Count.java
Created May 2, 2012 21:02
Android New SDK Feature May 2012
StackMobCommon.getStackMobInstance().count("user", new StackMobCountCallback() {
@Override public void success(long count) {
//count succeeded
}
@Override public void failure(StackMobException e) {
//count failed
}
});
@drapp
drapp / JumbleOfStuff.java
Created March 20, 2012 22:43
TaskMob Snippets
public class JumbleOfStuff extends StackMobModel {
private Task favoriteTask;
private TaskList[] allTheTaskLists;
private Set<Task> taskSet;
}
@drapp
drapp / expand.js
Created March 8, 2012 00:49
StackMob Select Example Responses
{
"username": "fred",
"email": "fred@example.com",
"bestfriend":
{
"username": "bob",
"email": "bob@example.com",
"bestfriend": "fred",
"friends": ["peggy", "betty", "earl"]
},
@drapp
drapp / expand.java
Created March 8, 2012 00:30
StackMob Select Example
StackMobQuery q = new StackMobQuery("user/fred").expandDepthIs(1);
StackMobCommon.getStackMobInstance().get(q, new StackMobCallback() { ...