Skip to content

Instantly share code, notes, and snippets.

Dariel Marlow dmarlow

Block or report user

Report or block dmarlow

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SAMLController3.cs
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;
View SAMLController2.cs
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;
View SAMLController1.cs
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;
View gist:a7f65342d55630dcde2c
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 Jul 22, 2014
SMS2MQTT C# - Responding
View gist:25b4ae6b93b9eac45d66
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 Jul 22, 2014
SMS2MQTT Python - Responding
View gist:fe4bdc40cfb36c178048
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)
View gist:4784d2080db9c7a51590
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)
View gist:9b584475b025c2bc277a
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;
View gist:2ea49c00ebc2e4e8e951
private static readonly Regex CommandRegex = new Regex(@"^(?<name>[a-zA-Z]+)\s?(?<count>[0-9]?)$");
You can’t perform that action at this time.