Skip to content

Instantly share code, notes, and snippets.

View ArthurN's full-sized avatar

Arthur Nisnevich ArthurN

View GitHub Profile
@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
#!/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
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|
@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
@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: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 / gist:f16ad0e6958a0af73d39
Created November 10, 2014 21:08
AWS permissions
# From http://breakthebit.org/post/77505127462/up-your-security-on-amazon-aws
{
"Statement": [
{
"Sid": "AllowPublicRead",
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:PutObject",
"s3:PutObjectAcl",
@ArthurN
ArthurN / gist:e980d723a6d63e9fc766
Created November 22, 2014 01:21
pdf-reader-get-fields.rb
def get_fields
# We have to use #send because AFAIK, PDF::Reader does not expose the root object anywhere
acroform = @reader.send(:root)[:AcroForm]
# PDF::Reader encapsulates each piece of PDF data in #objects. The field_refs are really references to
# these objects. We iterate through and de-reference the actual object, creating a AcroField based on its
# data
field_refs = @reader.objects[acroform][:Fields] unless acroform.nil?
fields = field_refs.map do |field_ref|
AcroField.new(@reader.objects[field_ref])
@ArthurN
ArthurN / kill-sidekiq.sh
Created August 24, 2015 18:51
Kill Duplicate Sidekiq processes
#!/bin/bash
if [ $(pgrep -f sidekiq | wc -l) -gt 1 ]; then
kill $(pgrep -f sidekiq | grep -v $(pgrep -of sidekiq) | sort -n | uniq | awk '{printf $1" "}');
fi
@ArthurN
ArthurN / generate_password_hash.sh
Created June 22, 2011 02:44
Useful CentOS Commands
echo "password"|openssl passwd -1 -stdin