Skip to content

Instantly share code, notes, and snippets.

View ArthurN's full-sized avatar

Arthur Nisnevich ArthurN

View GitHub Profile
@ArthurN
ArthurN / gist:e13637dce27d15168d4b
Last active August 29, 2015 14:07
pcos-test.sh
# Extract PDF field names and positions using pCOS:
./pcos --extended field "FT fullname Rect[0] Rect[1] Rect[2] Rect[3]" fw9.pdf
# CSV format, also output pagesize as the first line:
./pcos --extended pagesize "width height" --extended field "FT fullname V Rect[0] Rect[1] Rect[2] Rect[3]" --format "(VAL,)\n" --replace missing "" test.pdf
@ArthurN
ArthurN / i18n.t
Created August 26, 2014 22:48
Peak into what I18n namespaces are attempted by third party gems
# This monkeypatch logs any calls to I18n#t. This is especially useful to "peaking" into what namespaces are expected
# for third party gems, e.g. simple_form or reform.
I18n.module_eval do
class << self
def translate_with_puts(*args)
Rails.logger.debug "#{args}"
old_translate(*args)
end
alias :old_translate :translate
alias :translate :translate_with_puts
@ArthurN
ArthurN / gist:6ac227eb21e6f0627f18
Created May 29, 2014 23:02
Getting Source of a Package on CentOS, Applying Patch, & Rebuilding
# http://blog.foppiano.org/2007/12/11/installing-source-package-with-yum/
# http://wiki.centos.org/HowTos/RebuildSRPM
cd /tmp
sudo yumdownloader --source zbar
sudo yum-builddep zbar-blah-blah.rpm
rpm -ivh packagename-version.src.rpm
cd ~/rpmbuild
copy patch to SOURCES
Stacktrace (most recent call first):
premailer/rails/css_loaders/network_loader.rb:17:in `uri_for_url'
::Rails.configuration.action_controller.asset_host.split(%r{:?//})
premailer/rails/css_loaders/network_loader.rb:8:in `load'
uri = uri_for_url(url)
premailer/rails/css_helper.rb:33:in `block in load_css'
css = strategy.load(url)
premailer/rails/css_helper.rb:32:in `each'
STRATEGIES.each do |strategy|
#!/bin/sh
# http://vm-192-168-11-21.shengyun.grandcloud.cn/topics/2437
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
@ArthurN
ArthurN / pdf.js.google.closure.sh
Created February 2, 2014 03:06
Compile pdf.js using Google Closure API
curl -v -d code_url=http://mozilla.github.io/pdf.js/build/pdf.js -d compilation_level=SIMPLE_OPTIMIZATIONS -d output_info=errors -d output_format=text -d language=ECMASCRIPT5 http://closure-compiler.appspot.com/compile
curl -v -d code_url=http://mozilla.github.io/pdf.js/build/pdf.js -d compilation_level=SIMPLE_OPTIMIZATIONS -d output_info=compiled_code -d output_format=text -d language=ECMASCRIPT5 http://closure-compiler.appspot.com/compile > pdf.min.js
curl -v -d code_url=http://mozilla.github.io/pdf.js/build/pdf.worker.js -d compilation_level=SIMPLE_OPTIMIZATIONS -d output_info=compiled_code -d output_format=text -d language=ECMASCRIPT5 http://closure-compiler.appspot.com/compile > pdf.worker.min.js
curl -v -d code_url=http://mozilla.github.io/pdf.js/web/viewer.js -d compilation_level=SIMPLE_OPTIMIZATIONS -d output_info=compiled_code -d output_format=text -d language=ECMASCRIPT5 http://closure-compiler.appspot.com/compile > viewer.min.js
curl -v -d code_url=http://mozilla.github.io/pdf.js/web/l10n.js -d com
@ArthurN
ArthurN / i18n.rb
Created December 2, 2013 01:07
Monkey-patch Rails I18n.translate to see what keys ActiveModel is trying to use.
#initializers/i18n.rb
I18n.module_eval do
class << self
def translate_with_puts(*args)
Rails.logger.debug "#{args}"
old_translate(*args)
end
alias :old_translate :translate
alias :translate :translate_with_puts
end
@ArthurN
ArthurN / email.html
Created September 27, 2012 18:24
fatstax email templates
<html>
<head>
<meta name="format-detection" content="telephone=no" />
<style>
h1 {
font-size:14pt;
}
h2 {
font-size:12pt;
@ArthurN
ArthurN / gitconfig
Created May 19, 2012 22:20
Git Aliases
[alias]
st = status
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
co = checkout
amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend
@ArthurN
ArthurN / assign_sids.js
Created December 15, 2011 04:57
MongoDB error doing update shell/collection.js:200 (9001 socket exception?)
var startTime = (new Date()).getTime();
var total = db.items.count({_sid: { $exists: false } });
diff = ((new Date()).getTime() - startTime) / 1000.0;
print(diff + "s to count items without _sid");
print(total + " items need to be updated");
var done = 0;
db.items.find({_sid: { $exists: false } }).forEach(function (item) {
if (item.topic_ids != null && item.topic_ids.length > 0) {
item._sid = item.topic_ids[0];