Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrey Chernykh andreychernih

View GitHub Profile
@andreychernih
andreychernih / gist:3583565
Created Sep 1, 2012
Setup VPN server with WAN forwarding in 5 minutes
View gist:3583565
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
@andreychernih
andreychernih / MY_Exceptions.php
Created Apr 3, 2012
CodeIgniter error notifications
View MY_Exceptions.php
<?php
class MY_Exceptions extends CI_Exceptions {
function My_Exceptions()
{
parent::CI_Exceptions();
}
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
View helm.sh
cat config/deploy/k8s/*.yml | envsubst | kubectl apply -f -
cat config/deploy/k8s/*.yml | envsubst | kubectl wait --for condition=available -f - --timeout 120s
View self-signed-certificate-with-custom-ca.md

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
@andreychernih
andreychernih / default.rb
Created Mar 26, 2014
Install and compile TBB for android
View default.rb
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'
@andreychernih
andreychernih / active_admin.en.yml
Created Mar 17, 2014
Add "not equals" option to ActiveAdmin string filter
View active_admin.en.yml
en:
active_admin:
filters:
predicates:
not_eq: "Not equals"
@andreychernih
andreychernih / carrierwave.rb
Created Jul 1, 2011
Change image quality with carrierwave and mini_magick
View carrierwave.rb
# 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
@andreychernih
andreychernih / default.rb
Created Jul 20, 2012
Easy way to edit configuration file with Chef
View default.rb
add_line = "config statement"
bash "add_to_config" do
code <<-EOH
grep '#{add_line}' /etc/config || echo '#{add_line}' >> /etc/config
EOH
end
@andreychernih
andreychernih / search.feature
Created Sep 8, 2016
How to test a website blog post
View search.feature
Feature: Search
Scenario: Search for "apple"
Given I am on the front page
When I search for "apple"
Then I should see "apple.com"
@andreychernih
andreychernih / Dockerfile
Created Aug 29, 2016
docker osxfs slowness workaround
View Dockerfile
ENV APP_USER app
ENV BUNDLE_APP_CONFIG /usr/local/bundle
ADD Gemfile $DIR
ADD Gemfile.lock $DIR
# Force bundler to install all gems to system location (/usr/local/bundle) so that when you run `rake` command
# all files are loaded from docker image instead of mounted volume
RUN bundle install --deployment --path $BUNDLE_APP_CONFIG
RUN chown -R $APP_USER $BUNDLE_APP_CONFIG
You can’t perform that action at this time.