Skip to content

Instantly share code, notes, and snippets.

@CosminLazar
CosminLazar / mosquitto.service
Created Oct 19, 2018
Systemd service for Mosquitto
View mosquitto.service
[Unit]
Description=Mosquitto MQTT Broker daemon
ConditionPathExists=/etc/mosquitto/mosquitto.conf
After=network.target
Requires=network.target
[Service]
Type=forking
RemainAfterExit=no
StartLimitInterval=0
View DHT22ArduinoSample.cpp
#include <DHTSensor.h>
DHTSensor sensor(3);//Will be using pin3 for collecting the data
void loop()
{
DHTSensorMeasurement re = sensor.Read();
if (!re.HasError())
{
Serial.print("H: ");
Serial.print(re.Humidity());
Serial.print(" T: ");
View AutofacConstructorBug.cs
public interface IHaveDeferredEnumerable
{
IEnumerable<IHaveDeferredEnumerable> Get();
}
public class HasDeferredEnumerable : IHaveDeferredEnumerable
{
public IEnumerable<IHaveDeferredEnumerable> Get()
{
yield return null;
View ROCCAT_Talk.h
#pragma once
#define TALKFX_ZONE_AMBIENT 0x00
#define TALKFX_ZONE_EVENT 0x01
#define TALKFX_EFFECT_OFF 0x00
#define TALKFX_EFFECT_ON 0x01
#define TALKFX_EFFECT_BLINKING 0x02
#define TALKFX_EFFECT_BREATHING 0x03
#define TALKFX_EFFECT_HEARTBEAT 0x04
View InstallNuGetDebugTools.ps1
Install-Package NuGetDebugTools
Add-Debugger.ps1
Set-PSBreakpoint -Command init.ps1, install.ps1, uninstall.ps1
View ChangingBuildAction.ps1
$x86TalkFX = $project.ProjectItems.Item("CroccatTalkWrapper").ProjectItems.Item("win32-x86").ProjectItems.Item("talkfx-c.dll");
$x86TalkFX.Properties.Item("BuildAction").Value = [int]2;
@CosminLazar
CosminLazar / WrongInstall.ps1
Created Feb 21, 2015
How not to modify the project from Install.ps1
View WrongInstall.ps1
#This script edits the project file and marks the talkfx-c.dll files to always be copied to the output directory
param($installPath, $toolsPath, $package, $project)
# Load project XML.
$doc = New-Object System.Xml.XmlDocument
$doc.Load($project.FullName)
$namespace = 'http://schemas.microsoft.com/developer/msbuild/2003'
# Find the node containing the file. The tag "Content" may be replace by "None" depending of the case, check your .csproj file.
$talkFXDlls = Select-Xml "//msb:Project/msb:ItemGroup/msb:Content[contains(@Include, 'talkfx-c.dll')]" $doc -Namespace @{msb = $namespace}
@CosminLazar
CosminLazar / RavenDBExtensions.cs
Created May 19, 2014
Extension class adding FirstOrDefaultLazy to RavenDB
View RavenDBExtensions.cs
public static class RavenDBExtensions
{
public static Lazy<T> FirstOrDefaultLazy<T>(this IQueryable<T> query, Func<T, bool> predicate)
{
if (query == null) throw new ArgumentNullException("query");
if (predicate == null) throw new ArgumentNullException("predicate");
return query.Where(x => predicate(x)).FirstOrDefaultLazy();
}
View ExecutingOnANewThread.cs
private void ExecutingOnANewThread()
{
//both tasks defined bellow will be executed on a new background thread
var task = new Task(() => { }, TaskCreationOptions.LongRunning);
task.Start(TaskScheduler.Default);
//or
var task2 = Task.Factory.StartNew(() => { }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default);
}
You can’t perform that action at this time.