Skip to content

Instantly share code, notes, and snippets.

@xandout
xandout / grid2LatLng.js
Last active August 29, 2015 14:02
Convert NC Grid to LatLng
/*
Usage: var convertedGrid = gridToLatLng("3542A8115A");
Returns:
{ sw: [ 35.7125, -81.2625 ],
se: [ 35.7125, -81.26666666666667 ],
ne: [ 35.71666666666667, -81.26666666666667 ],
nw: [ 35.71666666666667, -81.2625 ] }
@xandout
xandout / LiveHosts
Last active August 29, 2015 14:16
PowerShell Find Live Hosts
$ping = New-Object System.Net.Networkinformation.Ping
1..254 | % {
$test = $ping.Send("192.168.1.$_", 50);
If($test.status -eq "Success"){
Write-output $test.address.IPAddressToString
}
}
@xandout
xandout / QNAP-watchMDADM.sh
Created March 19, 2015 16:34
Watch MDADM progress on QNAP.
#the busybox on my QNAP TS-420U does not have the watch command so.......
while sleep 5; do
cls; #clear the screen in the loop incase the string length changes dramatically.
TM=`date`;
STATUS=`grep finish /proc/mdstat`;
echo -ne "$TM$STATUS"\\r; #-ne and \\r(escape the escape char) will make it update in place. http://stackoverflow.com/a/12628482
done
@xandout
xandout / jswitch.js
Created March 28, 2015 03:45
Simple L2 Switch Implementation
var switchport = function(vlan){
this.vlan = vlan;
this.attach = function(device){
this.device = device.mac;
}
}
var vlan = function(vlanid, ipaddress){
this.vlanid = vlanid;
this.ipaddress = ipaddress || null;
@xandout
xandout / addSuperUser.sh
Created May 6, 2015 15:26
Add super user to MySQL without credentials
#!/bin/bash
echo ""
echo ""
read -e -p "Enter new username: " NEW_USER
read -e -p "Enter new password: " NEW_PASS
echo "----To stop MySQL and restart in safe mode"
echo ""
@xandout
xandout / DatabaseGet.java
Last active May 20, 2020 15:49
Get JSON from MySQL -- Java
import org.json.JSONArray;
import org.json.JSONObject;
import java.sql.*;
/**
* Created by Mitchell on 6/26/2015.
*/
public class DatabaseGet {
private Connection connection = null;
public DatabaseGet(String host, String username, String password, String database){
String HOST = "jdbc:mysql://" + host + "/" + database;
@xandout
xandout / gist:f3c41f5aecefc47af2e1
Created August 25, 2015 19:59
Brocade FGS Layer 3 Mode
FGS648P Switch>en
No password has been assigned yet...
FGS648P Switch#sh flash
Stack unit 1:
Compressed Pri Code size = 2878713, Version 07.2.02mT7e1 (FGS07202m.bin)
Compressed Sec Code size = 3183489, Version 07.2.02mT7e1 (FGSL07202m.bin)
Compressed Boot-Monitor Image size = 416213, Version 05.0.00T7e5
Code Flash Free Space = 2088960
FGS648P Switch#configure terminal
FGS648P Switch(config)#boot system flash secondary
@xandout
xandout / CDNS.c
Last active September 3, 2015 04:16
Playing with DNS packets in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock.h>
#include <time.h>
#define BUFFER_SIZE 4096
void usage(void);
@xandout
xandout / TrelloHorizontalScroll.js
Last active February 23, 2021 16:54
Enable horizontal scrolling on Trello boards
//To create a bookmarklet just append javascript: to this code and set as the URL in a new bookmark
var el = document.getElementById('board');
el.className += " trello-scroll";
document.addEventListener("wheel", function(e){
var under = document.elementFromPoint(e.clientX, e.clientY);
if(hasClass(under, "list-wrapper") || hasClass(under, "trello-scroll")){
if((e.wheelDelta>0?"left":"right") == "right"){
el.scrollLeft += 10;
} else {
el.scrollLeft -= 10;
#!/bin/python
"""
python report.py | sendmail user@domain.com
"""
import yum, platform
import os
from collections import namedtuple
DiskUsage = namedtuple('DiskUsage', 'total used free')