Skip to content

Instantly share code, notes, and snippets.

# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@Lochlan
Lochlan / trigger-change-file-input
Created February 23, 2015 07:48
This is how you trigger a `change` event on `<input type="file">` with JavaScript — useful for testing!
// vanilla JS
var event = document.createEvent("UIEvents");
event.initUIEvent("change", true, true);
document.querySelector('input[type=file]').dispatchEvent(event);
// jQuery
$('input[type=file]').trigger('change');
@jesobreira
jesobreira / url-encode.c
Created January 22, 2019 21:21 — forked from sudar/url-encode.c
URL Encoding in C (urlencode / encodeURIComponent)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* urlencode(char* originalText)
{
// allocate memory for the worst possible case (all characters need to be encoded)
char *encodedText = (char *)malloc(sizeof(char)*strlen(originalText)*3+1);
@hwhw
hwhw / cc2538-and-openocd.md
Last active November 16, 2023 20:20
Flashing CC2538 using OpenOCD (&UART)

Flashing CC2538 using OpenOCD (&UART)

Problem description

CC2538 SoCs are Cortex-M4 based SoCs by Texas Instruments for 802.15.4 PAN networking, especially for Zigbee communication using their Zigbee Stack solution. It also is a solid foundation for hobbyist-grade solutions involving Zigbee communication, especially for running a self-implemented Zigbee coordinator (often called "Zigbee gateway" in commercial distribution of similar tech). Software-wise, this is usually done by running "ZNP" (Zigbee Network Processor) firmware on the SoC and using a separate controller/computer to act as the "ZAP" (Zigbee Application Processor). In a hobbyist setting, the former is usually a cheap module from china containing the chip, capacitors and an antenna or antenna connector, while the latter is e.g. a Raspberry Pi or an Intel NUC or whatever floats your boat. The API between both components is specified and so the software side on the ZAP does not need to bother with Zigbee communication states but can act on a