Skip to content

Instantly share code, notes, and snippets.

View markembling's full-sized avatar

Mark Embling markembling

View GitHub Profile
@markembling
markembling / hosts.ps1
Created August 24, 2009 13:38
Powershell script for adding/removing/viewing entries to the hosts file.
#
# Powershell script for adding/removing/showing entries to the hosts file.
#
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
#
$file = "C:\Windows\System32\drivers\etc\hosts"
function add-host([string]$filename, [string]$ip, [string]$hostname) {
@markembling
markembling / aliases.ps1
Last active May 25, 2023 07:07
Current Powershell Profile
#########################################
# Convenient PowerShell Alias functions #
#########################################
# Open the given directory in Explorer
# Usage: open .
function open {
explorer $args
}
@markembling
markembling / gitutils.ps1
Last active March 29, 2023 01:47
Powershell functions for git information
# Git functions for PowerShell
# Copyright 2009-2019 Mark Embling (http://www.markembling.info/)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
/*
* Change detection for forms
*
* @author Mark Embling
*
* Initialise on applicable forms using the jQuery plugin.
* Recommended one per page but this is not a requirement.
*
* Copyright © 2022 Mark Embling
*
# SSH Agent Functions
# Mark Embling (http://www.markembling.info/)
#
# How to use:
# - Place this file into %USERPROFILE%\Documents\WindowsPowershell (or location of choice)
# - Import into your profile.ps1:
# e.g. ". (Resolve-Path ~/Documents/WindowsPowershell/ssh-agent-utils.ps1)" [without quotes]
# - Enjoy
#
# Note: ensure you have ssh and ssh-agent available on your path, from Git's Unix tools or Cygwin.
@markembling
markembling / LICENCE
Created December 9, 2012 13:16
Google Drive & Spreadsheets Using OAuth 2.0 Service Account Example. See http://markembling.info/2012/12/google-spreadsheet-dotnet-oauth2-service-account
Copyright (c) 2012, Mark Embling
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Mark Embling nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
@markembling
markembling / profile.ps1
Created September 4, 2009 12:27
My preferred prompt for Powershell - includes git info.
# My preferred prompt for Powershell.
# Displays git branch and stats when inside a git repository.
# See http://gist.github.com/180853 for gitutils.ps1.
. (Resolve-Path ~/Documents/WindowsPowershell/gitutils.ps1)
function prompt {
$path = ""
$pathbits = ([string]$pwd).split("\", [System.StringSplitOptions]::RemoveEmptyEntries)
if($pathbits.length -eq 1) {
@markembling
markembling / profile.ps1
Created June 12, 2018 13:02
Allow SSH agent installed and managed by posh-git to also be usable from other non-PowerShell processes (e.g. Tower Git client for Windows).
# Add this into your profile AFTER posh-git has been loaded and the SSH agent
# has been started.
[void][Environment]::SetEnvironmentVariable("SSH_AGENT_PID", [Environment]::GetEnvironmentVariable("SSH_AGENT_PID"), [EnvironmentVariableTarget]::User)
[void][Environment]::SetEnvironmentVariable("SSH_AUTH_SOCK", [Environment]::GetEnvironmentVariable("SSH_AUTH_SOCK"), [EnvironmentVariableTarget]::User)
# It may make it a little slower (as apparently writing to the user environment
# is slow), but will mean the SSH agent is visible to other processes.
@markembling
markembling / settings-actual.json
Last active March 17, 2017 12:32
JSON snippets associated with the Quora question at http://bit.ly/2mX0vh5
{
"editor.rulers": [
80,
120
],
"editor.renderWhitespace": "boundary",
"editor.minimap.enabled": true,
"editor.minimap.renderCharacters": false,
"editor.dragAndDrop": true,
"files.hotExit": "off",
@markembling
markembling / gist:1104836
Created July 25, 2011 18:42
A small ruby script which basically spams an MQTT broker.
require 'mqtt/client'
mqtt = MQTT::Client.new('10.25.2.4')
loop do
mqtt.connect do |c|
c.publish('test/foo/bar','this is a test message #{Time.now}')
puts "published a msg"