Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / user-setup.sh
Last active September 30, 2015 20:20
user setup script
NEW_USER=
sudo useradd $NEW_USER
sudo mkdir /home/$NEW_USER/.ssh
sudo chown $NEW_USER:$NEW_USER /home/$NEW_USER/.ssh
sudo chmod 700 /home/$NEW_USER/.ssh
sudo touch /home/$NEW_USER/.ssh/authorized_keys
sudo chown $NEW_USER:$NEW_USER /home/$NEW_USER/.ssh/authorized_keys
sudo chmod 600 /home/$NEW_USER/.ssh/authorized_keys
@gregjhogan
gregjhogan / PPPoE-info.sh
Created October 9, 2015 05:09
Retrieve CenturyLink PPPoE username/password from technicolor C2000T
# first enable telnet, and connect
# then you will get a '>' prompt where you want to run the following commands
sh
pidstat -l -C pppd
# see -u (username) and -p (password) in the output
@gregjhogan
gregjhogan / list-certificates-for-iis.ps1
Last active December 16, 2015 16:39
List certificates for IIS
Get-ChildItem -Recurse CERT:\LocalMachine\MY
@gregjhogan
gregjhogan / DB_Copy_Data.ps1
Created December 16, 2015 16:37
SQL DB bulk copy tables
Set-StrictMode -Version Latest
trap
{
Write-Error $_.Exception
Write-Error $_.Exception.GetBaseException()
}
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
@gregjhogan
gregjhogan / test-db-connectivity.ps1
Created December 16, 2015 16:51
Test DB connectivity
& sqlcmd -S 'tcp:hostname,1433' -Q 'SELECT 1'
@gregjhogan
gregjhogan / npm-git-through-proxy
Last active January 26, 2016 22:24
npm calling git through proxy
Install git
https://git-for-windows.github.io/
Add the following to the system PATH variable (requires jenkins service restart):
C:\Program Files\Git\bin
Set proxy for git globally:
git config --system http.proxy http://proxy.com:8080
git config --system https.proxy http://proxy.com:8080
@gregjhogan
gregjhogan / ad-user-groups.ps1
Created January 26, 2016 22:32
List AD groups for user
import-module activedirectory
Get-ADPrincipalGroupMembership [user] | Select name
@gregjhogan
gregjhogan / ad-group-users.ps1
Created January 26, 2016 22:33
List AD users for group
import-module activedirectory
Get-ADGroupMember [group] | Select name
@gregjhogan
gregjhogan / Fibonacci.cs
Last active February 6, 2016 19:05
Fibonacci Sequence Calculator
public class Fibinocci
{
public readonly int N;
public Fibinocci(int n)
{
if (n < 0)
{
throw new Exception("n must be >= 0");
}
@gregjhogan
gregjhogan / windows-uptime.ps1
Created February 16, 2016 20:28
Get windows uptime
Get-WmiObject win32_operatingsystem | select csname, @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}