Skip to content

Instantly share code, notes, and snippets.

View jinweijie's full-sized avatar
🎾

Weijie JIN jinweijie

🎾
View GitHub Profile
@jinweijie
jinweijie / Readme.md
Created April 28, 2020 06:17 — forked from leopoldodonnell/Readme.md
Install and run Postgres with an extension using docker-compose

Local Postgres

This gist is an example of how you can simply install and run and extended Postgres using docker-compose. It assumes that you have docker and docker-compose installed and running on your workstation.

Install

  • Requires docker and docker-compose
  • Clone via http: git clone https://gist.github.com/b0b7e06943bd389560184d948bdc2d5b.git
  • Make load-extensions.sh executable
  • Build the image: docker-compose build
@jinweijie
jinweijie / Demo.cs
Created February 12, 2016 13:52 — forked from rowanmiller/Demo.cs
EF6.x | Correlating SQL to code
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.Infrastructure.Interception;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace Demo
function createCORSRequest (poMethod, pcURL) {
var oXHR = new XMLHttpRequest();
if ('withCredentials' in oXHR) {
// Check if the XMLHttpRequest object has a "withCredentials" property.
// "withCredentials" only exists on XMLHTTPRequest2 objects.
oXHR.open(poMethod, pcURL, true);
} else if (typeof XDomainRequest != 'undefined') {
// Otherwise, check if XDomainRequest.
// XDomainRequest only exists in IE, and is IE's way of making CORS requests.
function isCardNumberValid(cardNumber, allowSpaces) {
if (allowSpaces) {
cardNumber = cardNumber.replace(/ /g, '');
}
if (!cardNumber.match(/^\d+$/)) {
return false;
}
var checksum = 0;
@jinweijie
jinweijie / gist:7923887
Created December 12, 2013 06:14
Dynamic modify LoginUrl for FormsAuthentication
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration("/YourSite");
// Get the external Authentication section.
AuthenticationSection authenticationSection =
(AuthenticationSection)configuration.GetSection(
"system.web/authentication");
// Get the external Forms section .
FormsAuthenticationConfiguration formsAuthentication =
@jinweijie
jinweijie / gist:7544714
Created November 19, 2013 12:37
Email validation regex
^(?!\.)("([^"\r\\]|\\["\r\\])*"|([-a-z0-9!#$%&'*+/=?^_`{|}~] |(?@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$
@jinweijie
jinweijie / gist:6247885
Last active December 21, 2015 04:18
ASP.Net button confirm with validators
this.btnReject.OnClientClick = string.Format("if(!confirm('{0}')) return false;", Language.GetResource("AreYouSureToRejectTheForm", this.Page));
@jinweijie
jinweijie / gist:6218706
Created August 13, 2013 07:32
Clear Workflow Table
delete [System.Activities.DurableInstancing].[InstancePromotedPropertiesTable]
delete [System.Activities.DurableInstancing].[KeysTable]
delete [System.Activities.DurableInstancing].[InstanceMetadataChangesTable]
delete [System.Activities.DurableInstancing].[RunnableInstancesTable]
delete [System.Activities.DurableInstancing].[InstancesTable]
@jinweijie
jinweijie / gist:5268096
Created March 29, 2013 01:13
img to vhd installation
imagex /apply e:\sources\install.wim 1 f:\
@jinweijie
jinweijie / gist:5002787
Created February 21, 2013 06:50
Skip certificate check
static void Main(string[] args)
{
ServicePointManager.ServerCertificateValidationCallback +=
new RemoteCertificateValidationCallback(ValidateCertificate);
Console.WriteLine("Client starting...");
ApplicationService svc = new ApplicationService();
App app = svc.GetAppInfo();