Skip to content

Instantly share code, notes, and snippets.

View aspyct's full-sized avatar

Antoine d'Otreppe aspyct

View GitHub Profile
@aspyct
aspyct / wpa_supplicant.conf
Created September 17, 2018 13:10
Connect to a WPA2 Enterprise network with wpa_supplicant with this .conf file. I used this to connect to my university's wireless network.
# Connect to a WPA2 Enterprise network with wpa_supplicant with this .conf file.
# I used this to connect to my university's wireless network on Arch linux.
# Here's the command I used:
#
# wpa_supplicant -i wlan0 -c ./wpa_supplicant.conf
#
network={
ssid="YOUR_SSID"
scan_ssid=1
@aspyct
aspyct / signal.c
Last active February 19, 2024 11:24
Unix signal handling example in C, SIGINT, SIGALRM, SIGHUP...
/**
* More info?
* a.dotreppe@aspyct.org
* http://aspyct.org
*
* Hope it helps :)
*/
#include <stdio.h>
#include <stdlib.h>
@aspyct
aspyct / AndroidManifest.xml
Created May 4, 2013 10:02
Android: switch wifi on/off
<!-- Add these permissions to your android manifest -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
@aspyct
aspyct / sort.rb
Last active October 29, 2023 03:08
Ruby implementation of quicksort, mergesort and binary search
# Sample implementation of quicksort and mergesort in ruby
# Both algorithm sort in O(n * lg(n)) time
# Quicksort works inplace, where mergesort works in a new array
def quicksort(array, from=0, to=nil)
if to == nil
# Sort the whole array, by default
to = array.count - 1
end
@aspyct
aspyct / zfs.sh
Last active July 28, 2023 21:37
ZFS Essentials
# Create a ZFS pool (i.e. choose disks that are part of the storage)
# In this case, it's a two-disk mirror
# Make sure to use /dev/disk/by-id/* for a stable pool
sudo zpool create <pool_name> mirror /dev/disk/by-id/<disk1> /dev/disk/by-id/<disk2>
sudo zfs create <pool_name>/<dataset_name>
# Check status
sudo zpool status
@aspyct
aspyct / RBTree.java
Created July 17, 2012 13:22
Left Leaning Red/Black Tree implemented in Java
package org.aspyct.going;
import java.util.Iterator;
import java.util.Stack;
/**
* This is an implementation of the Left Leaning Red/Black Tree as
* described in the course from the University of Princeton.
*
* This code contains a lot of assertions (assert ;).
@aspyct
aspyct / fr-dvorak-bepo-aspyct.keylayout
Created November 17, 2017 09:51
My custom bepo-based keylayout on OSX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!-- French Dvorak Layout -->
<!-- http://www.clavier-dvorak.org/ -->
<!-- version 0.6.5 -->
<keyboard group="126" id="6542" name="Aspyct French Dvorak" maxout="5">
<!--
This layout is designed for ISO and ANSI keyboards. The extra
key on an ISO keyboard (next to the left Shift) is optional,
characters on it are also accessible through other keys.
@aspyct
aspyct / common.h
Created July 15, 2012 22:00
Unix semaphore with the C programming language, tested under Debian
#ifndef _COMMON_H_
#define _COMMON_H_
#define SEM_KEY_FILE ("sem.key")
#endif /* _COMMON_H_ */
@aspyct
aspyct / display-double.cpp
Created July 28, 2012 21:31
A small program to display binary representation of double numbers
/*
* File: display-double.cpp
* Author: aspyct
*
* Can be compiled to a binaly that displays the binary value of double numbers.
* Usage : ./a.out <number1> ... <number n>
* Example: ./a.out 1.0 2.5
*
* Created on July 28, 2012, 11:03 PM
*/
@aspyct
aspyct / setup.sh
Last active May 2, 2020 11:20
Quick ubuntu18.04 server python workstation setup
#!/bin/sh
byobu-enable
sudo apt install -y vim vim-addon-manager vim-python-jedi vim-ctrlp ranger ripgrep
vim-addons install ctrlp python-jedi
echo "set nu et nowrap ts=4 sw=4 ai" > ~/.vimrc