Tuesday, 19 July 2016

Idea - multi floor roads

Think about it. Why are the roads one or two floored? Why can't we have multiple floored roads that allow traffic in huge number.

I'm thinking a setup like they do for show-off purposes in bars where they put glasses in pyramids and let the drink fall.

Similarly if we start with roads 32 lanes wide and higher road 16 lanes and such till we have 4 lane on top, we have got 4 floored roads.

One of which can exclusively be used by commercial vehicles, one by pedestrians and cyclists and differently abled etc.

Also put city lungs around them people can jog in peaceful area, drivers can take break and everyone gets fresh air.

And rain ruins roads, why not cover roads with solar panels.

Idea - multi floor farms

This is the time for humans to build multi floor farms and buildings that act as lungs for cities and also as food producers..

Think a 30 floor building. Now keep the structure but remove two floors after 1, 3, 6 ...

That way only 10 floors will be left. Now 30 feet are enough for plants and trees to grow. May be reduce the floor count further to 6. Trees can grow easily now.

Plant trees that give fruits, that will solve hunger problem a little bit.

Wednesday, 6 July 2016

nuname is uname package for node.

Remember this post: http://the-diary-of-a-wimpy-coder.blogspot.in/2016/07/uname-and-nodejs-os.html

This was about `uname` in terminal and `os` in nodejs. Well, I wrote a node js package for it: nuname. https://www.npmjs.com/package/nuname

Usage is simple.

  npm install nuname
  var nuname = require('nuname');

  console.log(nuname('r')); // for release
  console.log(nuname('s')); // for type

Remember: uname -r === os.release() uname -s === os.type()

Uname and NodeJS OS

MAC terminal

UNAME(1)                  BSD General Commands Manual                 UNAME(1)

     uname -- Print operating system name

     uname [-amnprsv]

     The uname utility writes symbols representing one or more system charac-
     teristics to the standard output.

     The following options are available:

     -a      Behave as though all of the options -mnrsv were specified.

     -m      print the machine hardware name.

     -n      print the nodename (the nodename may be a name that the system is
             known by to a communications network).

     -p      print the machine processor architecture name.

     -r      print the operating system release.

     -s      print the operating system name.

     -v      print the operating system version.

     If no options are specified, uname prints the operating system name as if
     the -s option had been specified.

     hostname(1), machine(1), sw_vers(1), uname(3)

     The uname utility conforms to IEEE Std 1003.2-1992 (``POSIX.2'').  The -p
     option is an extension to the standard.

BSD                            November 9, 1998                            BSD

uname -a
Darwin LM-BNG-26500023 14.5.0 Darwin Kernel Version 14.5.0: Thu Apr 21 20:40:54 PDT 2016; root:xnu-2782.50.3~1/RELEASE_X86_64 x86_64
uname -m
uname -n
uname -p
uname -r
uname -s
uname -v
Darwin Kernel Version 14.5.0: Thu Apr 21 20:40:54 PDT 2016; root:xnu-2782.50.3~1/RELEASE_X86_64

NODE.JS 4.4.1

var os = require('os');

{ hostname: [Function: getHostname],
  loadavg: [Function: getLoadAvg],
  uptime: [Function: getUptime],
  freemem: [Function: getFreeMem],
  totalmem: [Function: getTotalMem],
  cpus: [Function: getCPUs],
  type: [Function: getOSType],
  release: [Function: getOSRelease],
  networkInterfaces: [Function: getInterfaceAddresses],
  homedir: [Function: getHomeDirectory],
  arch: [Function],
  platform: [Function],
  tmpdir: [Function],
  tmpDir: [Function],
  getNetworkInterfaces: [Function: deprecated],
  EOL: '\n',
  endianness: [Function] }

  uname -r === os.release()
  uname -s === os.type()
  uname -n === os.hostname()

One of the old project of mine has incorrect and ugly code.

So I have this repo that I created way back when 2048 was very famous. This is in C. https://github.com/IAmAnubhavSaini/c_2048

The thing is that I wrote it in C and it sucks. Not the C, but the code that I wrote. I can surely say that I used to write shit code. Hmm. Well, I updated some of it, but it is still gibberish.

Things that I should have done.

1. Write a test suite to help understand future me what the hell code is doing.
2. Write cleaner code.
3. Write code is in granular form so that the code is understandable from the point of building block.

Hmm. Rant is over.

Oh, what provoked it? Well, http://the-diary-of-a-wimpy-coder.blogspot.in/2014/03/2048-in-c.html is the one of the highest visited post. Weird.

Monday, 4 July 2016

Evolving code

There's a need for programs to know about themselves. A program must remember it's history.

You called a program with some options, next time it should at the least be able to show you that history and let you execute that same command with or without modification.

This is a good idea for programs evolution. It needs to be done in an organic way. A program should know about it's consumption too.