Skip to content

Instantly share code, notes, and snippets.

Avatar

Arthur Nisnevich ArthurN

View GitHub Profile
View Keybase.md

Keybase proof

I hereby claim:

  • I am arthurn on github.
  • I am arthurn (https://keybase.io/arthurn) on keybase.
  • I have a public key ASAMIYJVK2x339Jmc7L8QypS9XFOTA2qZbvqdJ7LkKakWQo

To claim this, I am signing this object:

@ArthurN
ArthurN / BootstrapMultiselect.vue
Created Jan 24, 2018
Vue wrapper for jquery bootstrap multiselect
View BootstrapMultiselect.vue
<template lang='slm'>
select.form-control multiple="multiple"
option v-for="option in selectOptions" :value='option.value' {{ option.label }}
</template>
<script>
export default {
name: 'bootstrap-multiselect',
props: {
selectOptions: {
@ArthurN
ArthurN / installation.sh
Last active Jul 2, 2020
From pow to puma-dev on macOS keeping .dev domains
View installation.sh
# Why:
# 1) Chrome 63 (Dec 8) breaks .dev domains by forcing HTTPS: https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/
# 2) Pow is at EOL, superceded by puma-dev (see http://pow.cx/manual, 6 Version History, 0.6.0, Dec 8 2017)
# Uninstall pow
curl get.pow.cx/uninstall.sh | sh
# If you use powder, you can remove it as well
gem uninstall powder
View chronic_date_property.rb
module ChronicDateProperty #:nodoc:
extend ActiveSupport::Concern
module ClassMethods
# Define a Reform property which coerces its input via the Chronic parser.
def chronic_date_property(*args)
options = args.extract_options!
field = args.first
property(field, options)
@ArthurN
ArthurN / kill-sidekiq.sh
Created Aug 24, 2015
Kill Duplicate Sidekiq processes
View kill-sidekiq.sh
#!/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 / gist:e980d723a6d63e9fc766
Created Nov 22, 2014
pdf-reader-get-fields.rb
View gist:e980d723a6d63e9fc766
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])
View gist:f16ad0e6958a0af73d39
# From http://breakthebit.org/post/77505127462/up-your-security-on-amazon-aws
{
"Statement": [
{
"Sid": "AllowPublicRead",
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:PutObject",
"s3:PutObjectAcl",
View gist:e13637dce27d15168d4b
# 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 Aug 26, 2014
Peak into what I18n namespaces are attempted by third party gems
View i18n.t
# 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
Getting Source of a Package on CentOS, Applying Patch, & Rebuilding
View gist:6ac227eb21e6f0627f18
# 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