Skip to content

Instantly share code, notes, and snippets.

View DarrylDias's full-sized avatar
🎯
Focusing

Darryl Dias DarrylDias

🎯
Focusing
View GitHub Profile
@DarrylDias
DarrylDias / hello.js
Created December 25, 2013 09:13
Hello World! written in nodeJS
/* This will display Hello World! on client's web browser.
The code below will not show up in the source. Only "<strong>Hello World!</strong>" will be visible in source.
*/
var http = require('http');
http.createServer(function (req,res) {
res.writeHead(200, {'Content-Type:' 'text/html'});
res.end('<strong>Hello World!</strong>');
}).listen(80, '0.0.0.0');
console.log('Web Server running on port:80 on server ip');
@DarrylDias
DarrylDias / hello_world.js
Last active January 2, 2016 11:39
Hello World that displays console log on every new client's connection
var http = require('http');
http.createServer(function(request,response) {
response.writeHead(200, {'Content-Type':'text/plain'});
response.end("Hello World!\n"); // "Hello World!" will be displayed to the client's browser
console.log("New page request!\n"); // message will be displayed with every new request
}).listen(8000); //Node web server port. Edit it to your preferd port.
console.log("Node web server running at http://127.0.0.1:8000");
console.log("CTRL + C to stop the Node web server");
@DarrylDias
DarrylDias / ghost-starter.sh
Last active January 2, 2016 23:08
Ghost starter script.
#!/usr/bin/bash
if [ $(ps aux | grep node | grep -v grep | wc -l | tr -s "\n") -eq 0 ]
then
export PATH=/usr/bin:$PATH
#export PATH=/usr/local/bin:$PATH # If Node.js is source complied.
export NODE_ENV=production
NODE_ENV=production forever start --sourceDir /path/to/your/ghost index.js >> /var/log/nodelog.log 2>&1
fi
@DarrylDias
DarrylDias / phpmyadmin.conf
Created January 15, 2014 08:22
NGINX phpMyAdmin configuration for Fedora.
server {
listen 81; #You can change listen to the port you prefer
server_name localhost; # the server_name must be changed to the domain if required
root /usr/share/phpMyAdmin; # the root must be changed if the path to phpMyAdmin is different
index index.php;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
@DarrylDias
DarrylDias / deploy.sh
Created January 16, 2014 17:42
Sync folder using Lftp. you need to install Lftp to use this script on you system
#!/bin/bash
HOST='yourwebsite.com'
USER='your_username_here'
PASS='your_password_here'
TARGETFOLDER='/remote_folder'
SOURCEFOLDER='/home/myuser/local_folder'
lftp -f "
open $HOST
user $USER $PASS
@DarrylDias
DarrylDias / nginx.conf
Last active January 4, 2016 22:19
nginx.conf for running Ghost on Arch Linux ARM.
http {
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:2368;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
@DarrylDias
DarrylDias / .bash_profile
Last active August 29, 2015 13:56
Ruby 2.1 export environment. [Arch Linux]
PATH="$(ruby -e 'puts Gem.user_dir')/bin:$PATH"
export PATH
@DarrylDias
DarrylDias / nginx-startup.sh
Created February 8, 2014 16:50
NGINX startup script for user who have source complied NGINX.
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
var net = require('net'); // Store net module in net variable
var server = net.createServer(function (socket) { // create a netserver using createServer() function.
socket.write('Information \r\n'); // Write information of the client.
socket.pipe(socket); // connect to socket
});
server.listen(1337, '127.0.0.1'); // port and host running on.
@DarrylDias
DarrylDias / pdodriver.php
Created March 28, 2014 17:32
Check for available drivers for Database in PDO PHP.
<?php
print_r(PDO::getAvailableDrivers()); // This will display an array that lists PDO drivers avilable on the web server.
?>
/*
Example.
Web Setup: WAMP.