SSH into Root
$ ssh [email protected]
Change Root Password
| # create table topics! | |
| create table topics ( | |
| id int primary key auto_increment, | |
| name varchar(256), | |
| parent_id int null, | |
| type smallint not null, | |
| foreign key (parent_id) references topics(id), | |
| index(type) | |
| ); |
| openssl genrsa -out CAroot.key 2048 | |
| openssl req -new -key CAroot.key -out CAroot.csr # CN should be different from the certificates below | |
| openssl req -x509 -days 1825 -key CAroot.key -in CAroot.csr -out CAroot.crt | |
| cat CAroot.crt CAroot.key > CAroot.pem | |
| openssl genrsa -out mongod.key 2048 | |
| openssl req -new -key mongod.key -out mongod.csr | |
| openssl x509 -req -days 1825 -in mongod.csr -CA CAroot.pem -CAkey CAroot.key -CAcreateserial -out mongod.crt | |
| cat mongod.crt mongod.key > mongod.pem |
| package main | |
| import ( | |
| "database/sql" | |
| "gopkg.in/gorp.v1" | |
| "log" | |
| "strconv" | |
| "github.com/gin-gonic/gin" | |
| _ "github.com/go-sql-driver/mysql" |
| # if you want to render flamegraphs | |
| gem "stackprof", require: false # required by flamegraph | |
| gem "flamegraph", require: false |
SSH into Root
$ ssh [email protected]
Change Root Password
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;| 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 |
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
| # 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 |