Skip to content

Instantly share code, notes, and snippets.

@fairlight1337
fairlight1337 / run_hotspot.bat
Created October 5, 2016 05:28
Batch script for starting a SoftAP under Windows 10
netsh wlan set hostednetwork mode=allow ssid=<YOUR_SSID> key=<YOUR_KEY>
netsh wlan start hostednetwork
@fairlight1337
fairlight1337 / ls-branches
Last active August 8, 2016 07:24
A script I put into my $PATH and use for quickly listing the currently selected branches of all subdirectories (rather than going through them one by one)
#!/bin/bash
MASTER="master"
for item in $(ls -1); do
if [ -d $item ]; then
cd $item
if [ -d .git ]; then
branch=`git rev-parse --abbrev-ref HEAD`
@fairlight1337
fairlight1337 / Synchronized.cpp
Last active August 14, 2019 16:34
Simple synchronization class for allowing the same thread to enter a function over and over again, but shutting out others while it is in use
#include <iostream>
#include <condition_variable>
#include <mutex>
#include <thread>
#include <string>
class Synchronizer {
private:
std::condition_variable m_cvCondition;
@fairlight1337
fairlight1337 / Conditional.cpp
Created April 24, 2016 21:21
Trying out `conditional_variable` in threads (C++)
#include <iostream>
#include <condition_variable>
#include <mutex>
#include <thread>
#include <string>
#include <chrono>
#include <vector>
int nWorkersActive;
@fairlight1337
fairlight1337 / catch_segv.cpp
Last active January 22, 2024 17:29
Catching SIGSEGV (Segmentation Faults) in C
// This code installs a custom signal handler for the SIGSEGV signal
// (segmentation fault) and then purposefully creates a segmentation
// fault. The custom handler `handler` is then entered, which now
// increases the instruction pointer by 1, skipping the current byte
// of the faulty instruction. This is done for as long as the faulty
// instruction is still active; in the below case, that's 2 bytes.
// Note: This is for 64 bit systems. If you prefer 32 bit, change
// `REG_RIP` to `REG_EIP`. I didn't bother putting an appropriate
// `#ifdef` here.
@fairlight1337
fairlight1337 / WekaToJSON.py
Created September 17, 2014 18:16
Convert Weka J48 decision tree output to structured JSON
## Copyright (c) 2014, Jan Winkler <winkler@cs.uni-bremen.de>
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
##
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
@fairlight1337
fairlight1337 / hsvrgb-cpp
Created June 2, 2014 07:39
Simple RGB/HSV conversion in C++
// Copyright (c) 2014, Jan Winkler <winkler@cs.uni-bremen.de>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
@fairlight1337
fairlight1337 / cpp-py
Last active August 14, 2019 16:35
Hello World program compilable (/runnable) as both .py and .c(pp). Makes use of the #define preprocessor directive of C/C++ to make Python code invisible to the C compiler while using multiline comments from Python (""") to make C(++)-code invisible to the Python interpreter. Both programs just output "Hello World from both!", while each program…
#// This comment is invisible to both, Python and C(++).
#/*
# This multiline comment is also invisible to both.
#*/
#include <stdio.h>
#define pass void printstring(char* x) { printf("%s", x); printf("\n"); }
pass