Skip to content

Instantly share code, notes, and snippets.

View johnmurch's full-sized avatar

John Murch johnmurch

View GitHub Profile
@yanofsky
yanofsky / track_changes_anon.sh
Created August 25, 2013 21:28
A script to anonymize a Word document's track changes.
#change the working directory to the Desktop
cd ~/Desktop
#unzip the word doc into a new directory called anonDocument
unzip myDocument.docx -d anonDocument/
#search all of the files in the word doc package and replace any comment or track changes author with anonymous edit
grep -rl "w:author" ./anonDocument | xargs sed -i '' 's/w:author="[a-zA-Z0-9 ]*"/w:author="anonymous edit"/g'
#change the working directory to the anonDocument directory
@nikreiman
nikreiman / gist:1408399
Created November 30, 2011 08:06
Unix date formatting cheat sheet
Day
---
%a weekday, abbreviated Tue
%A weekday, full Tuesday
%d day of the month (dd), zero padded 22
%e day of the month (dd) 22
%j day of year, zero padded 001-366
%u day of week starting with Monday (1), i.e. mtwtfss 2
%w day of week starting with Sunday (0), i.e. smtwtfs 2
<!-- For our post on email personalization at scale: https://www.hull.io/blog/email-personalization/ -->
<!-- Read and subscribe to Hull -->
<p>Hi {% if customer.first_name != blank %}{{ customer.first_name | capitalize }}{% else %}there{% endif %},</p>
<p>
{% if customer.clearbit-employment_name == "Drift" %}
Last week, we saw you guys launched your new marketing email product. Congrats! We love the direction you're challenging marketers to take.
{% elsif customer.clearbit-location contains "Boston" %}
Last week, you might have seen another Boston-based tech company launching their new marketing email product.
How to install and run Headless nightmare.js based scripts in Ubuntu.
Steps:
1. Spin Ubuntu 16.04 x64 server
2. Run: apt-get update
3. Run: apt-get upgrade
4. Run: apt-get install -y libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb
5. Install Node.js 6+. See: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
You can then run your script using this command:
@lukebiggerstaff
lukebiggerstaff / AJAXTable.js
Last active December 21, 2019 04:54
A script to create a mobile first responsive table using AJAX and vanilla javascript
var getTableDataAJAX = function() {
var getTableData = new XMLHttpRequest();
getTableData.onreadystatechange = function() {
if(getTableData.readyState === 4) {
var tableInfo = JSON.parse(getTableData.responseText);
var tableHeading = tableInfo.tableHeading;
var tableCellsPets = tableInfo.tableCellsPets;
var tableCellsPeople = tableInfo.tableCellsPeople;
console.log([...new Set(new URL('https://www.amazon.com/SanDisk-128GB-microSDXC-Memory-Adapter/dp/B073JYC4XM/memory').pathname.toLowerCase().split(/-|\//gi).filter(Boolean))])
//output handles dupes for casing and removes falsy values
//[ 'sandisk','128gb','microsdxc','memory','adapter','dp','b073jyc4xm' ]
@magician11
magician11 / headless-chrome.js
Last active August 12, 2020 13:03
How to grab the page source from any dynamically generated webpage and then process it .
const CDP = require('chrome-remote-interface');
const chromeLauncher = require('chrome-launcher');
const cheerio = require('cheerio');
(async function() {
const launchChrome = () =>
chromeLauncher.launch({ chromeFlags: ['--disable-gpu', '--headless'] });
const chrome = await launchChrome();
const protocol = await CDP({ port: chrome.port });
@stagas
stagas / how-to-run-apache-and-node.js-together-the-right-way.markdown
Created December 24, 2010 14:45
How to run Apache and Node.js together (the right way)

Step 1

Get a VPS that offers 2 or more IP addresses.

Step 2

From the WHM cPanel, find the menu item Service Configuration, select Apache Configuration and then click on Reserved IPs Editor.

Step 3

@alexwilson
alexwilson / cloudflare-challenge.js
Last active September 3, 2021 17:23
This is a project designed to get around sites using Cloudflare's "I'm under attack" mode. Using the PhantomJS headless browser, it queries a site given to it as the second parameter, waits six seconds and returns the cookies required to continue using this site. With this, it is possible to automate scrapers or spiders that would otherwise be t…
/**
* This is a project designed to get around sites using Cloudflare's "I'm under attack" mode.
* Using the PhantomJS headless browser, it queries a site given to it as the second parameter,
* waits six seconds and returns the cookies required to continue using this site. With this,
* it is possible to automate scrapers or spiders that would otherwise be thwarted by Cloudflare's
* anti-bot protection.
*
* To run this: phantomjs cloudflare-challenge.js http://www.example.org/
*
* Copyright © 2015 by Alex Wilson <antoligy@antoligy.com>
@jpetitcolas
jpetitcolas / gist:5967887
Created July 10, 2013 16:37
Encode/decode a base64 encoded string in PostGreSQL
-- Decoding
SELECT CONVERT_FROM(DECODE(field, 'BASE64'), 'UTF-8') FROM table;
-- Encoding
SELECT ENCODE(CONVERT_TO(field, 'UTF-8'), 'base64') FROM table;