Skip to content

Instantly share code, notes, and snippets.

View adis-io's full-sized avatar

Adis Osmonov adis-io

View GitHub Profile
@adis-io
adis-io / database_state_loader.rb
Created June 10, 2022 16:32 — forked from keithpitt/database_state_loader.rb
Note that this code only works with PostgreSQL, but it wouldn’t be too hard to adapt our approach for other relational databases.
# Add to `spec/support/database_state_loader.rb`
class DatabaseStateLoader
class EnvironmentError < RuntimeError; end
def self.load(path)
new(path).load
end
def initialize(path)
@adis-io
adis-io / gist:022588f1a989bf2dfa23f5aa08decd34
Created June 10, 2022 11:30 — forked from 13k/gist:3086739
Capybara in Rails Console
# rails console test
# # or
# RAILS_ENV=test rails console
require 'capybara/dsl'
Capybara.app = app.instance_variable_get("@app")
cap = Object.new.instance_eval { extend Capybara::DSL; self }
# cap.visit '/'
# cap.page.find 'h1'
@adis-io
adis-io / Dockerfile
Created May 13, 2022 21:20 — forked from pdonorio/Dockerfile
A template for best practices in writing a docker image
#######################
## BUILD BASE
# Small image
FROM alpine:3.5
# or
FROM ubuntu:16.04
# LTS
@adis-io
adis-io / upgrade_to_mysql57.sh
Last active April 5, 2019 11:35 — forked from bufordtaylor/upgrade_to_mysql57.sh
Upgrading from MySQL 5.6 to 5.7 on OS X
mysql.server stop # kill the process if it fails
brew uninstall mysql56
brew update
brew install mysql@5.7
brew link mysql@5.7 --force
mysql.server stop
brew services start mysql # don't run via tmux
mysql_upgrade -u root --force
brew services restart mysql # don't run via tmux
cd ~/Code/17hats/17hats
@adis-io
adis-io / config.ru
Created January 25, 2017 06:10 — forked from Epictetus/config.ru
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
require "rails"
# Let's load only action controller. If you want
# to use active record, just require it as well.
require "action_controller/railtie"
class MyApp < Rails::Application
@adis-io
adis-io / sendmail
Last active August 29, 2015 14:12 — forked from ScreamingDev/sendmail
#!/usr/bin/php
<?php
$input = file_get_contents('php://stdin');
preg_match('|^To: (.*)|', $input, $matches);
$filename = tempnam('/var/log/mail', date('ymd-his-') . $matches[1] . '.');
file_put_contents($filename, $input);
// originally by Camden Ross. Thanks
/* bypass wordpress are you sure you want to logout screen when logging out of an already logged out account. */
function smart_logout() {
if (!is_user_logged_in()) {
$smart_redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '/';
wp_safe_redirect( $smart_redirect_to );
exit();
} else {
check_admin_referer('log-out');
@adis-io
adis-io / 0_reuse_code.js
Created August 15, 2014 11:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console