Skip to content

Instantly share code, notes, and snippets.

@kmassada
kmassada / phantomTest.js
Created October 28, 2015 10:17
Take screenshot using phantomJS (Headless Browser)
var page = require('webpage').create();
page.open('http://net.tutsplus.com', function () {
var title = page.evaluate(function () {
var posts = document.getElementsByClassName("post");
posts[0].style.backgroundColor = "#000000";
return document.title;
});
page.clipRect = { top: 0, left: 0, width: 600, height: 700 };
page.render(title + ".png");
@kmassada
kmassada / README.md
Last active September 10, 2021 08:29 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-available directory.
mkdir -p /usr/local/etc/nginx/sites-available

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default and default-ssl to /usr/local/etc/nginx/sites-available
    #STOP APACHE
    sudo apachectl stop
@kmassada
kmassada / Capistrano-Deployment-Recipe.rb
Created November 10, 2015 13:28 — forked from mrrooijen/Capistrano-Deployment-Recipe.rb
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
@kmassada
kmassada / npm-nuke.sh
Last active November 12, 2015 01:42
completely uninstall node js and reinstall
#clear all the npms
npm -g ls | grep -v 'npm@' | awk '/@/ {print $2}' | awk -F@ '{print $1}' | xargs npm -g rm
#remove all the binaries
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
#compile
wget http://nodejs.org/dist/v0.10.40/node-v0.10.40.tar.gz
tar -xzf node-v0.10.40.tar.gz
./configure
@kmassada
kmassada / README.md
Last active February 8, 2018 12:22
My GHOST BLOG workflow

STRUCTURE

  • we try out best to separate ghost/ from our application
  • depending on prod/dev ghost/ is git, or latest zip
  • Prod is started using pm2.
.
├── Capfile                        #cap task management 
@kmassada
kmassada / utils.sh
Last active June 12, 2017 03:39
helpers for bash scripts
#!/bin/bash
answer_is_yes() {
[[ "$REPLY" =~ ^[Yy]$ ]] \
&& return 0 \
|| return 1
}
ask() {
print_question "$1"
@kmassada
kmassada / README.md
Last active September 4, 2021 12:22
Vagrant and KVM(QEMU) on Centos7

Libvirt

yum group install -y "Development Tools"
yum -y install qemu-kvm libvirt virt-install bridge-utils libvirt-devel  libxslt-devel libxml2-devel libvirt-devel libguestfs-tools-c
echo "net.ipv4.ip_forward = 1"|sudo tee /etc/sysctl.d/99-ipforward.conf
sysctl -p /etc/sysctl.d/99-ipforward.conf
@kmassada
kmassada / vbox-mount-fix.sh
Last active December 20, 2015 12:21
Virtualbox Failed to mount centos7 vagrant
yum update -y; reboot;
yum install kernel-devel -y; reboot;
cd /tmp/;
wget http://download.virtualbox.org/virtualbox/5.0.10/VBoxGuestAdditions_5.0.10.iso;
sudo mkdir /mnt/
sudo mount -o loop VBoxGuestAdditions_5.0.10.iso /mnt
sudo /mnt/VBoxLinuxAdditions.run
@kmassada
kmassada / jasmine-test.js
Created January 6, 2016 17:28
jasmine basic test
(function () {
'use strict';
describe('Give it some context', function () {
describe('maybe a bit more context here', function () {
it('should run here few assertions', function () {
expect(true).toBe(true);
});
});
});
@kmassada
kmassada / index.js
Created January 6, 2016 17:34
node's hello world
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
app.get("/", function(req, res) {