Skip to content

Instantly share code, notes, and snippets.

View Regenhardt's full-sized avatar

Marlon Regenhardt Regenhardt

  • Softfair
  • Terra
View GitHub Profile
@Regenhardt
Regenhardt / MyNumberPicker.java
Last active August 29, 2015 14:17
Like NumberPicker, but with values min, max, initial in xml!
import android.content.Context;
import android.util.AttributeSet;
import android.widget.NumberPicker;
/**
* Created by Marlon on 26.03.2015.
*/
public class MyNumberPicker extends NumberPicker {
public MyNumberPicker(Context context) {
super(context);
@Regenhardt
Regenhardt / My.snippet
Created June 23, 2017 12:13
C# code snippets
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<!-- propnfy -->
<CodeSnippet Format="1.0.0">
<Header>
<Title>Full, notifying Property</Title>
<Author>Marlon Regenhardt</Author>
<Description>Full property, notifying when changed</Description>
<Shortcut>propnfy</Shortcut>
<Grid Visibility="{Binding BubbleVisible, Converter={StaticResource BoolToVis}}" Height="56" Width="56" HorizontalAlignment="Left" VerticalAlignment="Top">
<!--Bind keyinputs-->
<Grid.InputBindings>
<MouseBinding Gesture="LeftClick" Command="{Binding SwitchViews}"/>
</Grid.InputBindings>
<!--The bubble-->
<Grid.Background>
<ImageBrush ImageSource="/Images/TransparentBubbleWithMoveCorner56px.png" />
</Grid.Background>
@Regenhardt
Regenhardt / ThinClient.json
Created July 31, 2017 11:32
Azure thin client
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"virtualMachineName": {
"type": "string"
},
@Regenhardt
Regenhardt / Fluent Cast
Created May 22, 2018 15:27 — forked from lisardggY/Fluent Cast
For casting an object as part of a Fluent expression without having to put annoying parentheses around casting expressions.
public static T As<T>(this object objectToCast) where T : class
{
return objectToCast as T;
}
public class MyWebClient
{
public async Task<string> DownloadString(string uri)
{
using (HttpClient client = new HttpClient())
{
using (HttpResponseMessage response = client.GetAsync(uri).Result)
{
using (HttpContent content = response.Content)
{
/// <summary>
/// Caches objects.
/// </summary>
public class Cache<T>
{
private List<T> cache;
/// <summary>
/// Initializes a new <see cref="Cache{T}"/>:
/// </summary>
public Cache()
public static class SecureStringExtensions
{
public static string GetSHA512(this SecureString input)
{
using (var sha512 = SHA512.Create())
{
byte[] password = Encoding.UTF8.GetBytes(ToNormalString(input));
byte[] hash = sha512.ComputeHash(password);
return Encoding.UTF8.GetString(hash);
}
#!/bin/sh
### BEGIN INIT INFO
# Provides: ts3
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: TS3-Server
# Description: Teamspeak 3 Server
### END INIT INFO
The element 'CodeSnippets' in namespace 'http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet' cannot contain text.
List of possible elements expected: 'CodeSnippet' in namespace 'http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet'