Skip to content

Instantly share code, notes, and snippets.

@mplacona
mplacona / Program.cs
Created February 21, 2018 19:42
Twilio Voice & SMS
using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;
namespace Pamphlet
{
internal static class Program
{
private static void Main(string[] args)
@mplacona
mplacona / cleanup.sh
Last active July 31, 2017 14:31
Cleanup space from node_modules
# cd to your project folder
# How much space is it using?
find . -type d -maxdepth 3 -name node_modules | xargs du -hcs | grep total
# Get rid of them
find . -type d -maxdepth 3 -name node_modules | xargs -p rm -rf # Will prompt before deleting. answer y/n
import com.twilio.twiml.Body
import com.twilio.twiml.Message
import com.twilio.twiml.MessagingResponse
// ...
@RequestMapping(value = "/replyMessage", produces = arrayOf("text/xml"))
fun replyMessage(): String? {
val message = Message.Builder().body(Body("Be getting back to you soon, let me do some more Kotlin first")).build();
return MessagingResponse.Builder().message(message).build().toXml();
}
import com.twilio.http.TwilioRestClient
import com.twilio.rest.api.v2010.account.MessageCreator
import com.twilio.type.PhoneNumber
// ...
@RequestMapping(value = "/sendMessage")
fun sendMessage(){
val client = TwilioRestClient.Builder("YOUR_TWILIO_ACCOUNT_SID", "YOUR_TWILIO_AUTH_TOKEN").build()
val message = MessageCreator(
package uk.co.placona.TwilioKotlin
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SMSController {
@RequestMapping(value = "/")
fun helloSpringBoot() = "Hello Spring Boot"
}
package uk.co.placona.TwilioKotlin
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
@SpringBootApplication
open class App
fun main(args: Array<String>) {
SpringApplication.run(App::class.java, *args)
group 'uk.co.placona'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.1.1'
ext.spring_boot_version = '1.4.3.RELEASE'
repositories {
mavenCentral()
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>uk.co.placona.javacalls</groupId>
<artifactId>java-calls</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
ButterKnife.bind(this);
Observable<CharSequence> loginObservable = RxTextView.textChanges(mLogin);
loginObservable
.map(this::isValidLogin)
.subscribe(isValid -> mLogin.setCompoundDrawablesRelativeWithIntrinsicBounds(null,null, (isValid ? mValidField : mInvalidField), null));
Observable<CharSequence> passwordObservable = RxTextView.textChanges(mPassword);
passwordObservable
.map(this::isValidPassword)
ButterKnife.bind(this);
Observable<CharSequence> loginObservable = RxTextView.textChanges(mLogin);
Observable<CharSequence> passwordObservable = RxTextView.textChanges(mPassword);
Observable<Boolean> combinedObservables = Observable.combineLatest(loginObservable, passwordObservable, (o1, o2) -> isValidLogin(o1) && isValidPassword(o2));