Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"io"
"os"
)
var path = "/Users/novalagung/Documents/temp/test.txt"
@ChuckJHardy
ChuckJHardy / digital_ocean_setup.md
Last active August 27, 2024 04:03
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions
@vigram
vigram / sidekiq_tasks.rake
Created December 11, 2014 12:09
Rake task to restart Sidekiq process
# Usage: bundle exec rake sidekiq:restart RAILS_ENV=<environment name>
namespace :sidekiq do
sidekiq_pid_file = Rails.root+'tmp/pids/sidekiq.pid'
desc "Sidekiq stop"
task :stop do
puts "#### Trying to stop Sidekiq Now !!! ####"
if File.exist?(sidekiq_pid_file)
puts "Stopping sidekiq now #PID-#{File.readlines(sidekiq_pid_file).first}..."
#!/bin/sh
remove_dangling() {
echo "Removing dangling images ..."
docker rmi $(docker images -f dangling=true -q)
}
remove_stopped_containers() {
echo "Removing stopped containers ..."
docker rm $(docker ps -qa)
@grafikchaos
grafikchaos / Add SSH Keys.md
Last active October 21, 2018 17:00
Quickly add SSH Key to server
$ cat ~/.ssh/id_rsa.pub | ssh USER@HOST "mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys; chmod 700 ~/.ssh; chmod 600 ~/.ssh/authorized_keys"
@bsa7
bsa7 / Gemfile
Last active December 14, 2017 07:44
Puma autostart with server (Puma 2.11.2, NGINX 1.4.6, Ubuntu Server 15.04 x64)
source 'https://rubygems.org'
gem 'puma'
gem 'rails'
...
@justinweiss
justinweiss / filterable.rb
Last active January 30, 2025 13:06
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
BEFORE:
sam@ubuntu discourse % rm -fr tmp/cache
sam@ubuntu discourse % rm -fr public/assets
sam@ubuntu discourse % time RAILS_ENV=production bin/rake assets:precompile
58.55s user 1.79s system 100% cpu 1:00.02 total
AFTER:
@kzaitsev
kzaitsev / carrierwave.rb
Created January 15, 2014 19:44
Carrierwave + Selectel
CarrierWave.configure do |config|
if Rails.env.development? || Rails.env.test?
config.storage = :file
else
config.storage = :fog
config.fog_credentials = {
:provider => 'OpenStack',
:openstack_auth_url => 'https://auth.selcdn.ru/v1.0',
:openstack_username => Rails.application.secrets.openstack_username,
:openstack_api_key => Rails.application.secrets.openstack_api_key
@pauloricardomg
pauloricardomg / cors.nginxconf
Last active November 25, 2024 15:33
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {