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
// using Twilio; | |
// var twilio = new TwilioRestClient("accountSid", "authToken"); | |
// var msg = twilio.SendSmsMessage("+15551112222", "+15553334444", "Can you believe it's this easy to send an SMS?!"); | |
[System.Reflection.Assembly]::LoadFile("Twilio.Api.dll") | out-null | |
$twilio = new-object Twilio.TwilioRestClient("accountSid", "authToken") | |
$msg = $twilio.SendSmsMessage("+15551112222", "+15553334444", "Can you believe it's this easy to send an SMS?!") | |
// v2 | |
Add-Type -path "Twilio.Api.dll" |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var http = new HttpRequest("http://google.com/?q={search}"); | |
http.Headers["Content-Type"] = "text/xml"; | |
http.Headers.Authorization = "foo"; | |
http.UrlSegments.search = "bar"; | |
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
// use in webmatrix | |
@{ | |
Helper.Fetch(url: "http://example.com", method: "GET"); | |
} | |
@{ | |
Helper.Fetch(url: "http://example.com", method: HttpMethod.GET); // no intellisense or build protection | |
} | |
// regular code use, not webmatrix and not 4.0 |
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
var http = new Http("https://api.twilio.com/{version}/Accounts"); | |
http.AddUrlSegment("version", "2010-04-01"); | |
http.AddParameter("name", "value"); | |
http.Authenticate = (request) => // authenticators would just follow this contract | |
{ | |
request.AddHeader("name", "value"); | |
}; | |
http.Complete = (response, data) => | |
{ |
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
public class EntityBase:DynamicModel { | |
public EntityBase():base("northwind") { | |
PrimaryKeyField = "Id"; | |
} | |
} | |
public class Product : EntityBase { | |
} | |
public class User : EntityBase { |
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
[TestMethod] | |
public void Can_Generate_Single_Say_With_Shortcut() | |
{ | |
var response = new TwilioResponse(); | |
response.Say("Hello world"); | |
var expected = XDocument.Parse("<Response><Say>Hello world</Say></Response>").ToString(); | |
var actual = response.ToString(); | |
Assert.AreEqual(expected, actual); |
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
C:\dev\heroku-test\public>ssh-keygen | |
Generating public/private rsa key pair. | |
Enter file in which to save the key (//.ssh/id_rsa): | |
Could not create directory '//.ssh'. | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
open //.ssh/id_rsa failed: No such file or directory. | |
Saving the key failed: //.ssh/id_rsa. |
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
using System; | |
using RestSharp; | |
namespace StatsMix | |
{ | |
// Requires RestSharp | |
// http://restsharp.org | |
// http://github.com/johnsheehan/RestSharp | |
// Usage |
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
twilio.SendSmsMessageAsync("5551111111", "5552222222", "Async! ", (msg) => { | |
Dispatcher.BeginInvoke(() => { txtOutput.Text = msg.Sid; }); | |
}); | |
twilio.SendSmsMessageAsync("5551111111", "5552222222", "Async! ", smsSent); | |
public void smsSent(SmsMessage msg) { | |
Dispatcher.BeginInvoke(() => { txtOutput.Text = msg.Sid; }); | |
} | |
// or |
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
using System; | |
using System.Net; | |
using System.IO; | |
using System.Text; | |
using System.Diagnostics; | |
using System.Threading; | |
namespace LongPolling | |
{ | |
class MainClass |