Skip to content

Instantly share code, notes, and snippets.

View weeksdev's full-sized avatar
🏠
Working from home

Andrew Weeks weeksdev

🏠
Working from home
View GitHub Profile
@weeksdev
weeksdev / server.js
Created May 17, 2016 00:47
Simple node express with static file serve
var express = require('express'),
app = express(),
bodyParser = require('body-parser'),
compress = require('compression');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(compress());
app.use(express.static('public'));
@weeksdev
weeksdev / gulpfile.js
Created May 3, 2016 01:40
Gulpfile to Build .net projects and deploy to github
var gulp = require('gulp'),
msbuild = require('gulp-msbuild'),
githubRelease = require('gulp-github-release'),
zip = require('gulp-zip'),
series = require('run-sequence'),
fs = require('fs');
gulp.task('build', function () {
return gulp.src('./SOLUTION_NAME.sln')
.pipe(msbuild({
@weeksdev
weeksdev / git-bash.md
Last active May 20, 2025 08:31
Add Git Bash as External Tool to Visual Studio
  1. Tools > External Tools
  2. Add
  3. Settings:
  4. title: Git Bash
  5. command: C:\Program Files (x86)\Git\bin\sh.exe
  6. arguments: --login -i
  7. initial directory: $(SolutionDir)
@weeksdev
weeksdev / Base.cs
Created January 28, 2016 14:21
WPF MVVM Binding Example
class Base : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
this.VerifyPropertyName(propertyName);
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
@weeksdev
weeksdev / web.config
Created December 10, 2015 14:21
IIS Web Config with All Http Verbs Allowed
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<!--
For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
@weeksdev
weeksdev / PhantomJsCrawl.js
Created November 27, 2015 22:53
PhantomJs Escaped Fragment Crawler
var fs = require('fs'),
//root url to start crawl from, it will only look for hashes in a links for the specified baseUrl
//so for instance, if you had a link to some other website http://www.abc.com/something-here it's NOT going to parse it
baseUrl = 'http://localhost:3000/',
//folder to save the html pages to
saveFolder = 'public/_escaped_fragment_/',
//array containing every link already parsed
parsedLinks = [];
//method to parse given url/hash and iterator that recursively calls the additional pages
var checkPage = function (page, url, hash) {
@weeksdev
weeksdev / escaped_fragment.js
Created November 27, 2015 22:49
Express NodeJs Implementation Of Escaped Fragment
//declarations
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var compress = require('compression');
//catch all get requests and determine if there is an escaped_fragment, if so reroute to a relative folder public/_escaped_fragment_/{}.html
//if you have more complex hashes than `#!Something` then you may have to mod this logic to suit your needs.
app.get("*", function (req, res, next) {
if (req.query._escaped_fragment_) {
//pull file from escaped fragments folder and serve it
@weeksdev
weeksdev / node.md
Last active September 27, 2015 00:07
get forever running with new nodejs
@weeksdev
weeksdev / gist:106d6e18ce5f60097c9e
Last active August 29, 2015 14:27 — forked from cmandersen/gist:91d840db222c3df543c2
Setup nginx to redirect Google's _escaped_fragment_= request to a snapshots folder
# This should be inserted into the server {...} block.
# These lines rewrite the url to access the snapshots folder, or where ever you keep
# you prerendered pages (mainly used when working with pages rendered by JavaScript).
#
# example.com/?_escaped_fragment_= --> example.com/snapshots/index.html
# example.com/?_escaped_fragment_=/blog --> example.com/snapshots/blog.html
# example.com/?_escaped_fragment_=/blog/post --> example.com/snapshots/blog/post.html
# Captures URLs with any amount of levels (?_escaped_fragment_=/.../...)
msbuild myproject.csproj /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile