Skip to content

Instantly share code, notes, and snippets.

View 166MMX's full-sized avatar

Johannes Harth 166MMX

View GitHub Profile
@nacmartin
nacmartin / Progressbar.java
Created November 17, 2010 14:10
Java text console progressbar
import java.lang.Math.*;
public class Progressbar {
private int max;
private int current;
private String name;
private long start;
private long lastUpdate;
public Progressbar(int max, String name)
@timyates
timyates / hexdump.groovy
Last active December 30, 2015 00:19
Hexdump byte[] in Groovy via the metaClass
byte[].metaClass.hexdump { int idx, int len ->
println ''' +--------------------------------------------------+
| | 0 1 2 3 4 5 6 7 8 9 a b c d e f |
| +----------+--------------------------------------------------+------------------+'''.stripMargin()
delegate[ idx..<(idx+len) ].with { bfr ->
def bytes = bfr.collect { String.format( '%02x', it ) }
.collate( 8 )
.collate( 2 )
.collect { a, b -> ( a + [ '' ] + b ).join( ' ' ).padRight( 48, ' ' ) }
def ascii = bfr.collect { it > 0x1f && it < 0x7f ? (char)it : '.' }
#!/bin/sh
in_place() {
content="$1"
file="$2"
id="$3"
range="/^#${id} START\$/,/^#${id} END\$/"
[ -f "$file" ] && [ -n "$(tail -c 1 "$file")" ] && echo >>"$file"
{ rm -- "$file" && sed "${range}d" >"$file"; } <"$file" && sed -n "${range}p" >>"$file" <"$content"
}
in_place "$0" "$HOME/.profile" 'Jump marks .profile'
@roadsideseb
roadsideseb / xvfb-run.sh
Last active June 15, 2019 20:41 — forked from tyleramos/xvfb-run.sh
XVFB Run Bash script
#!/bin/sh
# $Id: xvfb-run 2027 2004-11-16 14:54:16Z branden $
# This script starts an instance of Xvfb, the "fake" X server, runs a command
# with that server available, and kills the X server when done. The return
# value of the command becomes the return value of this script, except in cases
# where this script encounters an error.
#
# If anyone is using this to build a Debian package, make sure the package
@Bayonetta
Bayonetta / gist:bf699390e49bbc5f64262eb9aab61254
Created August 30, 2017 06:39
line_history_version.xml
<plist version="1.0">
<dict>
<key>pings</key>
<array />
<key>jingleDocType</key>
<string>purchaseSuccess</string>
<key>jingleAction</key>
<string>purchaseProduct</string>
<key>status</key>
<integer>0</integer>
@MoriTanosuke
MoriTanosuke / CsvBean.java
Created June 23, 2011 18:58
Unmarshal CSV with Apache Camel and Bindy
package de.kopis.camel.model;
import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
import org.apache.camel.dataformat.bindy.annotation.DataField;
@CsvRecord(separator = ",")
public class CsvBean {
@DataField(pos = 1)
private String first;
@DataField(pos = 2)
@5263
5263 / decode_post_datamtrix.py
Created September 10, 2011 19:45
Decodes Informations from Deutsche Post Datamatrix Codes
#!/usr/bin/env python
import sys
import datetime
frankierart={
0x01:'Stampit 2003',
0x02:'0x02???',
0x03:'Frankit',
0x05:'Filiale',
0x07:'Frankierservice Infopost/Infobrief',
0x08:'Premiumadress',
@ngryman
ngryman / README.md
Last active January 16, 2023 14:07
intellij javascript live templates

intellij javascript live templates

Just a dump of handy live templates I use with IntelliJ. They should also work with WebStorm.

How to

  • Go to settings.
  • Search for live templates.
  • Under the javascript section you should be able to manage your templates.
@GreyCat
GreyCat / c-struct-to-ksy.rb
Created March 25, 2017 10:53
Convert C struct into Kaitai Struct spec (.ksy)
#!/usr/bin/env ruby
require 'yaml'
TYPE_TO_KSY = {
'uint8_t' => 'u1',
'uint16_t' => 'u2',
'uint32_t' => 'u4',
'uint64_t' => 'u8',
@erikvold
erikvold / gistUserScriptInstallLink.user.js
Created January 29, 2010 06:04
This userscript will add an 'Install' link to all userscript files (which end with .user.js by necessity).