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
private static readonly Regex CommandRegex = new Regex(@"^(?<name>[a-zA-Z]+)\s?(?<count>[0-9]?)$"); |
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 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; |
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 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) |
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
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) |
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 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 */); |
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 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 |
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
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; |
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
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; | |
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
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; | |