Skip to content

Instantly share code, notes, and snippets.

View Jeiwan's full-sized avatar
🛠️
Write code, delete code, repeat

Ivan Kuznetsov Jeiwan

🛠️
Write code, delete code, repeat
View GitHub Profile
@Jeiwan
Jeiwan / lightsail-docker.sh
Last active April 24, 2024 13:46 — forked from davidkryzaniak/lightsail-docker.sh
Auto-Install Docker and Docker Compose on AWS Lightsail
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
sudo apt-get install -y docker-engine
sudo curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo groupadd docker

Keybase proof

I hereby claim:

  • I am jeiwan on github.
  • I am jeiwan (https://keybase.io/jeiwan) on keybase.
  • I have a public key whose fingerprint is 9572 6E1E 203D 58CC E194 83C3 4931 B584 29A0 7886

To claim this, I am signing this object:

@Jeiwan
Jeiwan / ar_migrate.rb
Created February 9, 2016 05:06 — forked from icyleaf/ar_migrate.rb
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb
# Maps logical Rails types to MySQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default
@Jeiwan
Jeiwan / sprockets_manually.rb
Created January 11, 2016 10:19
Sprockets manually
require 'rubygems'
require 'bundler'
require 'pathname'
require 'logger'
require 'fileutils'
Bundler.require
ROOT = Pathname(File.dirname(__FILE__))
LOGGER = Logger.new(STDOUT)
@Jeiwan
Jeiwan / README.md
Created October 9, 2015 15:04 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default and default-ssl to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
require 'restclient'
# RestClient logs using << which isn't supported by the Rails logger,
# so wrap it up with a little proxy object.
RestClient.log =
Object.new.tap do |proxy|
def proxy.<<(message)
Rails.logger.info message
end
end
require 'rspec'
module Authenticable
def current_user
@current_user ||= 'Pedro'
end
def authenticate_with_token!
render json: { errors: "Not authenticated" },
status: :unauthorized unless user_signed_in?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
</head>
<body>
=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')
# paths
app_path = "/home/deployer/qna"
working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen
listen "/tmp/unicorn.qna.sock", :backlog => 64
# logging
stderr_path "log/unicorn.stderr.log"