Wednesday, July 24, 2019

Freshly Is it worth it? How good is freshly

Been living in NYC for few years and with city life
it’s hard to find time to cook sometimes

Buying groceries costs me more $$ since by the time
I decide to cook, groceries are already bad

Recently I came across Freshly! I was a bit skeptical
in the beginning about how good food in a box can be
that I need to microwave but I was surprised after eating
for a week. Meals were delicious, low carb, high in protein

Of course some meals are better than the others
but overall, it is definitely worth trying and there are plenty
of options to choose from

I get 6 meals every week for me and my wife and it works
really well . You can easily skip week/s which plays well if you
don’t want to eat Freshly every day

Use this link and you will get $20 off for your first two deliveries
and I will get the same. Win win!
http://refer.freshly.com/s/Atul26

How much does it cost?

More meals per week the less it is.  No brainer









Sunday, February 28, 2016

How to figure out static dependencies of a library for example libxml-2.0

Alright, this is fairly common question when you are trying to generate a static binary or have come across situations when you want to find out all the dependencies of a library.

Example:
The problem: How the hell do I figure out all the static dependencies of libxml-2 ?

The solution: Its easy, use pkg-config !!

Here is how to list all the static dependencies of libxml-2

Run the below command:

pkg-config --static --libs libxml-2.0

and this returns a list

-lxml2 -lpthread -lz -lm

Saturday, February 27, 2016

All permutation of a string using Go (Golang)

I have been playing around a bit with Golang and I thought the best way to learn about a prog. language is to write some code.

The problem: Write all permutations of a given string

The solution:

Run code here : http://play.golang.org/p/h4Kx6IS_lE




Saturday, January 16, 2016

Dockerizing Sinatra app with reloading (Docker + Sinatra + foreman + rerun)

Lately I have been trying to learn more about Docker, so I picked up a task to dockerize a Sinatra app.

Here is an excellent training material which includes 3 hours of video about docker:
https://training.docker.com/self-paced-training

Here is another introduction to docker by Codeship:
http://blog.codeship.com/using-docker-for-rails-development/

Assumptions:
  1. You have a Sinatra app up and running using foreman.
  2. You have docker machine installed. We will be using docker compose to dockerize

Lets get started:

Step 1: Create a file named Dockerfile in the root of your project with the following content


Step 2: Create a file named docker-compose.yml in the root of your project with the following content



Step 3: Lets get reloading Sinatra app on changes working (ONLY if you want to reload your Sinatra app on changes using rerun gem)

At the moment to get rerun to work properly with Docker you have to supply --force-polling option
as mentioned here
https://github.com/alexch/rerun#vagrant-and-virtualbox

The catch is that the supporting code is only in master(as of now) and is not pushed to the latest gem.
So chances are if you install the latest version of rerun gem, you might not get the force-polling option 

use this in your gemfile development section to load the master branch of the gem
gem 'rerun', :git => 'https://github.com/alexch/rerun.git'
gem 'foreman'

Step 4: And thats all the config thats needed. Run
    a) docker-compose build
    b) docker-compose up


Saturday, April 4, 2015

Ever wondered how good is a restaurants kitchen ?
Wana check how good a restaurant is for real in NYC. ?

NYC Restaurants Grades is the place to go. Checkout http://www.nycrestaurantsgrades.com/

Check most recent NYC restaurant inspections and grades. You can also see past NYC restaurants inspections results and grades.

Website - http://www.nycrestaurantsgrades.com/




Saturday, September 6, 2014

Binary Tree using HTML5 Canvas and JavaScript

Hi Guys -

I was just playing around with HTML5 Canvas and thought it will be fun to create a binary tree implementation using JavaScript.

I tried this a few years ago with Java and applets. Well, yeah u guessed it, it was a PITA.

With JavaScript and Canvas, it was a smooth ride.

The code below is only for the purpose of demo. Some nodes might overlap if the tree has a lot
of nodes.

Tested on Google Chrome

1 - Create a file index.html and add the below code to it.
      It contains an
      a - Input box where the user will enter the number to be added
      b - A button to add entered number
      c - A canvas element
      d - A script tag


     
2 - Next we will add a node object. Node, as the name suggests, represent a node in the tree
     Add the below code in the script tag of the index.html

   

3 - Next we will add code to draw a line from parent to child. Add the below code to the script tag    
   


4 - Next we add the core logic of a binary tree. To understand that logic, you should know how
     a binary tree works. Add the blow code the script tag

   

5 - Now we  need to create a binary tree object to which we can add node
 
     Add the below code to the script tag

     var btree = new BTree();

6 - Ok. We are almost done. We just need to wire the input box and add to tree button
     Add the below code to the script tag


    

Thursday, August 21, 2014

Elasticsearch 101 - How secure is it ?

So, I wanted to add full text search functionality to one of my projects and after doing some research I decided to go with Elasticsearch.

While reading the docs, I came across two RESTful apis which were good but also dangerously exploitable.

So what are those apis - (assuming that a local instance is running on port - 9200 )

1 - curl XGET 'http://localhost:9200/_nodes?pretty=true'
   
     Run this command from your terminal and you will see a lot of details about your machine

  • Paths - 
    • logs: /Users/I/am/a/hacker/logs
    • home: /Users/I/can/see/your/home
  • OS info -
    • cpu details
    • memory details
    • and yeah JVM details
  • Network info - 
    • IP address
    • mac address

2 - curl -XPOST 'http://localhost:9200/_cluster/nodes/_master/_shutdown'   or
     curl -XPOST 'http://localhost:9200/_shutdown'

     Any user can execute the above command and bring down your whole cluster. 
     Still most big companies have pretty good firewall setup so its hard to get access to a machine but
     still, imo, there should be some kind of permission to execute these commands


Anyways these are some interesting things which I came across while reading the docs.