Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# SPDX-License-Identifier: MIT
## Copyright (C) 2009 Przemyslaw Pawelczyk <przemoc@gmail.com>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
#
# Lockable script boilerplate
@jboner
jboner / latency.txt
Last active July 26, 2024 04:31
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@xingkaixin
xingkaixin / pysftp.py
Last active December 17, 2020 12:22
Python pexpect sftp sample
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pexpect import *
#import pexpect
import sys
import os
def initFile(*filenames):
@jeffeb3
jeffeb3 / slack_utils.py
Created September 29, 2016 21:48
Post to slack from a MicroPython (esp 8266, version 1.8.4)
def slack_it(msg):
''' Send a message to a predefined slack channel.'''
import urequests
# Get an "incoming-webhook" URL from your slack account. @see https://api.slack.com/incoming-webhooks
URL='https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
headers = {'content-type': 'application/json'}
data = '{"text":"%s"}' % msg
@martinbuberl
martinbuberl / git-import-repository.md
Last active June 20, 2024 10:42
Import existing Git repository into another

Import existing Git repository into another

Folder structure before (2 separate repositories):

XXX
 |- .git
 |- (project files)
YYY
 |- .git
@jgamblin
jgamblin / commonssids.txt
Created November 28, 2016 02:00
5000 most of common SSID names from https://wigle.net/stats#ssidstats
ssid
xfinitywifi
linksys
<no ssid>
BTWiFi-with-FON
NETGEAR
Ziggo
dlink
BTWifi-X
default
@skirdey
skirdey / pubsub_iot.py
Last active June 21, 2024 04:54
Connecting to AWS IoT MQTT topic using Python and Paho MQTT client
import paho.mqtt.client as paho
import os
import socket
import ssl
from time import sleep
from random import uniform
import json
import logging
logging.basicConfig(level=logging.INFO)
@uchidama
uchidama / pillow_with_opencv_findContours.ipynb
Last active January 13, 2024 15:57
Pillow to Opencv to find Contours, and back to Pillow Image.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
@manuelbl
manuelbl / README.md
Created August 3, 2019 09:12
ESP32 as Bluetooth Keyboard

ESP32 as Bluetooth Keyboard

With its built-in Bluetooth capabilities, the ESP32 can act as a Bluetooth keyboard. The below code is a minimal example of how to achieve it. It will generate the key strokes for a message whenever a button attached to the ESP32 is pressed.

For the example setup, a momentary button should be connected to pin 2 and to ground. Pin 2 will be configured as an input with pull-up.

In order to receive the message, add the ESP32 as a Bluetooth keyboard of your computer or mobile phone:

  1. Go to your computers/phones settings
  2. Ensure Bluetooth is turned on