Skip to content

Instantly share code, notes, and snippets.

View timsneath's full-sized avatar

Tim Sneath timsneath

View GitHub Profile
@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 / 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
# 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 / 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
#
@timsneath
timsneath / pubspec.yaml
Created April 4, 2018 23:51
Fragment of Flutter manifest to declare support for a custom font family
flutter:
uses-material-design: true
fonts:
- family: Patrick Hand
fonts:
- asset: assets/fonts/PatrickHand-Regular.ttf
@timsneath
timsneath / jokestate.dart
Last active April 5, 2018 00:07
Handling asynchronous state with a FutureBuilder widget
class JokePageState extends State<JokePage> {
Future<String> response;
initState() {
super.initState();
response = http.read(dadJokeApi, headers: httpHeaders);
}
Widget build(BuildContext context) {
return new Scaffold(
@timsneath
timsneath / customFont.dart
Created April 5, 2018 00:09
Adding a font to existing Flutter code
// declaring a text style based on custom font
const jokeTextStyle = const TextStyle(
fontFamily: 'Patrick Hand',
fontSize: 34.0,
color: Colors.black87,
letterSpacing: -0.5,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal);
// now all we have to do is add a style to the Text widget