Skip to content

Instantly share code, notes, and snippets.

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)
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);
}
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
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;
namespace AutoMapperTest
{
class Program
{
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;
}
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
# basic example configuration for nginx with php-fpm
server {
root /usr/share/nginx/www;
index index.html index.htm;
server_name localhost;
location /app1 {
static class RandomExtensions
{
public static bool NextBoolean(this System.Random rng)
{
// 2 because Next returns values between 0 and max - 1
return rng.Next(2) > 0;
}
}
static char *keyword;
static char *args[10]; // array of pointers to the arguments (stored in command)
int parse_command(char *command, char **keyword, char *args[]) {
char *tmp;
int n;
tmp = strtok(command, " ");
if (tmp != NULL)
*keyword = tmp;