Skip to content

Instantly share code, notes, and snippets.

View pistell's full-sized avatar
🥴
Unexpected token < in JSON at position 0

James Pistell pistell

🥴
Unexpected token < in JSON at position 0
View GitHub Profile
@pistell
pistell / resume.json
Last active September 30, 2020 00:05
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "James Pistell",
"label": "Front End Web Developer",
"image": "http://jamespistell.com/images/jp_bwsmall.jpg",
"email": "jamespistell@gmail.com",
"phone": "(315) 576-5094",
"url": "http://jamespistell.com",
"summary": "James hails from Rochester, NY. He earned his degree from the State University of New York College at Brockport. Before starting his niche SaaS application he worked at YPC Media as the Director of MarTech solutions. While his work blended knowledge of digital marketing and programming, his non-work interests range widely from world history to JavaScript. In his spare time James moonlights as a Captain in the Army National Guard's 91st Cyber Brigade.",
@pistell
pistell / scrape.js
Last active January 4, 2021 00:11
Scraping Multiple Pages on the Same Domain with Nightmare.js
// import the file system to save results to disk
const fs = require('fs');
// import Nightmare.js to scrape data
const Nightmare = require('nightmare')
// import vo to control the flow
const vo = require('vo')
// chalk just prints out nice things in the terminal. Useful for finding errors
const chalk = require('chalk')
// globally declare var for FileSystem's write stream
let stream;
@pistell
pistell / XMLRPC_Hack_Attempts
Created April 7, 2016 12:39
Finds IPs accessing xmlrpc.php from Apache logs and sorts them by connection attempts
grep -i "xmlrpc\.php" other_vhosts_access.log.1 | awk '{print $2 " " $8}' | sort | uniq -c | sort -n | tail > hack_attempts.txt
1. cd into your apache logs directory (ex- /var/log/apache2)
2. Run the grep command
This will search the file "other_vhosts_access_log.1" for the string "xmlrpc.php
Awk will then print out column 2 (the incoming connection) and column 8 (the file accessed)
Sorts by unique IPs then numbers them by attempts
Data is output to hack_attempts.txt for analysis
Example output::
@pistell
pistell / findAllwithNoClassOrID
Created March 25, 2015 11:35
Select all elements without a class or ID
jQuery('*:not([id]):not([class])');
//replace askterisk with whatever element you want
//eg- jQuery('img:not([id]):not([class])');
//will find all <img> tags with no class or ID
@pistell
pistell / gaTrackDownloads
Created March 25, 2015 07:20
Listen for Clicks and Track Event in Analytics
jQuery('.download').live('click', function(){
var pdfPage = document.querySelector(".entry-title").innerText.split(" ").slice(0,-2).join(" ");
_gaq.push(['_trackEvent', 'Download', pdfPage]);
});
//Line 1- Initialize jQuery, select the 'download' class, add a click even listener
//Line 2- pdfPage selects the 'entry-title' div, splits the text by whitespace, removes the last 2 elements, and joins them together
//Line 3- sends an event to Analytics with a category of "download" and an action value of pdfPage
@pistell
pistell / conditionalNoFollow
Created March 25, 2015 04:33
Add a nofollow attribute on all pages EXCEPT the homepage
<?php if (!is_home()) { ?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.theme-info a').attr('rel','nofollow');
});
</script>
<?php } ?>
<!--
Line 1- Initializes PHP and checks to see if the page is NOT on the home page