This file contains hidden or 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 console = new AppConsole() | |
{ | |
ConsoleName = "Web Monitor - web" + id + ".zensales.net", | |
ConsoleDescription = "A simple app that monitors the status of web" + id + ".zensales.net and heals it if necessary.", | |
ConsoleID = "tskhrnetsr802tTNR80S" //any sufficiently long random string to prevent guessing - can generate an one-off with StringHelper.RandomString(64) | |
}; | |
console.Write("This is a log line that I'm writing"); | |
//Console can now be viewed at http://www.appconsole.net/console/tskhrnetsr802tTNR80S |
This file contains hidden or 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
@echo off | |
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" | |
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" | |
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" | |
set "datestamp=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%" | |
set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%" | |
cd j: |
This file contains hidden or 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
//a.start, a.end, b.start, b.end are all DateTime's | |
bool hasCollision = a.start <= b.start && a.end > b.start || b.start <= a.start && b.end > a.start; |
This file contains hidden or 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
//Input: "St. Patrick's Day: Awësöme tö-dö's" | |
//Output: "st-patricks-day-awesome-to-dos" | |
public static string MakeSlug(string url) | |
{ | |
url = RemoveDiacritics(url.ToLowerInvariant()); | |
url = Regex.Replace(url, @"[^a-z0-9\-\s]", ""); | |
url = Regex.Replace(url, @"\s+", "-"); | |
url = Regex.Replace(url, @"\-+", "-").Trim('-'); | |
return url; |
This file contains hidden or 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 static string GetContentType(string extension) | |
{ | |
if (extension.StartsWith(".")) | |
extension = extension.Substring(1); | |
extension = extension.ToLower(); | |
if (MimeTypes.ContainsKey(extension)) | |
return MimeTypes[extension]; | |
This file contains hidden or 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.Text; | |
using System.Security.Cryptography; | |
namespace PasswordHash | |
{ | |
/// <summary> | |
/// Salted password hashing with PBKDF2-SHA1. | |
/// Author: havoc AT defuse.ca | |
/// www: http://crackstation.net/hashing-security.htm |
This file contains hidden or 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 getFileName = function (url) { | |
return url.replace(/\?.*$/, "").replace(/.*\//, ""); | |
} |
This file contains hidden or 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 AWS = require('aws-sdk'); | |
AWS.config.region = 'us-east-1'; | |
var sns = new AWS.SNS(); | |
exports.handler = function(event, context) { | |
var count = event.Records.length; | |
var completed = function(err, data){ | |
This file contains hidden or 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
MemoryStream mem = new MemoryStream(); | |
using (GZipStream gz = new GZipStream(mem, CompressionLevel.Optimal, true)) | |
{ | |
var b = Encoding.UTF8.GetBytes(json); | |
gz.Write(b, 0, b.Length); | |
gz.Flush(); | |
} | |
var data = mem.ToArray(); |
This file contains hidden or 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
AmazonS3Client client = new AmazonS3Client(RegionEndpoint.USWest2); | |
MemoryStream mem = new MemoryStream(); | |
using (GZipStream gz = new GZipStream(mem, CompressionLevel.Optimal, true)) | |
{ | |
var b = Encoding.UTF8.GetBytes(json); | |
gz.Write(b, 0, b.Length); | |
gz.Flush(); | |
} |
NewerOlder