Skip to content

Instantly share code, notes, and snippets.

@cibomahto
cibomahto / master_i2c.c
Created July 4, 2021 18:41
esp32 i2c with mutex
#include "master_i2c.h"
#include <driver/i2c.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#define ACK_CHECK_EN 0x1 //!< I2C master will check ack from slave
#define ACK_CHECK_DIS 0x0 //!< I2C master will not check ack from slave
static SemaphoreHandle_t i2c_semaphore = NULL;
@ericlaw1979
ericlaw1979 / TypeTheClipboard.vbs
Created February 18, 2021 16:46
Types the contents of the clipboard to the focused text area three seconds after invocation (useful for using sites/apps that block CTRL+V paste). Useful as a script launched from [SlickRun](https://bayden.com/slickrun)
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 3000
'Hackery to get the clipboard's contents
Set objHTML = CreateObject("htmlfile")
text = objHTML.ParentWindow.ClipboardData.GetData("text")
WshShell.SendKeys text
@minorsecond
minorsecond / CMakeLists.txt
Created September 8, 2020 15:56
CMakeLists for macOS App Bundle
cmake_minimum_required(VERSION 3.17)
project(foo)
set(CMAKE_CXX_STANDARD 20)
set(LIBPROC_SRC "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libproc.h")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
@nealfennimore
nealfennimore / wireguard.conf
Last active June 15, 2024 10:58
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@dmitrykustov
dmitrykustov / upgrade-postgres-9.4-to-9.6.md
Last active August 8, 2022 17:52 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.4 to 9.6 on Debian Jessie

To use the most modern version of Postgres software we need to add postgresql repository. Edit /etc/apt/sources.list or create /etc/apt/sources.list.d/pgdg.list and add there a line: deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main Then import the repository signing key, and update the package lists:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

Install a new version of PostgreSQL server.

Once the Debian upgrade finished, I used dpkg-query -l postgresql* to check which versions of postgres I have installed.

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@hvanhonacker
hvanhonacker / migrate_postgres_9.3_9.4_ubuntu_14.10.md
Last active May 13, 2023 06:22
Migration from postgresql 9.3 to 9.4

Upgrade from PostgreSQL 9.3 to 9.4 on Ubuntu 14.10

Install postgresql-9.4

$ sudo apt-get install postgresql-9.4

Then psql version should be 9.4.x

$ psql --version
@Ashton-W
Ashton-W / gfycat.js
Last active December 28, 2015 12:19
gfycat.com bookmarklet for Mobile Safari
javascript:location.href='http://gfycat.com/fetch/'+window.location.href
@jgeurts
jgeurts / statsd-graphite-install.sh
Last active January 28, 2017 20:23
Install statsd and graphite as a services on Ubuntu 13.10
sudo apt-get install --assume-yes python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install --assume-yes nodejs
sudo apt-get install --assume-yes git
# Install Graphite
sudo apt-get install python-dev ruby-dev bundler build-essential libpcre3-dev graphite-carbon graphite-web
cat >> /tmp/graphite-carbon << EOF
# Change to true, to enable carbon-cache on boot
@romannurik
romannurik / SwipeDismissListViewTouchListener.java
Last active May 1, 2021 10:16
**BETA** Android 4.0-style "Swipe to Dismiss" sample code
Moved to
https://github.com/romannurik/android-swipetodismiss