Skip to content

Instantly share code, notes, and snippets.

@wpsteak
wpsteak / index.js
Created December 28, 2020 07:53
index.js
const buffer = require('buffer');
const crypto = require('crypto');
const aes256gcm = (key, iv) => {
const ALGO = 'aes-256-gcm';
const encrypt = (str) => {
const cipher = crypto.createCipheriv(ALGO, key, iv);
let enc = cipher.update(str, 'utf8', 'hex');
@wpsteak
wpsteak / nginxproxy.md
Created February 28, 2019 18:17 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@wpsteak
wpsteak / AGPS.md
Created October 4, 2017 04:35 — forked from veproza/AGPS.md
Getting u-blox MAX-7C GPS to work with Assisted A-GPS

Getting u-blox MAX-7C GPS to work with Assisted A-GPS

So you got your u-blox GPS and wired it up only to look at it struggling to get a valid fix? Under less than ideal conditions, it can take a better part of half an hour. That's because unlike your smartphone GPS, it doesn't have the luxury of having downloaded all the auxiliary navigation data (almanacs and the lot) out-of-band, via fast mobile connection. Instead it relies on the satellite's signal itself, which is being transmitted to you at meager 50 bits per second (I'm not missing "kilo" there, it's three orders of magnitude slower than your 2G GPRS connection).

Luckily, the u-blox receivers are fitted with what the company calls "AssistNow" capability and it does exactly the same thing your iPhone does - feeds the GPS with pre-downloaded almanacs, speeding up the acquisition process to mere seconds.

In principle, the process looks easy enough - we just need to download the data, and then push them to the receiver. Sadly, the AssistNow documentat

@wpsteak
wpsteak / gist:1bf9ddb02008d752d760d87ca6c032e7
Created September 20, 2017 05:25 — forked from maxim75/gist:1000135
GPX parsing with JavaScript
<!DOCTYPE html>
<html>
<head>
<style>
#map_canvas
{
width: 400px;
height: 400px;
}
</style>
@wpsteak
wpsteak / gist:705d21958db14bf96bda6820779e4f22
Created December 18, 2016 11:54
/traverse the PWNode in inorder
#import <Foundation/Foundation.h>
@interface PWNode : NSObject <NSCopying>
typedef void (^PWNodeEnumerateBlock)(NSString *value);
@property (nonatomic, copy) NSString *value;
@property (nonatomic, strong) PWNode *leftNode;
@property (nonatomic, strong) PWNode *rightNode;
@wpsteak
wpsteak / gist:b45a4bec6a0c06002246
Created January 24, 2016 01:44
ESP 12 Flash update
ESP Tool
https://github.com/themadinventor/esptool
ESP-12 update to SDK v0.9.5 and AT v0.21.0.0 - noobs tutorial
http://blog.3mdeb.com/2015/01/25/esp-12-upgrade-to-esp-iot-sdk-v0-dot-9-5-using-esp-open-sdk-toolchain/
@wpsteak
wpsteak / stuns
Last active August 29, 2015 14:21 — forked from zziuni/stuns
# source : http://code.google.com/p/natvpn/source/browse/trunk/stun_server_list
# A list of available STUN server.
stun.l.google.com:19302
stun1.l.google.com:19302
stun2.l.google.com:19302
stun3.l.google.com:19302
stun4.l.google.com:19302
stun01.sipphone.com
stun.ekiga.net
@wpsteak
wpsteak / gist:1ac808896833b57d5faa
Last active August 29, 2015 14:19
raspberry pi connect bluetooth keyboard
sudo apt-get install bluez python-gobject
sudo apt-get install bluetooth bluez-utils blueman
sudo apt-get install —reinstall aptdaemon
sudo vim /usr/bin/bluez-simple-agent
(replace ‘KeyboardDisplay’ with ‘DisplayYesNo’)
sudo vim /etc/bluetooth/input.conf
(time out => 0)
@wpsteak
wpsteak / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/bin/sh
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
}
function has_compatibility() {