Skip to content

Instantly share code, notes, and snippets.

View Manuel-S's full-sized avatar

Manuel Schweigert Manuel-S

  • Karlsruhe, Germany
View GitHub Profile
@Manuel-S
Manuel-S / install tex.ps1
Last active March 12, 2018 14:22
LaTex for Windows Setup Script
# Usage: Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/Manuel-S/6db8b12835a71d9baf146af2964ee1c8/raw/'))
#install chocolatey if it isn't here already
if ((Get-Command "choco.exe" -ErrorAction SilentlyContinue) -eq $null)
{
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
#install tex backend
cinst miktex -y
@Manuel-S
Manuel-S / ConsulService.cs
Created November 27, 2017 15:19
lightweight consul c# client library
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
namespace Consul
{
public partial class ConsulService : IDisposable
{
private string serviceId;
@Manuel-S
Manuel-S / knockout-utils.js
Created July 27, 2016 11:37
extended binding syntax and a few custom bindings
// adds a jquery plugin function to apply ko bindings to a jquery DOM set
$.fn.applyBindings = function (viewModel) {
return this.each(function () {
ko.applyBindings(viewModel, this);
});
}
$.fn.koClean = function () {
return this.each(function () {
@Manuel-S
Manuel-S / FlattenArray.cs
Last active May 31, 2016 11:42
Flattens an arbitrarily nested array
using System;
using System.Collections;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
//nested array source
var source = new object[]{new object[]{1, 2, new[]{3}}, 4};
@Manuel-S
Manuel-S / LinqExtensions.cs
Last active December 27, 2017 00:09
LINQ Extensions: WhereProperties, FullTextSearch, DistinctKey, Once, ReplaceMatchingSequence
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
public static partial class LinqExtensions
{
public static IEnumerable<T> WhereProperties<T, P>(this IEnumerable<T> query, Func<IEnumerable<P>, bool> pred)
=> query.Where(item =>
@Manuel-S
Manuel-S / content-control.js
Last active January 12, 2016 10:02
Aurelia custom element to put a DOM Element from the viewmodel to the view
import {bindable, noView, inject} from 'aurelia-framework';
/* USAGE
<content-control content.bind="domElement"></content-control>
*/
@noView
@inject(Element)
export class ContentControl{
@Manuel-S
Manuel-S / auto-complete.js
Created January 12, 2016 09:50
Aurelia custom element for auto completion using awesomeplete
import {bindable, inject, inlineView} from 'aurelia-framework';
import * as Awe from 'awesomplete'; //eslint-disable-line
/* USAGE:
<auto-complete
data.two-way="values"
selected.bind="selectedValue"
placeholder="Select a value"
label="Autocomplete">
</auto-complete>
@Manuel-S
Manuel-S / iTunes Sync.cs
Created December 15, 2015 08:56
Synchronize Folders with iTunes Playlists. Usage: sync.exe [parent-folder] [parent-playlist]. Defaults to your OneDrive/Music Folder.
//reference iTunesLib from COM
using iTunesLib;
using Microsoft.Win32;
using System;
using System.IO;
using System.Threading;
using System.Linq;
class Program
{
@Manuel-S
Manuel-S / delete-folder.bat
Last active December 11, 2015 11:27
Delete Folder Structures even when they have more than 255 characters
mkdir %temp%\removefolder
robocopy %temp%\removefolder %1 /MIR
rmdir %1
rmdir %temp%\removefolder
@Manuel-S
Manuel-S / Exceptionhandling.cs
Last active October 28, 2015 14:16
C# can do unicode...
try
{
DoStuff()
}
catch (ArgumentException 💩)
{
Console.WriteLine(💩.Message);
}
catch (Exception ಠ_ಠ)
{