Skip to content

Instantly share code, notes, and snippets.

private const string ssoPendingSessionKey = "ssoPending";
private const string ssoSPSessionKey = "partnerSP";
public ActionResult SSOService() {
// Either an authn request has been received or login has just completed in response to a previous authn request.
// The SSO pending session flag is false if an authn request is expected. Otherwise, it is true if
// a login has just completed and control is being returned to this page.
bool ssoPending = Session[ssoPendingSessionKey] != null && (bool)Session[ssoPendingSessionKey] == true;
string partnerSP = null;
private const string ssoPendingSessionKey = "ssoPending";
private const string ssoSPSessionKey = "partnerSP";
public ActionResult SSOService() {
// Either an authn request has been received or login has just completed in response to a previous authn request.
// The SSO pending session flag is false if an authn request is expected. Otherwise, it is true if
// a login has just completed and control is being returned to this page.
bool ssoPending = Session[ssoPendingSessionKey] != null && (bool)Session[ssoPendingSessionKey] == true;
string partnerSP = null;
private const string ssoPendingSessionKey = "ssoPending";
public ActionResult SSOService() {
// Either an authn request has been received or login has just completed in response to a previous authn request.
// The SSO pending session flag is false if an authn request is expected. Otherwise, it is true if
// a login has just completed and control is being returned to this page.
bool ssoPending = Session[ssoPendingSessionKey] != null && (bool)Session[ssoPendingSessionKey] == true;
if (!(ssoPending && User.Identity.IsAuthenticated)) {
string partnerSP = null;
var sw = Stopwatch.StartNew();
var msg = new StringBuilder();
bool error = false;
try
{
msg.AppendFormat("Doing something with xyz {0}", blah);
if (!string.IsNullOrEmpty(value))
{
// do something here
@dmarlow
dmarlow / gist:25b4ae6b93b9eac45d66
Created July 22, 2014 17:41
SMS2MQTT C# - Responding
var reply = JsonConvert.SerializeObject(new { cmdId = command.cmdId, body = command.body });
var replyBytes = Encoding.UTF8.GetBytes(reply);
mqttClient.Publish(MqttPubTopic, replyBytes, MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, false /* retain */);
@dmarlow
dmarlow / gist:fe4bdc40cfb36c178048
Created July 22, 2014 17:40
SMS2MQTT Python - Responding
def on_message(mosq, obj, msg):
m = msg.payload.decode("utf-8")
print(msg.topic + " " + str(msg.qos) + " " + m)
obj = json.loads(m)
client.publish("weather-app/reply", (json.dumps({"cmdId": obj["cmdId"], "body": obj["body"]})), 2)
import mosquitto, json
client = mosquitto.Mosquitto("weather-app")
# callbacks
def on_connect(mosq, obj, rc):
print("rc: " + str(rc))
def on_message(mosq, obj, msg):
m = msg.payload.decode("utf-8")
print(msg.topic + " " + str(msg.qos) + " " + m)
var sb = new StringBuilder();
var match = CommandRegex.Match(obj.body);
try
{
var hn = new HackerSharp();
var count = 1;
var countStr = match.Groups["count"].Value;
int countVal;
private static readonly Regex CommandRegex = new Regex(@"^(?<name>[a-zA-Z]+)\s?(?<count>[0-9]?)$");