This file contains 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 android.content.Context; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.graphics.drawable.BitmapDrawable; | |
import android.graphics.drawable.Drawable; | |
import android.os.Handler; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.ViewGroup; | |
import android.widget.FrameLayout; |
This file contains 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 org.joda.time.DateTime | |
import org.joda.time.Minutes | |
val now = DateTime.now() | |
val past = now.minusMinutes(3) | |
println(Minutes.minutesBetween(past, now).minutes) | |
println(Minutes.minutesBetween(now, past).minutes) |
This file contains 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 android.os.StrictMode | |
fun <T> withStrictModeThreadPolicy(threadPolicy: StrictMode.ThreadPolicy, block: () -> T): T { | |
val previousPolicy = StrictMode.getThreadPolicy() | |
StrictMode.setThreadPolicy(threadPolicy) | |
try { | |
return block() | |
} finally { | |
StrictMode.setThreadPolicy(previousPolicy) | |
} |
This file contains 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 sample.json; | |
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.databind.ObjectReader; | |
import com.google.common.reflect.TypeToken; | |
import sample.json.Json; | |
import org.springframework.util.StringUtils; | |
import javax.annotation.Nonnull; |
This file contains 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 android.content.Context; | |
import android.view.View; | |
import android.view.inputmethod.InputMethodManager; | |
import android.widget.EditText; | |
public class KeyboardManagingFocusListener implements View.OnFocusChangeListener { | |
private final EditText editText; |
This file contains 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
// Alice.ts | |
import aws from 'aws-sdk'; | |
export function main(event: any, context: any, callback: Function) { | |
new aws.Lambda().invoke({ | |
FunctionName: process.env.BobFunction!, | |
Payload: JSON.stringify({message: "Hi!. I'm Alice."}) | |
}, (error: Error, data: any) => { | |
const response = JSON.parse(data.Payload); | |
console.log('FromBob', error || response) |
This file contains 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 cloudform, { Lambda, IAM, Fn } from 'cloudform'; | |
const LambdaExecutionRole = 'LambdaExecutionRole'; | |
cloudform({ | |
Resources: { | |
HelloWorld: new Lambda.Function({ | |
Code: { | |
ZipFile: "exports.wrtiteToConsole = function (event, context, callback){ console.log('Hello'); callback(null); }" | |
}, |
This file contains 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 cloudform, { Lambda, IAM, Fn } from 'cloudform'; | |
import { FunctionProperties } from 'cloudform/types/lambda/function'; | |
import { readFileSync } from 'fs'; | |
const LambdaExecutionRole = 'LambdaExecutionRole', Alice = 'Alice', Bob = 'Bob'; | |
function lambdaFunction(functionCode: string, options?: Partial<FunctionProperties>) { | |
return new Lambda.Function({ | |
Code: { ZipFile: functionCode }, | |
Handler: "index.main", | |
Role: Fn.GetAtt(LambdaExecutionRole, "Arn"), |
This file contains 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
[LambdaExecutionRole]: new IAM.Role({ | |
AssumeRolePolicyDocument: { | |
Statement: [{ | |
Effect: "Allow", | |
Principal: { Service: ["lambda.amazonaws.com"] }, Action: ["sts:AssumeRole"] | |
}] | |
}, | |
Path: "/", | |
ManagedPolicyArns: ["arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"], Policies: [{ | |
PolicyName: "AllowCallingOtherLambda", |
This file contains 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 org.slf4j.LoggerFactory | |
import org.springframework.http.HttpStatus | |
import org.springframework.web.bind.annotation.ResponseStatus | |
import reactor.core.publisher.Flux | |
import reactor.core.publisher.FluxSink | |
import reactor.core.publisher.Mono | |
import reactor.core.publisher.MonoSink | |
import reactor.core.scheduler.Scheduler | |
import java.util.concurrent.Callable |
NewerOlder