Skip to content

Instantly share code, notes, and snippets.

@snzip
snzip / install-libsodium.sh
Created December 3, 2017 13:33 — forked from jonathanpmartins/install-libsodium.sh
Install Libsodium on Ubuntu 14.04.3 LTS Trusty
#!/bin/bash
sudo add-apt-repository ppa:chris-lea/libsodium;
sudo echo "deb http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list;
sudo echo "deb-src http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list;
sudo apt-get update && sudo apt-get install libsodium-dev;
@snzip
snzip / server.py
Created November 28, 2017 07:09 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@snzip
snzip / dummy-web-server.py
Created November 28, 2017 07:00 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
@snzip
snzip / git-export-changes-between-two-commits.md
Created November 14, 2017 03:19 — forked from mrkpatchaa/git-export-changes-between-two-commits.md
Git command to export only changed files between two commits

Use case : Imagine we have just created a project with composer create-project awesone-project (currently V0.2). 2 weeks later, there is a new release (V0.3). How to update your project ? Since composer update only updates the project dependencies, it is not what we are looking for. Composer doesn't know about awesome-project since it's not in our composer.json.

After trying many git solutions, I've come to this :

git archive --output=changes.zip HEAD $(git diff --name-only SHA1 SHA2 --diff-filter=ACMRTUXB)

This command will check for changes between the two commits and ignore deleted files.

@snzip
snzip / Dockerfile
Created September 9, 2017 13:04 — forked from nginx-gists/Dockerfile
NGINX Plus for the IoT: Load Balancing MQTT
# Pull base image. The official docker openjdk-8 image is used here.
FROM java:8-jdk
# Copy HiveMQ to container
COPY hivemq.zip /tmp/
#Install wget and unzip, then download and install HiveMQ.
RUN \
apt-get install -y wget unzip &&\
unzip /tmp/hivemq.zip -d /opt/ &&\
@snzip
snzip / POSTGRESQL HSTORE errors
Created August 24, 2017 13:59
POSTGRESQL HSTORE errors
1) could not open extension control file "/usr/share/postgresql/9.3/extension/hstore.control"
```
PG::UndefinedFile: ERROR: could not open extension control file "/usr/share/postgresql/9.3/extension/hstore.control": No such file or directory
```
FIX:
```
sudo apt-get install postgresql-contrib
```
and then run 'cook' command again
@snzip
snzip / checkClassVersion.sh
Created June 21, 2017 01:52
Check java class version
You're looking for this on the command line (for a class called MyClass):
On Unix/Linux:
javap -verbose MyClass | grep "major"
On Windows:
javap -verbose MyClass | findstr "major"
You want the major version from the results. Here are some example values:
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StripTagAttribute {
public static void main(String[] args) {
String text = "%3Ctable%20class%3D%22pivot_table%22%3E%3Ctbody%3E%3Ctr%3E%3Cth%20colspan%3D%224%22%3E62964-pivot%3C%2Fth%3E%3C%2Ftr%3E%3Ctr%3E%3Cth%20class%3D%22h1%22%20style%3D%22cursor%3A%20move%3B%22%3E%3Cdiv%3EA%3C%2Fdiv%3E%3C%2Fth%3E%3Cth%20class%3D%22h1%22%20style%3D%22cursor%3A%20move%3B%22%3E%3Cdiv%3EB%3C%2Fdiv%3E%3C%2Fth%3E%3Cth%20class%3D%22h1%22%20colspan%3D%222%22%20style%3D%22cursor%3A%20pointer%3B%22%3EID%3C%2Fth%3E%3C%2Ftr%3E%3Ctr%3E%3Cth%20class%3D%22h2%22%20rowspan%3D%221%22%3E1234567%3C%2Fth%3E%3Cth%20class%3D%22h2%22%20rowspan%3D%221%22%3E2.25%3C%2Fth%3E%3Ctd%20class%3D%22odd%20portlet-alignment-number%22%20title%3D%22A%3A1234567%2C%20B%3A2.25%22%20x%3Anum%3D%221%22%3E%3Cspan%20class%3D%22pivot_cell_font%22%3E1%3C%2Fspan%3E%3C%2Ftd%3E%3C%2Ftr%3E%3Ctr%3E%3Ctd%20colspan%3D%224%22%20align%3D%22center