Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

To compress a folder

tar -zcvf tar-archive-name.tar.gz source-folder-name

To un-compress a tar.gz

tar -zxvf tar-archive-name.tar.gz

@ernest-ns
ernest-ns / Color.rb
Created June 15, 2016 19:48
A color class to calculate the distance between 2 colors.
class MyColor
attr_accessor :red, :blue, :green, :alpha
def initialize(args)
@red = args[:red]
@blue = args[:blue]
@green = args[:green]
@alpha = args[:alpha] || 1
end
def distance(color)
red_diff = self.red - color.red
@ernest-ns
ernest-ns / find_duplicate.rb
Created March 3, 2016 12:53
Rails Script to find Duplicate entries in the DB
User.select(:first,:email).group(:first,:email).having("count(*) > 1").count
#{[nil, nil]=>512,
# ["Joe", "test@test.com"]=>23,
# ["Jim", "email2@gmail.com"]=>36,
# ["John", "email3@gmail.com"]=>21}
@ernest-ns
ernest-ns / guest_additions.link
Created August 7, 2015 04:14
Vagrant: How to keep your guest additions updated
@ernest-ns
ernest-ns / vagrant_ssh_issue_solution.link
Created August 6, 2015 19:15
Solution to solve the vagrant ssh issue
@ernest-ns
ernest-ns / psqlCommands
Created June 10, 2015 05:50
PSQL COMMANDS
\l - to list all the databases
\connect <dbname> - connect to the db
\dt - list all the tables in the current DB
@ernest-ns
ernest-ns / How to - S3 sync
Created May 15, 2015 05:22
How to sync/upload local folder to s3
How to sync Local Folder with S3
s3cmd --configure
give the aws key and the secret key
options required
* --skip-existing
* --progress
So
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
#!/bin/bash
echo "*******************************************"
ps -aef | wc -l
echo "*******************************************"
sudo nmap -sS 127.0.0.1
echo "*******************************************"