Skip to content

Instantly share code, notes, and snippets.

View a-chernykh's full-sized avatar

Andrey Chernykh a-chernykh

View GitHub Profile
@a-chernykh
a-chernykh / avatar_uploader.rb
Created August 9, 2011 14:28
CarrierWave extension-aware remote file downloading
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def extension_white_list
model.skip_avatar_extension_check ? nil : %w(jpg jpeg gif png bmp)
end
end
@a-chernykh
a-chernykh / gist:3583565
Created September 1, 2012 19:06
Setup VPN server with WAN forwarding in 5 minutes
apt-get -y install pptpd dnsmasq
Add/uncomment the following line in /etc/sysctl.conf:
net.ipv4.ip_forward=1
Commit the changes by running as root:
sysctl -p
@a-chernykh
a-chernykh / carrierwave.rb
Created July 1, 2011 12:50
Change image quality with carrierwave and mini_magick
# put this in config/initializers/carrierwave.rb
module CarrierWave
module MiniMagick
def quality(percentage)
manipulate! do |img|
img.quality(percentage)
img = yield(img) if block_given?
img
end
end
@a-chernykh
a-chernykh / MY_Exceptions.php
Created April 3, 2012 13:54
CodeIgniter error notifications
<?php
class MY_Exceptions extends CI_Exceptions {
function My_Exceptions()
{
parent::CI_Exceptions();
}
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
@a-chernykh
a-chernykh / helm.sh
Created June 20, 2019 14:55
Poor man's helm
cat config/deploy/k8s/*.yml | envsubst | kubectl apply -f -
cat config/deploy/k8s/*.yml | envsubst | kubectl wait --for condition=available -f - --timeout 120s

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@a-chernykh
a-chernykh / default.rb
Created March 26, 2014 17:51
Install and compile TBB for android
default[:tbb][:version] = '4.2-20140122oss'
default[:tbb][:url] = 'https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb42_20140122oss_src.tgz'
default[:tbb][:sha] = 'f1bd8d983f93a10e340ba63f3a479632ddca1562a5242814dd82a378d3233b75'
@a-chernykh
a-chernykh / active_admin.en.yml
Created March 17, 2014 12:26
Add "not equals" option to ActiveAdmin string filter
en:
active_admin:
filters:
predicates:
not_eq: "Not equals"
@a-chernykh
a-chernykh / default.rb
Created July 20, 2012 12:19
Easy way to edit configuration file with Chef
add_line = "config statement"
bash "add_to_config" do
code <<-EOH
grep '#{add_line}' /etc/config || echo '#{add_line}' >> /etc/config
EOH
end
@a-chernykh
a-chernykh / search.feature
Created September 8, 2016 03:58
How to test a website blog post
Feature: Search
Scenario: Search for "apple"
Given I am on the front page
When I search for "apple"
Then I should see "apple.com"