Skip to content

Instantly share code, notes, and snippets.

View ogxd's full-sized avatar
👋

Olivier Giniaux ogxd

👋
View GitHub Profile
@jjeffery
jjeffery / ComWithoutRegistering.cs
Created January 6, 2012 02:25
COM without registering
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace ComWithoutRegisteringExample
{
internal static class ComHelper
{
private delegate int DllGetClassObject(ref Guid clsid, ref Guid iid, [Out, MarshalAs(UnmanagedType.Interface)] out IClassFactory classFactory);
@benbalter
benbalter / gist.md
Last active April 21, 2024 15:50
Example of how to embed a Gist on GitHub Pages using Jekyll.

Here's an example of how to embed a Gist on GitHub Pages:

{% gist 5555251 %}

All you need to do is copy and paste the Gist's ID from the URL (here 5555251), and add it to a gist tag surrounded by {% and %}.

@AngryAnt
AngryAnt / TerriblyHackyLog.cs
Created August 7, 2013 18:04
Abusing reflection and the internal Unity player build error function to get stacktrace-less error logs. Not recommended for anything sane.
using UnityEngine;
using System.Reflection;
public class TerriblyHackyLog : MonoBehaviour
{
void Start ()
{
Log ("Aaaaarrrrgh!");
}
@gszauer
gszauer / Brainfuck.cs
Created October 11, 2014 02:43
Simple 100 line C# brainfuck interpreter
using System;
namespace Brainfuck {
class MainClass {
public static void Main (string[] args) {
Console.WriteLine ("Enter Command Buffer: ");
string commandBuffer = Console.ReadLine ();
int[] memory = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int memoryPointer = 0;
using System;
using System.Diagnostics;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Security;
namespace TestPerf
{
public class Benchmark
{
@maxattack
maxattack / QuaternionUtil.cs
Last active April 5, 2024 01:50
Some Helper Methods for Quaternions in Unity3D
using UnityEngine;
/*
Copyright 2016 Max Kaufmann (max.kaufmann@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
@jyore
jyore / MacBookNetworkAliveOnSleep.md
Last active July 22, 2024 19:15
Keep Your MacBook Network Connections Alive As It Sleeps!

MacBookNetworkAliveOnSleep

As someone that regularly has multiple SSH/VPN sessions open, it can be a huge inconvience to lose all the connections when I lock my screen to get up to go to a meeting, lunch, etc. This is especially true for those connections that require two factor authentication. So, how can I tell my MacBook to keep those connections alive, even though my screen is locked?

Well, turns out that it is pretty simple. All that is needed is to run the following command.

cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources
sudo ./airport en0 prefs DisconnectOnLogout=NO
On OSX Yosemite and above, in a terminal window:
1. Switch to the root user.
$ sudo su -
2. Create a Dummynet pipe that represents a slow, unreliable network:
# dnctl pipe 1 config bw 10Kbit/s delay 300 plr 0.1 noerror
@mustafaturan
mustafaturan / network-tweak.md
Last active June 16, 2024 21:58
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'