Skip to content

Instantly share code, notes, and snippets.

@karronoli
karronoli / cpanfile
Last active October 11, 2015 16:13
Parse xn--zqsv6t8x5aypa (sample) by perl
requires 'WWW::Mechanize', '1.74';
requires 'HTML::TreeBuilder::XPath', '0.14';
requires 'HTML::Tidy', '1.56';
requires 'HTTP::Response::Encoding', '0.06';
@karronoli
karronoli / dub.json
Last active September 3, 2016 15:24
Parse xn--zqsv6t8x5aypa (sample)
{
"name": "eanswer",
"description": "A minimal D application.",
"dependencies": {
"kxml": ">=1.0.0",
"ironcache-d": "~>0.0.5"
}
}
@karronoli
karronoli / gist:113f93f1c6814c31826e
Last active August 29, 2015 14:24
Dump RedPen memory usage on Heroku.
heroku run "(sleep 30; curl -sS --data document=test localhost:8080/rest/document/validate >/dev/null; curl -sS localhost:8080/rest/config/redpens; java -version; ps ux; killall java)& `sed -e 's/web //' -e 's/\$PORT/8080/' < Procfile` 2>&1 1>/dev/null | grep -v :INFO:"
@karronoli
karronoli / PKGBUILD
Last active May 12, 2016 13:39
systemd service files for RedPen.
pkgname=redpen-git
_pkgname=$(echo $pkgname | cut -d- -f1)
pkgver=1.5.5_a5db96
pkgrel=1
pkgdesc='A document checker. RedPen is a proofreading tool to help writers or programmers.'
url="http://redpen.cc/"
arch=('any')
license=('Apache')
depends=('java-runtime>=8')
makedepends=('git' 'maven')
@karronoli
karronoli / redpan_ja.bat
Last active December 6, 2015 09:56
RedPen interface for proofreading paragraph.
@echo off
chcp 65001 >NUL
set JAVA_OPTS=-XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dfile.encoding=UTF-8
cmd /c %USERPROFILE%\Downloads\redpen-cli-1.2\bin\redpen.bat ^
-c %USERPROFILE%\Downloads\redpen-cli-1.2\conf\redpen-conf-ja.xml %* 2>&1 ^
| findstr /V /R "^$" | findstr /V /C:"[INFO ]"
if ERRORLEVEL 1 (
exit /b 0
) else (
exit /b 1
@karronoli
karronoli / dummy.sh
Created May 26, 2015 15:30
Copy except invalid UTF-8 string line.
perl -MEncode -nle 'next unless eval {decode_utf8($_, Encode::LEAVE_SRC | Encode::FB_CROAK)}; print $_' <.histfile >/tmp/.histfile
@karronoli
karronoli / input.json
Last active August 29, 2015 14:19
generate JSON Schema from existing JSON file.
{
"str": "A",
"int": 1,
"float": 1.1,
"obj": {"a": true, "b": false, "c": null, "d": {"e": 2}},
"obj2": {},
"arr": [3, 4],
"arr2": [[1, 2], [3, 4], [5, 6]],
"arr3": [{"A": 1}, {"B": 2}],
"arr4": [[1], [2, 3]],
@karronoli
karronoli / myzipr.ps1
Last active August 29, 2015 14:18
emulate "zip temp.zip -r %TEMP%\hoge"
# emulate "zip temp.zip -r %TEMP%\hoge", require .net4.5
Add-Type -AssemblyName System.IO.Compression
# https://msdn.microsoft.com/en-us/library/system.io.compression.ziparchivemode(v=vs.110).aspx
# ZipArchiveMode Enumeration (System.IO.Compression)
# "the entire archive is held in memory."
$zip = New-Object -TypeName System.IO.Compression.ZipArchive `
-ArgumentList ([System.IO.File]::Create(
(Join-Path -Path $env:TEMP -ChildPath "temp.zip"))
), ([System.IO.Compression.ZipArchiveMode]::Update)
@karronoli
karronoli / capture-ie.ps1
Last active January 16, 2020 19:11
Capture IE screenshot by PowerShell.
<#
.SYNOPSIS
Capture WebPage & Save.
.DESCRIPTION
1. Move into the directory that contains capture-ie.ps1
2. Read config.json
3. Retrieve resouces
4. Start IE for capture page
5. Save to PNG file
@karronoli
karronoli / discard-GREP_OPTIONS.el
Created March 8, 2015 17:09
Re: Bug 1176547 - emacs grep warns "GREP_OPTIONS is deprecated" https://bugzilla.redhat.com/show_bug.cgi?id=1176547
(advice-add
'setenv :around
(lambda (f &rest args)
"discard GREP_OPTIONS on grep"
(let ((VARIABLE (first args)))
(unless (string= VARIABLE "GREP_OPTIONS")
(apply f args)))))