Skip to content

Instantly share code, notes, and snippets.

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@bogdanRada
bogdanRada / installation.sh
Created September 23, 2020 09:47 — forked from mikhailov/installation.sh
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@bogdanRada
bogdanRada / yt.php
Created September 11, 2020 08:12 — forked from lhuxman-lhux/yt.php
youtube download
<?php
if (file_exists('sig1.php')) {
unlink('sig1.php');
}
function quality($itag) {
switch ($itag) {
case "17":
return "144P";
break;
case "278":
@bogdanRada
bogdanRada / #drag-drop.py
Created September 4, 2020 12:32 — forked from florentbr/#drag-drop.py
Selenium - HTML5 drag and drop
from selenium import webdriver
import time
# JavaScript: HTML5 Drag and drop script
# param1 (WebElement): Source element to drag
# param2 (WebElement): Optional - target element for the drop
# param3 (int): Optional - Drop offset x relative to the target if any or source element
# param4 (int): Optional - Drop offset y relative to the target if any or source element
# param4 (int): Optional - Delay in milliseconds (default = 1ms) for dragging and dropping
# param5 (string): Optional - Key pressed (alt or ctrl or shilf)
@bogdanRada
bogdanRada / Vagrantfile
Created August 27, 2020 09:46 — forked from helloIAmPau/Vagrantfile
Vagrant file deploying a redis server
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
$INSTALL_REDIS = <<SCRIPT
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y redis-server
@bogdanRada
bogdanRada / sed command
Created August 27, 2020 09:26 — forked from donnykurnia/sed command
patch /etc/ImageMagick/policy.xml to allow read and write PDF file
sudo sed -e 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read|write" pattern="PDF" \/>\n\ \ <policy domain="coder" rights="read|write" pattern="LABEL" \/>/' -i /etc/ImageMagick/policy.xml
module RetryableTyphoeus
require 'typhoeus'
include Typhoeus
DEFAULT_RETRIES = 1
class Request < Typhoeus::Request
def original_on_complete=(proc)
@original_on_complete = proc
#! /usr/bin/env ruby
require 'rspec'
require 'forwardable'
# This is a cleaner implementation of Forwardable. It does not use string evaluation,
# nor does it have any rescues in it. This code grew out of a discussion at RubiABQ
# http://www.meetup.com/Rubyists-in-Albuquerque/events/225108828/
module MyForwardable
@bogdanRada
bogdanRada / Fix redis server startup warnings, redis tuning performance on Ubuntu 16.04.md
Created April 17, 2020 09:19
Fix redis server startup warnings, redis tuning performance on Ubuntu 16.04
  • Maximum Open Files
You requested maxclients of 10000 requiring at least 10032 max file descriptors.
Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
@bogdanRada
bogdanRada / my.cnf
Created April 17, 2020 09:14
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated January 2020 ~
#
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#