Skip to content

Instantly share code, notes, and snippets.

View shahzaibalikhan's full-sized avatar

Shahzaib Ali Khan shahzaibalikhan

  • Berlin, Germany
View GitHub Profile
@learncodeacademy
learncodeacademy / node-deploy-as-upstart-service.md
Last active August 16, 2022 17:35
Deploy Node.js app on Ubuntu as Upstart Service - instead of using Forever

Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to re-deploy.

To get around this, we're going to run our node app as an Upstart service. Upstart services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts.

###Step 1: Create a service for your node app

  • ssh in as root ssh root@youripaddress
  • Create a node-app.conf file in /etc/init
    IMPORTANT: whatever filename you pick is what you will use to start|stop|restart your service i.e. service node-app start
@learncodeacademy
learncodeacademy / flightplan-deploy.md
Last active January 7, 2024 11:58
Deploy Node.js Apps with Flightplan

##Setup your server (this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g forever

##Install flightplan

  • npm install -g flightplan
  • in your project folder npm install flightplan --save-dev
  • create a flightplan.js file
@othiym23
othiym23 / npm-upgrade-bleeding.sh
Created September 20, 2014 19:36
a safe way to upgrade all of your globally-installed npm packages
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
@mashpie
mashpie / i18n-express4-cookie-example.js
Last active August 12, 2021 15:48
i18n-express4-cookie-example
@relaiyavalli
relaiyavalli / scrapNewsTitles.py
Last active August 29, 2015 14:02
Here is a simple Python code snippet to retrieve news titles from various news feeds. This example retrieves Technology news headlines from Reuters. All you need is urllib and cookielib installed. Please be careful only to scrap permissible sites and rss feeds.
import urllib2
import re
import cookielib
from cookielib import CookieJar
# If the web site expects cookies
cookie = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
# Get Scrapper pose as Browser
@johanneswuerbach
johanneswuerbach / rails-vagrant-provision.sh
Last active June 29, 2020 19:24
Provision a vagrant box with ruby stable (using rvm), postgres, redis and node (using nvm)
#!/usr/bin/env bash
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8
sudo apt-get update
sudo apt-get install -y build-essential git curl libxslt1-dev libxml2-dev libssl-dev
# postgres
@qubyte
qubyte / unshortener.dart
Last active October 3, 2018 13:34
Super simple URL unshortener in Dart
import 'dart:io' show HttpRequest, HttpClient, HttpServer, ContentType;
import 'dart:convert' show JSON;
void handleRequest(HttpRequest request) {
// For convenience.
var response = request.response;
// No path is expected. Return with 404 for anything else.
if (request.uri.path != '' && request.uri.path != '/') {
response.statusCode = 404;
@jasonrudolph
jasonrudolph / 00-about-search-api-examples.md
Last active April 30, 2024 19:21
5 entertaining things you can find with the GitHub Search API
@reu
reu / pub-sub.js
Created April 9, 2013 01:51
node.js redis pub-sub example
var redis = require("redis")
, subscriber = redis.createClient()
, publisher = redis.createClient();
subscriber.on("message", function(channel, message) {
console.log("Message '" + message + "' on channel '" + channel + "' arrived!")
});
subscriber.subscribe("test");
@TooTallNate
TooTallNate / repl-client.js
Created March 26, 2012 20:09
Running a "full-featured" REPL using a net.Server and net.Socket
var net = require('net')
var sock = net.connect(1337)
process.stdin.pipe(sock)
sock.pipe(process.stdout)
sock.on('connect', function () {
process.stdin.resume();
process.stdin.setRawMode(true)