Skip to content

Instantly share code, notes, and snippets.

@phortx
phortx / gist:4059848
Created November 12, 2012 15:02
Java Unicode German Umlaut Escape Sequences
Char Unicode
------------------------------
Ä, ä \u00c4, \u00e4
Ö, ö \u00d6, \u00f6
Ü, ü \u00dc, \u00fc
ß \u00df
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active May 8, 2024 05:28
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@tott
tott / ip_in_range.php
Created November 27, 2013 22:46
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@TSedlar
TSedlar / clippy.sh
Created August 19, 2014 01:30
Bash script for uploading screenshots to imgur or clipboard content to pastie
#!/bin/bash
function get_clipboard_content {
xclip -selection c -o
}
function upload_pastie {
local lang="plain_text"
local content=$(get_clipboard_content)
local private=1
@drorata
drorata / gist:146ce50807d16fd4a6aa
Last active May 23, 2024 02:48
Minimal Working example of Elasticsearch scrolling using Python client
# Initialize the scroll
page = es.search(
index = 'yourIndex',
doc_type = 'yourType',
scroll = '2m',
search_type = 'scan',
size = 1000,
body = {
# Your query's body
})
@gambrell
gambrell / logstash-remove-nulls.conf
Created March 19, 2015 13:47
Logstash filter to remove embedded NULL characters
# Logstash filter to remove embedded NULL characters
filter {
mutate {
gsub => [
# Replace all NULL characters empty string. Do this to the message field first which will apply to all fields instead of specifying individual fields.
"message", "[\u0000]", ""
]
}
@diasjorge
diasjorge / partman.cfg
Last active August 3, 2020 14:14
Partman example using lvm
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/device_remove_lvm_span boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-auto-lvm/new_vg_name string system
d-i partman-lvm/confirm boolean true
d-i partman/alignment string "optimal"
d-i partman-auto-lvm/guided_size string max
@TiZ-HugLife
TiZ-HugLife / conky-toggle
Created March 27, 2015 19:29
conky-toggle
#!/bin/bash
if [[ "$(cat /tmp/.conkystate)" = "above" ]]; then
STATE="below"
REMOVE="above"
else
STATE="above"
REMOVE="below"
fi
echo $STATE > /tmp/.conkystate
@manifestinteractive
manifestinteractive / sniff.txt
Last active November 23, 2023 02:16
A friendly formatter for curl requests to help with debugging.
\n
============= HOST: ==========\n
\n
local_ip: %{local_ip}\n
local_port: %{local_port}\n
remote_ip: %{remote_ip}\n
remote_port: %{remote_port}\n
\n
======= CONNECTION: ==========\n
\n
@Jikoo
Jikoo / Experience.java
Last active May 10, 2024 15:32
A utility for managing experience with Bukkit.
package com.github.jikoo.planarwrappers.util;
import org.bukkit.entity.Player;
/**
* A utility for managing player experience.
*/
public final class Experience {
/**