Skip to content

Instantly share code, notes, and snippets.

View mniak's full-sized avatar
🌵
Nothing is happening

Mniak mniak

🌵
Nothing is happening
View GitHub Profile
using System;
using System.Windows;
using System.Windows.Data;
namespace WpfConverters
{
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (!(value is bool))
@mniak
mniak / mvvm.snippet
Last active July 11, 2018 14:20
Collection of MVVM #snippet #wpf
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>ViewModel Property</Title>
<Author>Andre Guilherme</Author>
<Description>Creates a property that gets and sets the ViewModel (DataContext) of the object.</Description>
@mniak
mniak / HybridStream.cs
Last active July 11, 2018 14:25
#memory #stream that a temporary #file as it gets bigger
using System.IO;
namespace Mniak.IO
{
public class HybridStream : Stream
{
private const long DEFAULT_THRESHOLD = 1 * 1024 * 1024; // 1 MB
private object streamLock = new object();
private bool usingMemory;
@mniak
mniak / then-else.ts
Last active July 19, 2016 11:15
ThenElse for TypeScript - a kind of promise that does not throw an error when there is no catch
// https://gist.github.com/andregsilv/8e157583965b7af00d5ef975b9569cff
export class ThenElse<T> {
private done: boolean;
private value: any;
private failure: boolean;
private thenCallbacks = new Array<(value: T) => void>();
private elseCallbacks = new Array<(value: any) => void>();
constructor(task: (resolve: (value: T) => void, reject: (reason: any) => void) => void) {
@mniak
mniak / SingleRequestListener.cs
Last active October 3, 2018 15:03
#owin single #http request listener.
using Microsoft.Owin;
using Microsoft.Owin.Hosting;
using Owin;
using System;
using System.Threading.Tasks;
/* Used NuGet Packages
install-package Microsoft.Owin
install-package Microsoft.Owin.Host.HttpListener
install-package Microsoft.Owin.Hosting
@mniak
mniak / nlog.appdata.config
Last active July 11, 2018 14:14
My standard #nlog configs
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
<variable name="company_name" value="MyCompany" />
<variable name="outdir" value="${specialfolder:folder=LocalApplicationData}/${var:company_name}/Logs/${var:program_name:default=Undefined}" />
<variable name="layout" value="${longdate} | ${pad:padding=-15:${threadname:whenEmpty=${threadid}}} | ${pad:padding=-5:${level:uppercase=true}} | ${logger} | ${message}${onexception:inner= | ${exception:format=tostring}}"/>
<targets>
<target name="file_full" xsi:type="File"
layout="${var:layout}"
fileName="${var:outdir}/full.log"
archiveFileName="${var:outdir}/full.{#}.log"
@mniak
mniak / TypeKeys.csx
Last active July 11, 2018 14:13
SendKey scripts
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
public void TypeKeys(string text, bool trimNums=true) {
if (trimNums) {
text = Regex.Replace(text, "[^0-9]", "");
}
@mniak
mniak / .bash_profile
Last active September 18, 2023 12:18
My OS #config files
# FOR MACOSX: curl -o ~/.bash_profile https://gist.githubusercontent.com/mniak/31cea1e0e50809dbb4e5dd13d689644c/raw/.bash_profile -H 'Cache-Control: no-cache'
# FOR LINUX: curl -o ~/.bashrc https://gist.githubusercontent.com/mniak/31cea1e0e50809dbb4e5dd13d689644c/raw/.bash_profile -H 'Cache-Control: no-cache'
export PS1="\[\e[33m\]\W\[\e[m\] \\$\[$(tput sgr0)\] "
export CLICOLOR=1
export TERM=xterm-256color
export DOTNET_CLI_TELEMETRY_OPTOUT=1
if [ $(uname) == "Darwin" ]; then #OSX specific configuration
@mniak
mniak / glogg.ini
Last active September 18, 2023 12:11
Coloured #glogg filters
[FilterSet]
version=1
filters\size=13
filters\1\regexp=\\[Fatal\\]
filters\1\fore_colour=red
filters\1\back_colour=white
filters\2\regexp=\\| *[Ff][Aa][Tt][Aa][Ll] *\\|
filters\2\fore_colour=red
filters\2\back_colour=white
/*
* Requires jQuery
* (c) Copyright Andre Soares (mniak) 2011-2018. All rights reserved.
* Licensed under MIT license (https://opensource.org/licenses/MIT)
*/
(function($){
$.fn.noteRange = function(options) {
var defaults = {
whiteColor: 'white',
blackColor: 'black',