Skip to content

Instantly share code, notes, and snippets.

View krystalmonolith's full-sized avatar

Mark Deazley krystalmonolith

View GitHub Profile
@krystalmonolith
krystalmonolith / tcap
Created February 2, 2018 01:12
Capture multiple interfaces with tshark, hit ctrl-c and display resulting pcap files with wireshark.
#!/bin/bash
INTERFACES="enp3s0 enp4s0 brmn001"
TS="`date +%Y%m%dT%H%M%S`"
trap interrupted_tshark SIGINT SIGTERM
PIDS=""
PCAPFILES=""
@krystalmonolith
krystalmonolith / aptuu
Created November 29, 2018 12:56
apt update + upgrade bash script that logs to syslog for debian/ubuntu
#!/bin/bash
(((apt-get update && apt-get -y -q upgrade) 2>&1 | logger -t aptuu -p user.info); logger -t aptuu -p user.info "*** aptuu Completed. ***") &
tail -f /var/log/syslog
@krystalmonolith
krystalmonolith / DeepCopy.java
Last active November 29, 2018 13:04
Generic Java Deep Copy Class
package com.example;
import java.io.*;
public class DeepCopy {
private Class<?> clazz;
private byte[] byteData;
public <T> DeepCopy(T t) {
saveObject(t);
@krystalmonolith
krystalmonolith / javascript-truth.js
Last active February 24, 2019 21:17
Javascript Truth
const x = { One:1, Zero:0, False:false, True:true, Undefined:undefined, Null:null, StringTrue:'true', StringFalse:'false', StringUndefined:'undefined', StringNull:'null' };
console.log(x);
console.log('\n---------------------------------------------------------------------------\n');
for (let i in x) { console.log(i + ':' + x[i] + ':' + (x[i] ? 'true' : 'false')) }
// { One: 1,
// Zero: 0,
// False: false,
// True: true,
// Undefined: undefined,
@krystalmonolith
krystalmonolith / activity-type.service.spec.ts
Last active April 17, 2019 17:29
Refactored Angular Service Testing
// THE REFACTORED SERVICE TEST
import {ActivityTypeService} from './activity-type.service';
import {UrlService} from '..';
import {httpGetSpecDefinitions} from '../base/service-test-base';
const TEST_VALUE: Array<object> = [{x: 'obj1'}, {x: 'obj2'}];
describe('ActivityTypeService',
httpGetSpecDefinitions((spy) => new ActivityTypeService(spy, new UrlService()), TEST_VALUE));
@krystalmonolith
krystalmonolith / RandomDelayedCountedClicks.ts
Last active June 13, 2019 20:31
RxJS delayWhen example enhanced with clicks queued/completed and delays displayed.
import { fromEvent, interval } from 'rxjs';
import { delayWhen, map, tap, scan, debounce } from 'rxjs/operators';
let queued: number = 0;
let completed: number = 0;
const start = Date.now();
const clicks = fromEvent(document, 'click');
function tf(): number { return Date.now() - start };