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 / 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 / NetezzaGenerateExternal
Last active March 13, 2017 21:00
Netezza Generate External Command
CREATE EXTERNAL TABLE 'path/to/flat/file.dat'
USING ( delim ',' datestyle 'YMD' datedelim '-' REMOTESOURCE 'ODBC' requireQuotes true quotedvalue 'yes' LOGDIR 'path/to/log/directory/' nullvalue '') AS
SELECT *
FROM MonkeyPants
@formix
formix / xd2md.cs
Last active August 7, 2024 08:02
Generates Markdown From VisualStudio XML documentation files
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace Formix.Utils
{
class Program
@cmandersen
cmandersen / gist:91d840db222c3df543c2
Created July 2, 2014 04:26
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_=/.../...)
@weeksdev
weeksdev / commands.md
Last active March 9, 2016 15:19
Basic Git Commands
@weeksdev
weeksdev / Controller.js
Last active January 1, 2016 13:09
ExtJS MVC Snippets
Ext.define('App.controller.exampleController', {
extend: 'Ext.app.Controller',
init: function () {
this.control({
'#someButton': {
click: this.buttonAction
}
});
},
buttonAction: function (btn) {
anonymous
anonymous / regExFindConsoleLogsNotCommented
Created December 23, 2013 15:23
Regular Expression To Find console.logs that are not commented out
(?<!//)(?>console.log)(.*)(?=;)