SSH into Root
$ ssh root@123.123.123.123
Change Root Password
SSH into Root
$ ssh root@123.123.123.123
Change Root Password
#!/usr/bin/env ruby | |
require 'yaml' | |
# If this was a branch checkout | |
if ARGV[2] == '1' | |
def dump(database_name, branch_name) | |
print "Saving state of #{database_name} on '#{branch_name}' branch..." | |
if system(%[pg_dump -c -f "#{@dump_folder}/#{database_name}-#{branch_name}" #{database_name}]) |
#!/bin/bash | |
i=0 | |
files=() | |
# sort spec files by number of examples for better balancing | |
for file in $(find ./spec -name "*_spec.rb" -print0 | xargs -0 grep -e "^ *it" -c | sort -t: -k2,2rn | awk -F":" '{ print $1 }') | |
do | |
if [ $(($i % $CIRCLE_NODE_TOTAL)) -eq $CIRCLE_NODE_INDEX ] | |
then | |
files+=" $file" |
package main | |
import ( | |
"database/sql" | |
"gopkg.in/gorp.v1" | |
"log" | |
"strconv" | |
"github.com/gin-gonic/gin" | |
_ "github.com/go-sql-driver/mysql" |
upstream puma { | |
server unix:///var/www/app/shared/tmp/sockets/puma.sock fail_timeout=0; | |
} | |
server { | |
listen 80 default deferred; | |
server_name example.com; | |
rewrite ^/(.+) https://example.com/$1 permanent; | |
} |
#Timecop is fun, but you don't need a whole gem for that. Just use | |
#Time.stub(:now), e.g. | |
describe "time" do | |
before do | |
@fake_time = Time.now | |
Time.stub(:now) { @fake_time } | |
end | |
it "is equal" do | |
Time.now.should == Time.now # now it passes |
guard 'rspec', :version => 2 do | |
watch(%r{^spec/.+_spec\.rb$}) | |
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | |
watch('spec/spec_helper.rb') { "spec" } | |
# Rails example | |
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | |
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } | |
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } | |
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } |
# Drop this into /spec/support/matchers | |
# Usage: result.should be_url | |
# Passes if result is a valid url, returns error "expected result to be url" if not. | |
# Matcher to see if a string is a URL or not. | |
RSpec::Matchers.define :be_url do |expected| | |
# The match method, returns true if valie, false if not. | |
match do |actual| | |
# Use the URI library to parse the string, returning false if this fails. | |
URI.parse(actual) rescue false |
If you see this error when cron job runs a ruby script:
'require': cannot load such file ...
And you are using bundler e.g. require 'bundler/setup'
. It's probably because the directory where cron runs the script is not correct, resulting in bundler fails to load gems.
Simply changed the directory to fix it, i.e.
* * * * * /usr/local/bin/ruby -C /home/example/scripts example_script.rb >>/home/example/log/cron.log 2>&1
Here's all you have to do to add clustering to your node.js application.
cluster.js
, and run cluster.js
instead of server.js
(or /bin/www, or whatever it's called for your project)server.js
filevar cluster = require('cluster');
if (cluster.isMaster) {
// Count the machine's CPUs
var cpuCount = require('os').cpus().length;