Skip to content

Instantly share code, notes, and snippets.

@fairlight1337
fairlight1337 / run_hotspot.bat
Created Oct 5, 2016
Batch script for starting a SoftAP under Windows 10
View run_hotspot.bat
netsh wlan set hostednetwork mode=allow ssid=<YOUR_SSID> key=<YOUR_KEY>
netsh wlan start hostednetwork
@fairlight1337
fairlight1337 / ls-branches
Last active Aug 8, 2016
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)
View ls-branches
#!/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 Aug 14, 2019
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
View Synchronized.cpp
#include <iostream>
#include <condition_variable>
#include <mutex>
#include <thread>
#include <string>
class Synchronizer {
private:
std::condition_variable m_cvCondition;
@fairlight1337
fairlight1337 / Conditional.cpp
Created Apr 24, 2016
Trying out `conditional_variable` in threads (C++)
View Conditional.cpp
#include <iostream>
#include <condition_variable>
#include <mutex>
#include <thread>
#include <string>
#include <chrono>
#include <vector>
int nWorkersActive;
@fairlight1337
fairlight1337 / catch_segv.cpp
Last active Oct 29, 2021
Catching SIGSEGV (Segmentation Faults) in C
View catch_segv.cpp
// 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 Sep 17, 2014
Convert Weka J48 decision tree output to structured JSON
View WekaToJSON.py
## 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 Jun 2, 2014
Simple RGB/HSV conversion in C++
View hsvrgb-cpp
// 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 Aug 14, 2019
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…
View cpp-py
#// 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