Skip to content

Instantly share code, notes, and snippets.

View kaymccormick's full-sized avatar
🎯
Focusing

Kay McCormick kaymccormick

🎯
Focusing
View GitHub Profile
@kaymccormick
kaymccormick / README
Last active August 3, 2018 20:27 — forked from leandrosilva/README
Parsing Syslog files with Python and PyParsing
$ python xlogd.py sample.log
parsed: {'appname': 'test.app', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '68898', 'priority': '132', 'message': 'bla bla bla warn'}
parsed: {'appname': 'test.app', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '68902', 'priority': '131', 'message': 'bla bla bla error'}
parsed: {'appname': 'Dock', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '154', 'priority': '11', 'message': 'CGSReleaseWindowList: called with 5 invalid window(s)'}
parsed: {'appname': 'WindowServer', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '79', 'priority': '11', 'message': 'CGXSetWindowListAlpha: Invalid window 0'}
================================= test session starts =================================
platform linux -- Python 3.7.0, pytest-3.7.3, py-1.6.0, pluggy-0.7.1
rootdir: /home/user/j/jade/newsrc/pyramid_res, inifile:
collected 0 items / 1 errors
======================================= ERRORS ========================================
___________________ ERROR collecting tests/test_resourceManager.py ____________________
ImportError while importing test module '/home/user/j/jade/newsrc/pyramid_res/tests/test_resourceManager.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
@kaymccormick
kaymccormick / pysyslog.py
Created October 21, 2018 13:24 — forked from marcelom/pysyslog.py
Tiny Python Syslog Server
#!/usr/bin/env python
## Tiny Syslog Server in Python.
##
## This is a tiny syslog server that is able to receive UDP based syslog
## entries on a specified port and save them to a file.
## That's it... it does nothing else...
## There are a few configuration parameters.
LOG_FILE = 'youlogfile.log'
@kaymccormick
kaymccormick / xsend
Created October 29, 2018 13:17 — forked from tskrynnyk/xsend
Command-line utility for sending jabber messages.
#!/usr/bin/python
# xsend: command-line utility for sending jabber messages
# http://xmpppy.sourceforge.net/
#
import sys,os,xmpp,time
if len(sys.argv) < 2:
print "Syntax: xsend JID msg"
sys.exit(0)
LINODE_CLI=linode-cli
CREATE_CMD_CATEGORY=create
ROOT_PASS=XXXX
SS_ID=349134
BOOTED=yes
STACKSCRIPT_DATA=stackscript-data.json
HOSTNAME=XXXX
PYTHON=python
LINODE_TOKEN=`cat .linode_token`
KERBEROS=yes
@kaymccormick
kaymccormick / get-dist-config.py
Created November 17, 2018 22:58
Use python-apt to extract disttributed config files. This will fill up your disk with package files!
#!/usr/bin/python3
import shutil
import apt_pkg
import apt_inst
import apt
import apt.debfile
import apt.progress
import aptsources.distinfo
import os.path
/*
* Host definitions with object attributes
* used for apply rules for Service, Notification,
* Dependency and ScheduledDowntime objects.
*
* Tip: Use `icinga2 object list --type Host` to
* list all host objects after running
* configuration validation (`icinga2 daemon -C`).
*/
[Unit]
Description=The PHP 7.3 FastCGI Process Manager
Documentation=man:php-fpm7.3(8)
After=network.target
[Service]
Type=simple
PIDFile=/opt/php-dev/var/run/php-fpm.pid
EnvironmentFile=/etc/default/php-dev-fpm
#ExecStart=/usr/bin/strace -o /tmp/out-trace -f /opt/php-dev/sbin/php-fpm --nodaemonize
import React from 'react'
import DocViewer from '../src/components/doc/Viewer'
import { setupSaxParser } from 'docutils-react/lib/getComponentForXmlSax'
import regeneratorRuntime from "regenerator-runtime";
export default class Viewer extends React.Component {
constructor(props) {
super(props);
}
@kaymccormick
kaymccormick / copyTree.ts
Created August 3, 2019 13:44
recursively copy an ast-types AST tree, in typescript
import {visit,getFieldNames, getFieldValue, eachField, namedTypes, builders} from 'ast-types';
import { NodePath } from 'ast-types/lib/node-path';
import { Map, List, Set} from 'immutable';
import { ValueKind } from './types';
export type CopyTreeResult = Map<string, ValueKind>;
export function copyTree(node: namedTypes.Node,
report?: (arg: string) => void,
level: number = 0): CopyTreeResult {
let cache: List<Map<string, any>> = List<Map<string, any>>();