This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You'll need activerecord-import gem installed in your app | |
class BackupService | |
def initialize(path: nil) | |
@path = path || Rails.root.join('tmp', "backup-#{Time.now.to_i}.sqlite") | |
end | |
def backup(*scopes) | |
with_db do | |
prepare |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"modelId": "000004q1vq", | |
"services": [ | |
{ | |
"actions": [ | |
], | |
"code": "", | |
"description": "", | |
"events": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'rails' | |
gem 'sqlite3', platform: 'ruby' | |
end | |
require 'active_record' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
gem "rails", github: "rails/rails" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# curl -s https://gist.githubusercontent.com/cristianbica/10347658/raw/setup_swap.rb | sudo ruby - multiplier [remove_current_swap] | |
# multiplier - when creating the swap will multiply the current RAM with the multiplier | |
# remove_current_swap - true to remove current swap in /swapfile (default false) | |
# Ex: curl -s https://gist.githubusercontent.com/cristianbica/10347658/raw/setup_swap.rb | sudo ruby - 2 | |
# Ex: curl -s https://gist.githubusercontent.com/cristianbica/10347658/raw/setup_swap.rb | sudo ruby - 2 true | |
if ARGV[1] and ARGV[1]=="true" | |
puts "Removing swap from swapfile as requested ..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dpkg -l x264 fdk-aac libvpx libaacplus ffmpeg 2>/dev/null >/dev/null && echo "Packages are already installed" && exit | |
#cleanup | |
cd | |
sudo rm -rf fdk-aac-0.1.0* ffmpeg* libaacplus-2.0.2* libvpx* x264* | |
sudo apt-get -y remove ffmpeg fdk-aac libaacplus x264 libav-tools libvpx-dev libx264-dev libvpx | |
sudo apt-get update | |
sudo apt-get -y install build-essential checkinstall git libfaac-dev libgpac-dev \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for 1G of swap run | |
# curl https://gist.githubusercontent.com/cristianbica/9594944/raw/add_swap.sh | bash -v -s 128M 8 | |
# it will build a swapfile of 1G (8 blocks of 128M) and make it swap | |
BLOCK_SIZE=$1 | |
BLOCKS_COUNT=$2 | |
dd if=/dev/zero of=/swapfile bs=$BLOCK_SIZE count=$BLOCKS_COUNT | |
sudo chown root:root /swapfile | |
sudo chmod 0600 /swapfile | |
mkswap /swapfile | |
swapon /swapfile |