Skip to content

Instantly share code, notes, and snippets.

View pganti's full-sized avatar

Paddy Ganti pganti

  • Instart Logic
  • Bay Area,CA
View GitHub Profile
@pganti
pganti / mcast_listener.py
Created November 17, 2019 16:26
multicast listener
# listener for multicast stats
import socket
import struct
import json
MCAST_GRP = '224.0.0.251'
MCAST_PORT = 6000
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
@pganti
pganti / json_splitter.sh
Created November 17, 2019 16:10
json splitter
#!/bin/bash
FILENAME=$1
FILESTEM=`echo "$FILENAME" | cut -d'.' -f1`
NUM_FILES=$2
# Hack to get the right number of files
NUM_FILES=$((NUM_FILES-1))
LC=`wc -l $FILENAME | awk '{print $1}'`
LC_FILE=$((LC / NUM_FILES))
echo 'Going to split the files now ...'
split -l $LC_FILE $FILENAME ${FILESTEM}-Part # Split the file into chunks of 20 lines each
@pganti
pganti / csv_splitter.sh
Created November 17, 2019 16:09
split csv files
#!/bin/bash
FILENAME=$1
FILESTEM=`echo "$FILENAME" | cut -d'.' -f1`
NUM_FILES=$2
# Hack to get the right number of files
NUM_FILES=$((NUM_FILES-1))
LC=`wc -l $FILENAME | awk '{print $1}'`
LC_FILE=$((LC / NUM_FILES))
HDR=$(head -1 $FILENAME) # Pick up CSV header line to apply to each file
echo 'Going to split the files now ...'
when CLIENT_ACCEPTED {
set req 0
TCP::collect 7
}
when CLIENT_DATA {
if { [string range [TCP::payload] 0 6] equals "CONNECT" } {
set lines [split [TCP::payload] "\n"]
log local0.info "lines = $lines"
set m 0
@pganti
pganti / download_chrome41.js
Created May 6, 2019 22:06 — forked from ebidel/download_chrome41.js
For when you need to test your site in Google Search (Chrome 41).
/**
* Copyright 2018 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@pganti
pganti / har.js
Created April 2, 2019 22:59
pupetter create har
const fs = require('fs'); [2/6256]
const { promisify } = require('util');
const puppeteer = require('puppeteer');
const { harFromMessages } = require('chrome-har');
// list of events for converting to HAR
const events = [];
// list of promises that get the response body for a given response event
@pganti
pganti / rum.js
Created March 9, 2019 00:35
google rum for ads
(function() {
var aa =
"function" == typeof Object.create
? Object.create
: function(a) {
function b() {}
b.prototype = a;
return new b();
},
ba;
@pganti
pganti / rum.js
Created March 9, 2019 00:35
google rum for ads
(function() {
var aa =
"function" == typeof Object.create
? Object.create
: function(a) {
function b() {}
b.prototype = a;
return new b();
},
ba;
@pganti
pganti / hb
Created February 12, 2019 04:45
cleartargeting
`slot.getTargetingKeys().forEach(function(key){
if(key.substring(0,3) == 'hb_'){
slot.clearTargeting(key);
}
});`
@pganti
pganti / pubads_impl.js
Created February 8, 2019 21:40
gpt_timing
(function(_) {
var window = this
, document = this.document;
var ca, fa, ha, ka, la, oa, ra, sa, xa, Ba, Aa, za, Da, Ja, Ha, Ia, Ka, La, Ma, Na;
_.m = function(a) {
return function() {
return _.aa[a].apply(this, arguments)
}
}
;