Blog Spot!


Linux - wget Basic Authentication

NO Authentication:

wget http://website.com/get/articles

With Basic Authentication:

wget --user=username --password=password http://website.com/get/articles

Added on 23.Mar.2015
Tags: linux request wget authentication

How To Set Up SSH Keys

Step 1: Check for SSH keys:

$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist

Step 2: Generate a new SSH key:

$ ssh-keygen -t rsa
# Generating public/private rsa key pair.

You can press enter here, saving the file to the user home

Enter file in which to save the key (/home/username/.ssh/id_rsa):

It's up to you whether you want to use a passphrase. Entering a passphrase does have its benefits: the security of a key, no matter how encrypted, still depends on the fact that it is not visible to anyone else. Should a passphrase-protected private key fall into an unauthorized users possession, they will be unable to log in to its associated accounts until they figure out the passphrase, buying the hacked user some extra time. The only downside, of course, to having a passphrase, is then having to type it in each time you use the Key Pair.

Enter passphrase (empty for no passphrase):

The public key is now located in /home/username/.ssh/id_rsa.pub The private key (identification) is now located in /home/username/.ssh/id_rsa

digitalocean

Added on 21.Mar.2015
Tags: ssh key public private linux

Linux: Display a countdown or stopwatch timer in a terminal?

Stopwatch format:

date1=`date +%s`; while true; do 
   echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
done

Countdown timer:

seconds=20; date1=$((`date +%s` + $seconds)); 
while [ "$date1" -ne `date +%s` ]; do 
  echo -ne "$(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)\r"; 
done

You can combine these into simple commands by using bash (or whichever shell you prefer) functions. In bash, add these lines to your ~/.bashrc (the sleep 0.1 will make the system wait for 1/10th of a second between each run so you don't spam your CPU):

function countdown(){
   date1=$((`date +%s` + $1)); 
   while [ "$date1" -ne `date +%s` ]; do 
     echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%H:%M:%S)\r";
     sleep 0.1
   done
}
function stopwatch(){
  date1=`date +%s`; 
   while true; do 
    echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r"; 
    sleep 0.1
   done
}

You can then start a countdown timer of one minute by running:

countdown 60

You can countdown two hours with:

countdown $((2*60*60))

or a whole day using:

countdown $((24*60*60))

And start the stopwatch by running:

stopwatch

superuser.com

Added on 20.Mar.2015
Tags: linux bash terminal clock countdown stopwatch

Create a quick REST API using Slim framework

During a recent client project, I frequently needed to access a remote database table and update the same for certain fields. This was accomplished using phpMyAdmin on the server. However, it was getting tedious and was prone to accidental updates and deletes. Also, a couple of other developers also needed to make changes to certain fields on the remote database from their local server.

This is all a tedious process and prone to errors. One solution was to create a quick REST api wrapper around the remote database, using which developers could update the database table without any risk of corrupting the data and also with the added benefit of updating the table programmatically.

This post shows how to create a simple REST API using Slim framework. Slim is a PHP micro framework which lets you write quick PHP web applications. Here we will use it to build a REST api. Although I cannot show the exact database schema used, as this would not make sense without the context, I’ve provided a simple schema for the examples. The schema shows a students table which provides student scores along with their names.

full article

Added on 19.Mar.2015
Tags: rest php slim microframework

What is TLS? With NodeJS

Simple TLS/SSL nodejs server example

What is TLS?

Transport Layer Security (or TSL) is the successor to Secure Sockets Layer (or SSL). It, along with SSL, are the de-facto standard cryptographic protocols for secure communications over the web. TSL encrypts communications on top of a network transport layer (typically tcp), and uses public-key cryptography to encrypt messages.

Public-Key Cryptography

In public-key cryptography, each peer has two keys: A public key, and a private key. The public key is shared with everyone, and the private key is (naturally) kept secret. In order to encrypt a message, a computer requires its private key and the recipient's public key. Then, in order to decrypt the message, the recipient requires its own private key and the sender's public key.

In TLS connections, the public key is called a certificate. This is because it's "signed" to prove that the public key belongs to its owner. TLS certificates may either be signed by a third-party certificate authority (CA), or they may be self-signed. In the case of Certificate Authorities, Mozilla keeps a list of trusted root CAs that are generally agreed upon by most web browsers. These root CAs may then issue certificates to other signing authorities, which in turn sign certificates for the general public.

History of TLS/SSL Support in Node.JS

TLS support in node is relatively new. The first stable version of node.js to support TSL and HTTPS was the v0.4 branch, which was released in early 2011. Since then, the primary focus of the core developers has shifted from TLS/HTTPS to Windows support in the v0.5 branch. As such, the TSL APIs in node are still a little rough around the edges, and documentation leaves something to be desired.

read more

Added on 18.Mar.2015
Tags: tls ssl node js

Search


PHP Libraries


Carbon lib / docs
Idiorm lib / docs
Image Workshop lib / docs
lorenzos/Minixed lib / docs
Parsedown lib / docs
PHP Paginator lib / docs
PHP Redis lib / docs
QrCode lib / docs
Requests lib / docs
Slim lib / docs
Spyc lib / docs
TWIG lib / docs
Upload lib / docs
Validation lib / docs
Zebra Image lib / docs

JS Libraries


AJV lib / docs
BackboneJS lib / docs
Bootstrap Notify lib / docs
C3.js lib / docs
ChartJS lib / docs
FastMD5 lib / docs
HighlightJS lib / docs
jQuery-Storage lib / docs
JS-Cookie lib / docs
Leaflet JS lib / docs
LowDB lib / docs
Marked lib / docs
NeedlyJS lib / docs
ParcelJS lib / docs
RequireJS lib / docs
Swig lib / docs
Toastr lib / docs
Underscore lib / docs
ValidateJS lib / docs
top