Archive for the ‘Quick Tips’ Category

Quick Tip: Find your Distro Name in 1 Line

lsb_release -cs

Quick Tip: Scaling in Hbase

Everything scales — hence autosharding, notifications to ZooKeeper, etc

So you don’t have to do anything to make it distributed/scalable

Quick Tip: HBase Scan (a simple example)

hbase(main):008:0> scan ‘test’
ROW                   COLUMN+CELL
 row1                 column=cf:a, timestamp=1381963930588, value=value1
 row2                 column=cf:b, timestamp=1381963944569, value=value2
 row3                 column=cf:c, timestamp=1381963957538, value=value3

3 row(s) in 0.1270 seconds

Quick Tip: How to Connect to a Running Session (shell) in HBase in 1 Line

./bin/hbase shell

Quick Tip: Shred a Directory in 1 Line

find directory -type f | xargs shred –remove
normal (recursive) directory removal:
rm -rf directory

Quick Tip: IPTables port forwarding in 1 Line

iptables -A PREROUTING -t nat -p tcp -i eth0 –dport 88 -j DNAT –to 192.168.1.2:22

Quick Tip: Erase a drive (insecurely) in 1 Line

sudo dd if=/dev/zero of=/dev/sdx bs=512 count=1
where sdx is the drive you want to zero (this is an INsecure wipe)

Quick Tip: Remove Lines with sed in 1 Line

cat sample.txt | sed -e '1,15d'

Quick Tip: Create a Binary Column Conditionally in Postgres/PaDB/SQL


create table c as
    select a.id, tall, funny, weight,
           (case when b.id is null then 0 else 1 end) as rich
    from tablea a left outer join
         tableb b 
         on a.id = b.id;
or
select
    a.id, tall, funny, weight,
    (b.id is not null)::integer as rich
from
    tablea a
    left outer join
    tableb b on a.id = b.id

Quick-Tip: How to Programmatically Re-install Packages in R

 

Get the currently installed packages:
package_df <-as.data.frame(installed.packages(“/Library/Frameworks/R.framework/Versions/2.15/Resources/library”))
package_list <- as.character(package_df$Package)

 

Re-install  packages:

install.packages(package_list)