Skip to content

Instantly share code, notes, and snippets.

View sapslaj's full-sized avatar

Justin Roberson sapslaj

View GitHub Profile
@sapslaj
sapslaj / csv_json.rb
Last active April 25, 2018 13:15
Convert JSON to CSV and vice-vera
require 'csv'
require 'json'
require 'active_support/all'
def json_to_csv(json_file, csv_file)
CSV.open(csv_file, "w") do |csv|
data = JSON.parse(File.read(json_file))
csv << data.inject([]) { |keys, d| [keys, d.keys].flatten.uniq }.map(&:titleize)
data.each { |d| csv << d.keys.map { |key| d[key] } }
end

Keybase proof

I hereby claim:

  • I am sapslaj on github.
  • I am sapslaj (https://keybase.io/sapslaj) on keybase.
  • I have a public key ASAZ09ZrNEjgy5xOO8CX0mLyi7UyzRAOW-_9mywLmou7Ggo

To claim this, I am signing this object:

$IPType = "IPv4"
$adapter = Get-NetAdapter | ? {$_.Status -eq "up"}
$interface = $adapter | Get-NetIPInterface -AddressFamily $IPType
If ($interface.Dhcp -eq "Disabled") {
# Remove existing gateway
If (($interface | Get-NetIPConfiguration).Ipv4DefaultGateway) {
$interface | Remove-NetRoute -Confirm:$false
}
@sapslaj
sapslaj / netbox-quickstart.py
Created August 7, 2017 08:23
How to overcomplicate Django application installers.
from __future__ import unicode_literals
import code
import platform
import sys
import os
import getpass
from cmd import Cmd
@sapslaj
sapslaj / QuickDnsChange.ps1
Last active August 9, 2017 22:38
Quickly change DNS settings
# Automatically elevate to administrator
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
Add-Type -AssemblyName System.Windows.Forms
# This script assumes the Windows Server installation is already joined to a
# domain. There might be further tweaks needed to make it work between non-
# domain joined computers due to the differences between firewall profiles.
# Quick sanity check
Enable-PSRemoting
winrm qc
# Set up firewall display groups to be enabled.
# Protip: if you want to find out where to add more to this list, go to the
@sapslaj
sapslaj / status.php
Created March 9, 2017 23:39
Prevents unwanted information from leaking in a public Nextcloud instance.
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Andreas Fischer <[email protected]>
* @author Christopher Schäpers <[email protected]>
* @author Frank Karlitschek <[email protected]>
* @author Joas Schilling <[email protected]>
* @author Jörn Friedrich Dreyer <[email protected]>
* @author Lukas Reschke <[email protected]>
@sapslaj
sapslaj / Dockerfile
Last active March 16, 2020 06:44
Cisco Packet Tracer 7 Inside a Docker Container
FROM ubuntu:14.04
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
mkdir -p /home/pt && \
echo "pt:x:${uid}:${gid}:PacketTracer:/home/pt:/bin/bash" >> /etc/passwd && \
echo "pt:x:${uid}:" >> /etc/group && \
echo "pt ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/pt && \
chmod 0440 /etc/sudoers.d/pt && \
chown ${uid}:${gid} -R /home/pt
@sapslaj
sapslaj / nodelist-array-polyfill.js
Created November 10, 2016 16:17
Hack NodeList to use toArray() so you can then use forEach and stuff. Don't use it unless you are a lazy dirtbag though.
// Don't do this.
NodeList.prototype.toArray = function () {
var newArray = [];
for (var i = 0; i < this.length; i++) {
newArray.push(this[i]);
}
return newArray;
}
[ 0.000000] Linux version 4.5.5-300.fc24.x86_64 ([email protected]) (gcc version 6.1.1 20160510 (Red Hat 6.1.1-2) (GCC) ) #1 SMP Thu May 19 13:05:32 UTC 2016
[ 0.000000] Command line: BOOT_IMAGE=vmlinuz initrd=initrd.img root=live:CDLABEL=Fedora-WS-Live-24-1-2 rd.live.image nomodeset
[ 0.000000] tseg: 0000000000
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x01: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x02: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x04: 'AVX registers'
[ 0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[ 0.000000] x86/fpu: Using 'lazy' FPU context switches.
[ 0.000000] e820: BIOS-provided physical RAM map: