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
| # basic example configuration for nginx with php-fpm | |
| server { | |
| root /usr/share/nginx/www; | |
| index index.html index.htm; | |
| server_name localhost; | |
| location /app1 { |
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.Drawing; | |
| using System.Windows.Forms; | |
| // based on http://alanbondo.wordpress.com/2008/06/22/creating-a-system-tray-app-with-c/ | |
| namespace MyTrayApp | |
| { | |
| public partial class TrayApp : Form |
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
| private static string GetCharacterNameFromSkyrimSaveFileName(string filename) | |
| { | |
| var re = new Regex(@"save \d+ - (?<charname>[\w]+)\s+([\w\s])+\s+\d{2}\.\d{2}.\d{2}", RegexOptions.IgnoreCase); | |
| var m = re.Match(Path.GetFileName(filename)); | |
| return m.Success ? m.Groups["charname"].Value : null; | |
| } |
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.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using AutoMapper; | |
| namespace AutoMapperTest | |
| { | |
| class Program | |
| { |
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
| SET NOCOUNT ON | |
| DECLARE @Starts DATETIME | |
| DECLARE @Ends DATETIME | |
| SET @Starts = '2014-06-05 00:00:00' | |
| SET @Ends = '2014-06-05 23:59:00' | |
| select |
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 Class LoginCheckHttpModule | |
| Implements IHttpModule | |
| Public Sub Dispose() Implements System.Web.IHttpModule.Dispose | |
| End Sub | |
| Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init | |
| AddHandler context.PostAcquireRequestState, AddressOf OnPostAcquireRequestState | |
| End Sub |
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 abstract class BasePage : System.Web.UI.Page | |
| { | |
| protected override void OnInit(EventArgs e) | |
| { | |
| // cache none of the things! | |
| Response.Cache.SetCacheability(HttpCacheability.NoCache); | |
| Response.Cache.SetNoStore(); | |
| Response.Cache.SetMaxAge(TimeSpan.Zero); | |
| base.OnInit(e); | |
| } |
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 TimeSpan GetTimePeriod(string str) | |
| { | |
| if (str == null) | |
| throw new ArgumentNullException("str"); | |
| // Plain old regex: ([\+-]?)(\d+)([A-Za-z]+)? | |
| Regex re = new Regex("(?<Operator>[+\\-]?)(?<Value>\\d+)(?<Unit>[A-Za-z]+)?", RegexOptions.IgnoreCase); | |
| Match m = re.Match(str); | |
| if (m.Success) |
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 ReadToEnd(this StreamReader reader, int maximumCharacters) | |
| { | |
| var builder = new System.Text.StringBuilder(); | |
| while (true) | |
| { | |
| var line = reader.ReadLine(); | |
| if (line == null) | |
| break; | |
| if (builder.Length + line.Length > maximumCharacters) |
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
| long targetFileSize = UUInt32.MaxValue + (long)(UInt32.MaxValue / 2); | |
| long bytesWritten = 0; | |
| byte[] buf = new byte[8192]; | |
| var rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); | |
| using (var output = File.Open(@"C:\tmp\garbage.dat", FileMode.CreateNew, FileAccess.Write, FileShare.None)) | |
| { | |
| while (bytesWritten < targetFileSize) | |
| { | |
| rng.GetBytes(buf); | |
| output.Write(buf, 0, buf.Length); |