Skip to content

Instantly share code, notes, and snippets.

View shahzaibalikhan's full-sized avatar

Shahzaib Ali Khan shahzaibalikhan

  • Berlin, Germany
View GitHub Profile
@brikis98
brikis98 / BinaryModules.js
Created December 1, 2011 00:45
Node.js performance tips
// Use built in or binary modules
var crypto = require('crypto');
var hash = crypto.createHmac("sha1",key).update(signatureBase).digest("base64");
@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)
@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");
@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
@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;
@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
@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
@mashpie
mashpie / i18n-express4-cookie-example.js
Last active August 12, 2021 15:48
i18n-express4-cookie-example
@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
@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