Skip to content

Instantly share code, notes, and snippets.

View courtarro's full-sized avatar

Ethan Trewhitt courtarro

View GitHub Profile
@oneamtu
oneamtu / gtest.cmake
Created September 16, 2012 20:38
How to add google test as an downloadable external project
########################### GTEST
# Enable ExternalProject CMake module
INCLUDE(ExternalProject)
# Set default ExternalProject root directory
SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/third_party)
# Add gtest
# http://stackoverflow.com/questions/9689183/cmake-googletest
ExternalProject_Add(
@4ndrej
4ndrej / SSLPoke.java
Last active January 3, 2024 09:50
Test of java SSL / keystore / cert setup. Check the comment #1 for howto.
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import javax.net.ssl.SSLServerSocketFactory;
/*
* Source from Christopher Schultz
* @see http://markmail.org/message/zn4namfhypyxum23
*/
public class SSLInfo
@leahcim
leahcim / 25_pre-os-prober
Created March 3, 2014 19:13
In Ubuntu, /etc/grub.d/30_os-prober overrides grub menu style and timeout defined by the user in /etc/default/grub. Here is a workaround to save the menu style and timeout values before os-prober changes them, and to restore them afterwards. The two files need to be placed under /etc/grub.d and made executable. Finally, "sudo update-grub" should…
#! /bin/sh
set -e
# Save the $timeout and $timeout_style values set by /etc/grub.d/00_header
# before /etc/grub.d/30_os-prober messes them up.
cat << EOF
set timeout_bak=\${timeout}
set timeout_style_bak=\${timeout_style}
EOF
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@abstrask
abstrask / 00-button
Last active November 13, 2023 06:32 — forked from jefferyto/00-button
Scripts for OpenWrt on TP-Link TL-MR3020 to change network configs using 3-position sliding switch. Configuration changes by UCI/LuCI overwrites the symbolic links used by original scripts. This version copies the scripts instead of using symbolic links. Added script attached to WPS button, to commit the updated config to the current config (3g,…
# based on
# https://dev.openwrt.org/browser/trunk/target/linux/atheros/base-files/etc/hotplug.d/button/00-button
# https://forum.openwrt.org/viewtopic.php?pid=172110#p172110
. /lib/functions.sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
do_button () {
local button
@eliangcs
eliangcs / tornado_subprocess.py
Last active January 7, 2020 08:48
A minimal web server that runs shell commands, powered by Tornado and its Subprocess module
"""
A minimal web server that runs shell commands, powered by Tornado and its
Subprocess module. It does non-blocking IO and streams the response.
To start the server:
$ python tornado_subprocess.py
To send a shell command using httpie:
@hnyman
hnyman / 01_leds
Last active March 3, 2018 03:06
ath10k WIFI LEDs for ipq806x/R7800
--- a/target/linux/ipq806x/base-files/etc/board.d/01_leds
+++ b/target/linux/ipq806x/base-files/etc/board.d/01_leds
@@ -50,6 +50,15 @@ zyxel,nbg6817)
;;
esac
+case "$board" in
+netgear,r7800)
+ ucidef_set_led_wlan "wlan2g" "WLAN 2G" "ath10k-phy1" "phy1tpt"
+ ucidef_set_led_wlan "wlan5g" "WLAN 5G" "ath10k-phy0" "phy0tpt"
import numpy as np
def los_to_earth(position, pointing):
"""Find the intersection of a pointing vector with the Earth
Finds the intersection of a pointing vector u and starting point s with the WGS-84 geoid
Args:
position (np.array): length 3 array defining the starting point location(s) in meters
# /usr/bin/env python
#
# Author: Red5d
#
# Description: Extract and run OCR on subtitles from a PGS-format .sup file.
#
# Example Usage: python sup2srt.py bd_subtitles.sup bd_subtitles.srt
#
# Dependencies:
# - pytesseract