Skip to content

Instantly share code, notes, and snippets.

View tkouba's full-sized avatar

Tomas Kouba tkouba

  • Prague, Czech Republic
View GitHub Profile
@qwertie
qwertie / DateTimePicker.xaml
Last active June 5, 2023 18:31
C# DateTimePicker for WPF
<UserControl x:Class="DTPicker.DateTimePicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DTPicker"
xmlns:wpftc="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
mc:Ignorable="d"><!--Uses Calendar in WPFToolkit.dll,
see http://wpf.codeplex.com/releases/view/40535-->
<UserControl.Resources>
@chrisnicola
chrisnicola / MongoHelper.cs
Created December 22, 2011 20:33
Mongo C# extension to compare BsonDocument and BsonValue objects
public static bool SameAs(this BsonDocument source, BsonDocument other, params string[] ignoreFields)
{
var elements = source.Elements.Where(x => !ignoreFields.Contains(x.Name)).ToArray();
if (elements.Length == 0 && other.Elements.Where(x => !ignoreFields.Contains(x.Name)).Any()) return false;
foreach (var element in source.Elements)
{
if (ignoreFields.Contains(element.Name)) continue;
if (!other.Names.Contains(element.Name)) return false;
var value = element.Value;
var otherValue = other[element.Name];
@josheinstein
josheinstein / InstallClickOnceApp.cs
Created July 19, 2012 15:57
Install ClickOnce application programmatically (C#)
using System;
using System.Collections.Generic;
using System.Deployment.Application;
using System.Linq;
using System.Text;
using System.Threading;
namespace InstallClickOnceApp
{
@rudyryk
rudyryk / TextMeter.cs
Last active August 8, 2021 10:53
C# — Measure string size in Xamarin.Forms for iOS and Android platforms
//
// TextMeter.cs
// Created by Alexey Kinev on 11 Feb 2015.
//
// Licensed under The MIT License (MIT)
// http://opensource.org/licenses/MIT
//
// Copyright (c) 2015 Alexey Kinev <alexey.rudy@gmail.com>
//
// Usage example:
@eralston
eralston / .tfignore
Created February 26, 2015 19:00
Example ignore file for Team Foundation Server, excluding files from Bin, NuGet packages, etc
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
bin
obj
#include nuget executable
@brisingraerowing
brisingraerowing / CPOL.md
Created June 25, 2015 06:17
Codeproject Open License in Markdown (Converted with html2text)

The Code Project Open License (CPOL) 1.02

Preamble

This License governs Your use of the Work. This License is intended to allow developers to use the Source Code and Executable Files provided as part of the Work in any application in any form.

The main points subject to the terms of the License are:

@dieseltravis
dieseltravis / PS-BGInfo.ps1
Last active April 23, 2024 15:16
update wallpaper background image with powershell (like Sysinternals BGInfo)
# PS-BGInfo
# Powershell script that updates the background image with a random image from a folder and writes out system info text to it.
# run as a lower priority task
[System.Threading.Thread]::CurrentThread.Priority = 'BelowNormal'
# Configuration:
# Font Family name
$font="Input"
@gbaman
gbaman / HowToOTG.md
Last active May 16, 2024 20:10
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@gene-pavlovsky
gene-pavlovsky / notepad2-solarized.ini
Last active January 29, 2022 19:11
Solarized Dark and Light color schemes for Notepad2-mod
[Default Text]
FileNameExtensions=txt; text; wtx; log; asc; doc; diz; nfo
Default Style=font:Consolas; size:11; fore:#93a1a1; back:#002b36
Margins and Line Numbers=size:-1; fore:#657b83; back:#073642
Matching Braces=size:+1; bold; fore:#dc322f; back:#073642
Matching Braces Error=size:+1; underline; fore:#dc322f; back:#073642
Control Characters (Font)=size:-1
Indentation Guide (Color)=fore:#073642
Selected Text (Colors)=eolfilled; fore:#eee8d5; back:#586e75
Whitespace (Colors, Size 0-5)=fore:#d33682
@alexrainman
alexrainman / ITextMeter
Last active August 1, 2022 07:45
Calculate Xamarin.Forms label height by amount of text
namespace YourNamespace
{
public interface ITextMeter
{
double MeasureTextSize(string text, double width, double fontSize, string fontName = null);
}
}