Skip to content

Instantly share code, notes, and snippets.

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
@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:
@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 / 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 / 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 / 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 / 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 / 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 / install_elixir.md
Created December 3, 2017 14:01 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

@snzip
snzip / setproxy
Created December 20, 2017 11:54 — forked from beradrian/setproxy
Set proxy for npm and git
# set a proxy
set HTTP_PROXY=
set HTTPS_PROXY=%HTTP_PROXY%
npm config set proxy %HTTP_PROXY%
npm config set https.proxy %HTTPS_PROXY%
npm config set https-proxy %HTTPS_PROXY%
git config --global http.proxy %HTTP_PROXY%
git config --global https.proxy %HTTPS_PROXY%
# unset proxy