This tutorial uses the "Sample hapi.js REST API" project.
Take a look at: https://github.com/agendor/sample-hapi-rest-api/
##Topics
- Introduction
- Installing Node.js
- Installing MySQL
- Setting-up the project
// Generates a URL-friendly "slug" from a provided string. | |
// For example: "This Is Great!!!" transforms into "this-is-great" | |
function generateSlug (value) { | |
// 1) convert to lowercase | |
// 2) remove dashes and pluses | |
// 3) replace spaces with dashes | |
// 4) remove everything but alphanumeric characters and dashes | |
return value.toLowerCase().replace(/-+/g, '').replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, ''); | |
}; |
# www.fduran.com | |
MySQL Master-Slave Replication Notes | |
Master | |
/etc/mysql/my.cnf | |
server-id = 100 | |
log_bin = /var/log/mysql/mysql-bin.log | |
binlog-do-db = wpdb | |
binlog-ignore-db = mysql |
#Mounting the share is a 2 stage process: | |
# 1. Create a directory that will be the mount point | |
# 2. Mount the share to that directory | |
#Create the mount point: | |
mkdir share_name | |
#Mount the share: | |
mount_smbfs //username:[email protected]/share_name share_name/ |
This tutorial uses the "Sample hapi.js REST API" project.
Take a look at: https://github.com/agendor/sample-hapi-rest-api/
##Topics
class API::V1::BaseController < ApplicationController | |
skip_before_filter :verify_authenticity_token | |
before_filter :cors_preflight_check | |
after_filter :cors_set_access_control_headers | |
def cors_set_access_control_headers | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS' |
# Clear existing task so we can replace it rather than "add" to it. | |
Rake::Task["deploy:compile_assets"].clear | |
desc "Precompile assets locally and then rsync to web servers" | |
task :compile_assets do | |
# compile assets locally | |
run_locally do | |
with rails_env: fetch(:stage) do | |
execute :bundle, "exec rake assets:precompile" | |
end |
githooks
and save the commit-msg
file in there.The githook can then be installed by symlinking them to your .git/hooks dir.
Run these commands from the project root
$ ln -s ../../githooks/pre-commit .git/hooks/
$ ln -s ../../githooks/commit-msg .git/hooks/
When npm installs native node modules it uses node-gyp
to compile code. This is the seam node uses for targeting different operating systems, e.g. OS X
, linux
, Windows
etc.
By default node-gyp
compiles using one core and if you have more than one you probably want to utilize that power to speed up compile time. The way node-gyp
handles this is by using the JOBS
environment variable, which sets the jobs
variable here. This piece of code then checks the value of jobs
to determine how many cores to use.
Note that if the value of JOBS
is max
then all cores will be used. So lets try this on leveldown
. First lets check that JOBS
isn't set yet:
lms@ux301|01:34|~/src/leveldb-repos/leveldown (master) $ echo $JOBS
#!/usr/bin/env bash | |
# this removes every single docker container, image and volume on your system | |
# bash <(curl --silent --location https://gist.github.com/greyltc/361d6abb69d50090e62e/raw) | |
#FORCE="--force" | |
echo "Cleaning up all the docker things!" | |
echo "Containers..." | |
for c in $(docker container ls --all --quiet) | |
do |