Skip to content

Instantly share code, notes, and snippets.

@1gor
1gor / nginx.conf
Created February 12, 2017 03:24 — forked from weapp/nginx.conf
Return common errors as json in Nginx
error_page 500 /500.html;
location /500.html{
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
}
error_page 502 /502.html;
location /502.html{
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
}
@1gor
1gor / nginx.conf
Created February 12, 2017 03:24 — forked from weapp/nginx.conf
Return common errors as json in Nginx
error_page 500 /500.html;
location /500.html{
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
}
error_page 502 /502.html;
location /502.html{
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
}
@1gor
1gor / gist:2141022ae246c5af7c359e2db6e39431
Created April 14, 2017 02:37 — forked from Hailong/gist:c705a490d6e1eb31f3402bb19286a16a
Set up Mautic dev environment quickly.
#!/bin/bash
# 1. Check out the latest code from https://github.com/mautic/mautic
# 2. Run 'composer install' in the root directory as described in the README file.
# 3. Run the following script to set the folder permissions correctly. NOTE: change the "my_linux_account" and "web_daemon_account" properly according your sever.
my_linux_account="root"
web_daemon_account="apache"
@1gor
1gor / rsync-incremental-backup.sh
Created April 21, 2017 23:05 — forked from morhekil/rsync-incremental-backup.sh
Shell script to handle incremental data backups with rsync. Optimised to handle large number of infrequently changing files, by using hard links to save on used disk space. For more details - http://localhost:4000/2014/01/12/automatic-backups-with-ruby-and-linux-shell-part-3/
#!/bin/bash
# Rsync based file backup script, with hard-linking enabled.
#
# Runtime options:
# -n - dry-run; do nothing, just display what is going to happen on a real run
# -v - verbose output; print out what is being backed up
#
# set to your rsync location
@1gor
1gor / capybara cheat sheet
Created July 18, 2017 00:42 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
LOCAL_IP="$(ifconfig eth0 | grep "inet " | awk -F'[: ]+' '{ print $4 }')" \
SELENIUM_URL=http://firefox-browser:4444 \
RAILS_ENV=test \
rspec spec/integrations/login_spec.rb
@1gor
1gor / auth.rb
Created July 30, 2017 04:49 — forked from badosu/auth.rb
Basic HTTP Auth with Roda
auth = Rack::Auth::Basic::Request.new(env)
unless auth.provided?
# env['warden'].custom_failure! # If you're using warden avoid intercepting 401
r.halt [401, {'Content-Type' => 'text/plain', 'Content-Length' => '0', 'WWW-Authenticate' => 'Basic realm="Restricted Area"'}, []]
end
unless auth.basic?
r.halt [400, {'Content-Type' => 'text/plain', 'Content-Length' => '0'}, []]
end
@1gor
1gor / resource.rb
Created September 17, 2017 11:44 — forked from jamiehodge/resource.rb
Server Side Events, Sequel and Postgres LISTEN/NOTIFY
require 'sequel'
DB ||= Sequel.connect ENV['DATABASE_URL']
class Resource < Sequel::Model
include Sequel.inflections
def after_save
db.notify channel
end
@1gor
1gor / _mdl_accordion.sass
Created October 12, 2017 06:51 — forked from fotinakis/_mdl_accordion.sass
(Material Design Light) MDL Accordion
// From @nickretallack - http://nickretallack.com/experiments/mdl/collapse/index.html
.mdl-accordion.mdl-accordion--opened
border-top: 1px solid #e0e0e0
border-bottom: 1px solid #e0e0e0
margin-top: -1px
.mdl-accordion.mdl-accordion--opened + .mdl-accordion.mdl-accordion--opened
border-top: none
margin-top: 0
@1gor
1gor / woocommerce-create-order.md
Created December 18, 2017 03:01 — forked from stormwild/woocommerce-create-order.md
WooCommerce Creating Order Programmatically

WooCommerce Creating Order Programmatically

WooCommerce Create Order

creating Woocommerce order with line_item programatically

// http://stackoverflow.com/questions/26581467/creating-woocommerce-order-with-line-item-programatically
$address = array(
            'first_name' => 'Fresher',