Skip to content

Instantly share code, notes, and snippets.

View joemaidman's full-sized avatar

Joe Maidman joemaidman

View GitHub Profile
@joemaidman
joemaidman / example.ts
Last active October 6, 2021 16:32
Type issue
// using TS V3.7.5
type ClassType<T> = new () => T;
class DefaultClass {}
class RedClass {}
@joemaidman
joemaidman / cloudSettings
Last active January 19, 2018 14:03
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-01-19T14:03:34.798Z","extensionVersion":"v2.8.7"}
@joemaidman
joemaidman / systemTrayMin
Created March 4, 2016 15:38
Minimse c# window to systemtray
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();
ni.Icon = new System.Drawing.Icon("Main.ico");
ni.Visible = true;
@joemaidman
joemaidman / bubble
Created February 29, 2016 20:33
WPF bubble up visual tree to allow scroll over control with own scrollviewer
controlName.PreviewMouseWheel += PreviewMouseWheel;
private new void PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (!e.Handled)
{
e.Handled = true;
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
eventArg.RoutedEvent = UIElement.MouseWheelEvent;
eventArg.Source = sender;
@joemaidman
joemaidman / c#part
Created February 29, 2016 20:28
WPF datagrid tooltip for hidden text
public class TrimmedTextBlockVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null) return Visibility.Collapsed;
FrameworkElement textBlock = (FrameworkElement)value;
textBlock.Measure(new System.Windows.Size(Double.PositiveInfinity, Double.PositiveInfinity));
@joemaidman
joemaidman / randomnumber.js
Created February 3, 2016 15:40
Random number 0 - 1
var x = Math.floor(Math.random() * (1 - 0 + 1)) + 0;
@joemaidman
joemaidman / sortfuncs.js
Created September 7, 2015 12:09
Javascript sort functions
//Sort values ascending
function compareByValueAsc(a, b) {
if (a.value < b.value)
return -1;
if (a.value > b.value)
return 1;
return 0;
}
//Sort values descending
@joemaidman
joemaidman / geoloc.js
Last active September 7, 2015 12:11
Javascript/HTML5 Geolocation
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
@joemaidman
joemaidman / round.js
Last active September 7, 2015 12:07
Decimal rounding in javascript
//Round a decimal
function round(value, decimals) {
return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
}
@joemaidman
joemaidman / resp.css
Last active September 7, 2015 12:11
Bootstrap 3 responsive navbar fix
@media(max-width:992px){
.nav>li>a {
padding-left: 10px;
padding-right:10px
}
}