Skip to content

Instantly share code, notes, and snippets.

@enxoco
enxoco / parseGoogleSearches.sh
Last active February 1, 2018 18:23
This is a one line to parse out google search parameters.
#!/bin/bash
#This is currently a one liner that I use against a Redwood access log to strip out just the date, username and search terms
#For my users.
#This is the old way I was doing it.
grep google.com /var/log/redwood/access.log | grep -Ev 'carddav|calendar|inbox.google.com|ssl-bump|clients3.google.com|mail.google.com|gstatic.com' | grep search | grep q= | awk -F',' '{print $1","$2","$4}' | sort | uniq | sed 's/q=/ql=,/g' | awk -F',' '{print $1","$2","$4}' | sort | uniq | awk -F',' '!seen[$3]++' | sed 's/&/,&/g' | awk -F',' '{print$1","$2","$3}' | sed 's/%20/ /g'
#This is a better approach. The above code will return all of the requests that are sent to the autorequest engine, while this script excludes those and only returns us the actual search terms
grep "google.com/search?" /var/log/redwood/access.log | grep -v google.com/search/complete | sed -e 's/&q=/,/g; s/&/,/g; s/+/ /g' | awk -F, '{print$1","$2","$3","$4}' | sed 's/q=/,/g' | awk -F, '{print $1","$2","$3","$5}' | awk '$4!=""'
@enxoco
enxoco / SetProxy.ps1
Created March 20, 2018 18:56
Set up system proxy on Windows via powershell.
$port=$args[0]
$password=$args[1]
Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name AutoConfigURL -Value "http://00.adam.nxone.co:$port/proxy.pac?a=$password"
Write-Host "Set Autoconfig setting"
Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name ProxyEnable -value 1
Write-Host "Enabled Proxy"
$signature = @'
[DllImport("wininet.dll", SetLastError = true, CharSet=CharSet.Auto)]
function countUp(t,e,i,o,s,a){this.options=a||{useEasing:!0,useGrouping:!0,separator:",",decimal:"."};for(var n=0,r=["webkit","moz","ms"],l=0;l<r.length&&!window.requestAnimationFrame;++l)window.requestAnimationFrame=window[r[l]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[r[l]+"CancelAnimationFrame"]||window[r[l]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(t,e){var i=(new Date).getTime(),o=Math.max(0,16-(i-n)),s=window.setTimeout(function(){t(i+o)},o);return n=i+o,s}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)});var d=this;this.d="string"==typeof t?document.getElementById(t):t,this.startVal=Number(e),this.endVal=Number(i),this.countDown=this.startVal>this.endVal,this.startTime=null,this.timestamp=null,this.remaining=null,this.frameVal=this.startVal,this.rAF=null,this.decimals=Math.max(0,o||0),this.dec=Math.pow(10,this.decimals),this.duration=1e3*s||2e3,this.easeOutExpo=function(t,e,i,o){return i*
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-111383435-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
@enxoco
enxoco / index.html
Created June 17, 2019 12:15
bridgeScholars 9th grade
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="./style.css">
</head>

Keybase proof

I hereby claim:

  • I am enxoco on github.
  • I am enxo (https://keybase.io/enxo) on keybase.
  • I have a public key ASCvGX6Nnbelcbe4OHg7oFmsrx4x0GYgUcOVlbrxI6GHLAo

To claim this, I am signing this object:

@enxoco
enxoco / StoreController.js
Created September 27, 2019 16:18
This is the code that is responsible for rendering a store locator view. It uses Mapbox and Turf.js to calculate the distance of each store relative to the user and sort them based on the closest one. pickup-flow.js is the frontend code that runs in the browser while StoreController.js is the backend controller method that pulls a list of stores…
'use strict'
const Database = use('Database')
const Env = use('Env')
const stripe = require('stripe')(Env.get('STRIPE_SK'))
class StoreController {
async showStores({request, response, view}) {
const stores = await Database
.table('locations')
@enxoco
enxoco / formAssemblyBallotMessage.js
Last active December 5, 2019 18:33
A simple bit of custom JavaScript to hide a FormAssembly form and show a custom message to the user when their ballot has been cast.
<script>
/*
* This script should be placed in Properties section of a form assembly form.
* It assumes that you have at least two visible text inputs. One named Ballot Status and one named Ballot Cast Message.
* For the script to work properly, Ballot Cast Message should NOT be a hidden field.
* The script will automatically hide it from the user but relies on a Title attribute which is not added to hidden fields by default.
*/
window.addEventListener('load', function () {
var ballotStatus = document.querySelector("input[title='Ballot Status']");
if (ballotStatus.value.toLowerCase() === 'cast') {// If ballot has been cast, hide form and show message.
var submitButton = document.getElementsByClassName('frm_final_submit')[0];
var addToCart = function() {
var appTypeCode = localStorage.getItem('appTypeCode');
// The rest of this function copied from
// https://gist.githubusercontent.com/mircian/709f93862edad5111e36b21c83c27b73/raw/2d5a1fa6cff6ceb684db397d3ad7bedc618344fc/woocommerce_simple_add_to_cart.js
if ( 'undefined' === typeof wc_add_to_cart_params ) {
// The add to cart params are not present.
return false;
@enxoco
enxoco / menu.css
Last active January 29, 2020 02:26
Add this css snippet somewhere.
@media (min-width: 1025px) {
ul#primary-menu {
display: flex;
align-items: center;
}
}
/* Update your main stylesheet. Should be style.css with this */
#site-navigation {
// Change grid-column from this
grid-column: 2/3;