This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // using System; | |
| // using System.Diagnostics; | |
| // using System.Runtime.CompilerServices; | |
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | |
| unsafe static void BlockCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) | |
| { | |
| Debug.Assert(src != null); | |
| Debug.Assert(dst != null); | |
| Debug.Assert(srcOffset >= 0 && srcOffset < src.Length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ apk add sshfs | |
| $ modprobe fuse | |
| $ mkdir /mnt/server | |
| $ sshfs root@192.168.1.12:/ /mnt/server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| radio2_restart && radio5_restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include <vector> | |
| #ifdef THREAD_SAFE_EVENTS | |
| #include <shared_mutex> | |
| #define MUTEX std::shared_mutex rwmutex; | |
| #define RWLOCK rwmutex.lock(); | |
| #define RWUNLOCK rwmutex.unlock(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Precompiled headers basically improve build times by reducing the amount of code compiling each time a build | |
| command is invoked. | |
| This feature is available in Visual Studio for Windows C/C++ development | |
| via project "Properties" -> "C/C++" -> "Precompiled Headers", | |
| but this feature is missing for Linux C/C++ Development (Visual Studio) and | |
| requires a workaround since GCC/Clang support pch. | |
| The workaround: | |
| - Creating a "precompile.sh" bash script and appending the content above. | |
| - Set in your project's properties in "Properties" -> "Build Events" -> "WSL Pre-Build Event", the following: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| // LINKER_INCLUDE_UNUSED: Forces linker to keep unused functions that were declared elsewhere | |
| // LINKER_KEEP_UNUSED: Forces linker to keep unused functions that are delcared within the current file | |
| #define EXPORT extern "C" _declspec(dllexport) | |
| #if defined(LINKER_INCLUDE_UNUSED) | |
| #if defined(_WIN64) | |
| #define LINKER_KEEP(s) EXPORT __pragma(comment (linker, "/export:"#s)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include <thread> | |
| namespace std_ex { | |
| template <typename Callable, typename... Args> | |
| std::thread thread(Callable&& f, Args&& ... args) { | |
| return std::thread(f, args...); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public unsafe static void MarshalPtrToStructureArray<T>(IntPtr sPtr, ulong arrSize, ref T[] output) where T : unmanaged | |
| { | |
| fixed (T* dPtr = output) | |
| { | |
| ulong dataSize = arrSize * (uint)Marshal.SizeOf(typeof(T)); | |
| Unsafe.CopyBlock(dPtr, (void*)sPtr, (uint)dataSize); | |
| // Alternatively, .NET Framework >= 4.6 | |
| // ulong dataSize = arrSize * (uint)Marshal.SizeOf<T>(); | |
| // Buffer.MemoryCopy((void*)sPtr, dPtr, dataSize, dataSize); |