Skip to content

Instantly share code, notes, and snippets.

@embix
embix / qtconcurrentspike
Created September 28, 2011 22:59
QtConcurrent::run spike solution
#include <QList>
#include <QtAlgorithms>
#include <QDebug>
#include <QtConcurrentRun>
QList<int> sort(QList<int> unsorted, int chunkId){
qDebug() << "starting to sort chunk " << chunkId;
qSort(unsorted);
qDebug() << "finished to sort chunk " << chunkId;
return unsorted;
@embix
embix / LaTexEnvironment2CommandParameter
Created May 15, 2012 19:15
simplify an environment to a simple command allowing the use of special/shorter aliases within
\documentclass[a4paper,DIV=calc,ngerman]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\begin{document}
\newcommand{\aufz}[1]{
\makeatletter
aptitude install -y git curl python-dev python-pip redis-server ruby1.9.1-full rubygems1.9.1
aptitude install -y mysql-server libmysqlclient-dev
adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/git git
adduser --disabled-login --gecos 'gitlab system' gitlab
usermod -a -G git gitlab
su - gitlab
ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
aptitude install gitolite
cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
su - git
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NLog.Common;
using NLog.Targets;
using NLog.Config;
namespace ConsoleApplication1
@embix
embix / gist:5745130ba9b93c7b0200
Created July 7, 2015 12:23
CheckForDotNet45, patched to make it work on windows server core
using Microsoft.Win32;
using System;
using System.Diagnostics;
// originally from https://github.com/shanselman/SmallestDotNet/tree/master/CheckForDotNet45
// patched to work even on windows server core
namespace CheckForDotNet45
{
internal class Program
{
//public static class MyExtensions
//{
// // Write custom extension methods here. They will be available to all queries.
// public static IEnumerable<String> ReadLines(this FileInfo file)
// {
// if (null == file) throw new ArgumentNullException(nameof(file));
// return File.ReadLines(file.FullName, Encoding.UTF8);
// }
//}
@embix
embix / FizzBuzz.fs
Last active November 10, 2015 11:37
type integerString = {i:int; s:string}
let FizzThrough //: integerString -> integerString =
input =
if(input.i%3=0)
then {i=input.i;s="Fizz"}
else {i=input.i;s=input.s}
let BuzzThrough input =
if(input.i%5=0)
Enumerable.Range(1, 100)
.Select(i => new { i, s = ""})
.Select(si => si.i%3==0? new { si.i, s = "Fizz"} : si)
.Select(si => si.i%5==0? new { si.i, s = si.s+"Buzz"} : si)
.Select(si => si.s.Length>0?new { si.i, s = si.s+Environment.NewLine} : si)
.Select(si=>si.s).Aggregate((a,b)=>a+b)
C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\fsc.exe
-o:obj\Debug\FSInfoVersion.exe
-g
--debug:full
--noframework
--define:DEBUG
--define:TRACE
--doc:bin\Debug\FSInfoVersion.XML
--optimize-
--tailcalls-
using System.Management;
// reference System.Management.dll
void Main()
{
using (var control = new USBControl())
{
Console.ReadLine();//block - depends on usage in a Windows (NT) Service, WinForms/Console/Xaml-App, library
}
}