Skip to content

Instantly share code, notes, and snippets.

View timsneath's full-sized avatar

Tim Sneath timsneath

View GitHub Profile
@timsneath
timsneath / profile.ps1
Last active March 23, 2024 20:33
PowerShell template profile: adds some useful aliases and functions
### PowerShell template profile
### Version 1.03 - Tim Sneath <tim@sneath.org>
### From https://gist.github.com/timsneath/19867b12eee7fd5af2ba
###
### This file should be stored in $PROFILE.CurrentUserAllHosts
### If $PROFILE.CurrentUserAllHosts doesn't exist, you can make one with the following:
### PS> New-Item $PROFILE.CurrentUserAllHosts -ItemType File -Force
### This will create the file and the containing subdirectory if it doesn't already
###
### As a reminder, to enable unsigned script execution of local scripts on client Windows,
@timsneath
timsneath / ToolWindowStyles.xaml
Created October 21, 2015 20:01
Resource dictionary to map VS themes onto standard WPF controls
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0">
<Style TargetType="UserControl">
<Setter Property="Background" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowBackgroundBrushKey}}" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static vs:EnvironmentColors.ToolWindowTextBrushKey}}"/>
</Style>
### PowerShell personal template profile - Microsoft.PowerShell_profile.ps1
### Version 1.1 - Tim Sneath <tim@sneath.org>
###
### This file should be stored in $PROFILE.CurrentUserCurrentHost
### If $PROFILE.CurrentUserAllHosts doesn't exist, you can make one with the following:
### PS> New-Item $PROFILE.CurrentUserCurrentHost -ItemType File -Force
### This will create the file and the containing subdirectory if it doesn't already
# iPlayer
if (Test-Path 'C:\Program Files (x86)\get_iplayer')
@timsneath
timsneath / himawari.ps1
Last active August 20, 2017 17:46 — forked from MichaelPote/himawari.ps1
Windows Powershell Script to download the latest image from the Himawari-8 satelite, combine the tiles into a single image, convert to jpg and then set as the desktop background.
#
# Himawari-8 Downloader
#
#
#
# This script will scrape the latest image from the Himawari-8 satellite, recombining the tiled image,
# converting it to a JPG which is saved in My Pictures\Himawari\ and then set as the desktop background.
#
# http://himawari8.nict.go.jp/himawari8-image.htm
#
# Setup assets
$foldersToDelete = ,"$env:ProgramData\Microsoft\VisualStudio\Packages"
$foldersToDelete += "$env:AppData\Microsoft\VisualStudio\Packages"
$foldersToDelete |? { Test-Path $_ } |% { del -rec -for $_ }
# VS assets
# Any VS installation folders
if (test-path $env:ProgramData\Microsoft\VisualStudio\Packages\_Instances) {
gci $env:ProgramData\Microsoft\VisualStudio\Packages\_Instances -filter state.json -recurse | gc -raw | convertfrom-json | select -expand installationPath | del -force -recurse
}
@timsneath
timsneath / Program.cs
Created March 11, 2017 23:35
Here is a test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp8
{
class Program
{
@timsneath
timsneath / CreateGist.cs
Created March 11, 2017 23:45
Gets the file currently being edited
private string GetCurrentFilenameFromEditor()
{
var textManager = this.ServiceProvider.GetService(typeof(SVsTextManager)) as IVsTextManager;
int mustHaveFocus = 1;
textManager.GetActiveView(mustHaveFocus, null, out IVsTextView textView);
var userData = textView as IVsUserData;
if (userData == null)
{
// no text view is currently open
@timsneath
timsneath / CreateGist.cs
Created March 11, 2017 23:46
Gets the filename for the file currently visible in the Visual Studio code editor
private string GetCurrentFilenameFromEditor()
{
var textManager = this.ServiceProvider.GetService(typeof(SVsTextManager)) as IVsTextManager;
int mustHaveFocus = 1;
textManager.GetActiveView(mustHaveFocus, null, out IVsTextView textView);
var userData = textView as IVsUserData;
if (userData == null)
{
// no text view is currently open
@timsneath
timsneath / # README
Last active December 13, 2020 22:45
Settings files
My dotfiles
@timsneath
timsneath / joke.dart
Last active April 6, 2018 16:00
Basic example of an async HTTP GET call to a JSON web service
import 'package:http/http.dart' as http;
import 'dart:convert';
const dadJokeApi = "https://icanhazdadjoke.com/";
const httpHeaders = const {
'User-Agent': 'DadJokes (https://github.com/timsneath/dadjokes)',
'Accept': 'application/json',
};
main() async {