Skip to content

Instantly share code, notes, and snippets.

@Mossman1215
Mossman1215 / Aggregate.php
Last active September 5, 2017 03:38
Aggregate Number of High CPU alerts from Nagios Logs
#grep the logs like this
#grep "SERVICE ALERT: <instanceid>;Load;.* : CRITICAL" /var/log/nagios3/archives/nagios-* > critical_load.txt
<?php
$file = file('~/critical_load.txt');
#initialise empty hashmap
$map = array();
$hours = array();
foreach($file as $line){
#read timestamp
$guffpos = strpos($line,'[')+1;
@Mossman1215
Mossman1215 / gdrive.el
Created August 9, 2018 04:47
Sync my work notes to google drive when saving
(defun save-gdrive ()
"Sync org file to GDrive with rclone."
(when (eq major-mode 'org-mode)
(shell-command-to-string "rclone sync $HOME/org/notes.org gdrive:notes.org")
(shell-command-to-string "rclone sync $HOME/org/notes.org_archive gdrive:notes.org_archive")
))
(add-hook 'after-save-hook 'save-gdrive)
@Mossman1215
Mossman1215 / spritesheet.py
Created August 9, 2018 08:25
create a spritesheet from a folder of images
#from https://minzkraut.com/2016/11/23/making-a-simple-spritesheet-generator-in-python/
from PIL import Image
import os, math, time
max_frames_row = 16.0
frames = []
tile_width = 0
tile_height = 0
spritesheet_width = 0
spritesheet_height = 0
@Mossman1215
Mossman1215 / export.py
Last active December 15, 2018 03:30
Export screen space bounding box during blender render
import bpy
import bpy_extras
import json
import os
from mathutils import *
from math import *
def write_frame(scene):
print("----Starting Render function----")
with open('collision.json', 'r') as f:
- name: Install and Configure Solr
hosts: localhost
become: yes
gather_facts: yes
vars:
solr_change_default_password: False
solr_port: 80
roles:
- role: lean_delivery.java
- role: lean_delivery.solr_standalone
@Mossman1215
Mossman1215 / Chown.ps1
Last active March 6, 2022 17:00
Change ownership powershell snippet
#References
#base script
#https://stackoverflow.com/questions/22988384/powershell-change-owner-of-files-and-folders
#parameters
#https://powershell.org/forums/topic/file-path-parameter/
param (
[Parameter(Mandatory=$true)]
[ValidateScript({Test-Path -Path $_})]
[string]$path
)
@Mossman1215
Mossman1215 / goss.yaml
Last active May 15, 2020 03:58
cwp web server test
port:
tcp:222:
listening: true
ip:
- 0.0.0.0
tcp6:80:
listening: true
ip:
- '::'
tcp6:222:
<?php
namespace SilverStripe\Com\Tasks;
use Psr\Log\LoggerInterface;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\BuildTask;
use SilverStripe\Versioned\Versioned;
use SilverStripe\CMS\Model\SiteTree;
/**
* export site tree for performance testing
#requires pyvips and ruby-image-processing on ubuntu
import pyvips
import argparse
import pathlib
parser = argparse.ArgumentParser(description='resize images ')
parser.add_argument('images', metavar='file', nargs='+',
help='paths to files to shrink')
args = parser.parse_args()
for filepath in args.images:
image = pyvips.Image.new_from_file(filepath, access='sequential')

Keybase proof

I hereby claim:

  • I am mossman1215 on github.
  • I am mossman1215 (https://keybase.io/mossman1215) on keybase.
  • I have a public key ASAuKCd0pltWF-VE_tXaw9zAXOGartSlNO7f3uznOg19Qwo

To claim this, I am signing this object: