Success is neither magical nor mysterious. Success is the natural consequence of consistently applying basic fundamentals.
— E. James Rohn.
Hi guys, last week I’ve worked on a vanilla Windows 10 client computer without internet but is connected to a LAN with many computer.
I’ve asked myself on how to get all alive computers in the network using only built in tools from Windows.
Here are the things I’ve did in order to accomplish this feat.
First thing I did was ping all broadcast IP using ping <broadcast ip> -t -i 4. This will ping the broadcast IP, this action will spread and send all message to all active computers in the network. After that we would wait for around 5-10 seconds, and execute the follow up command which is arp -a. The arp command will check the address resolution protocol and list it down.
The -i 4 on the ping command instructs to ping only on IPv4 (Internet Protocol Version 4) network. That’s all there is to it. Kindly check the manual page of the commands for different flag combinations.
She had an immense curiosity about life, and was constantly staring and wondering.
— Henry James in The Portrait of a Lady.
On a bright sunny day, while you’re on vacation on a remote island, you get an emergency call from your office regarding a failure on production database and you don’t have your workstation with you. And the only access you can get due to slow internet speed is SSH (Secure Shell), you try to access the remote production database using a rented computer and an SSH client; the tools inside the server is only compose of a psql command. How can you export and backup your SQL schema layouts?
Don’t panic and don’t worry we got you covered, thepsql saves your day if you’ll just gonna be exporting SQL schema layouts.
First and foremost, fire up and execute the psql command. Inside the psql environment execute the commands below:
SELECT 'postgresql' AS dbms,t.table_catalog,t.table_schema,t.table_name,c.column_name,c.ordinal_position,c.data_type,c.character_maximum_length,n.constraint_type,k2.table_schema,k2.table_name,k2.column_name
FROM information_schema.tables t
NATURAL LEFT JOIN information_schema.columns c
LEFT JOIN(information_schema.key_column_usage k
NATURAL JOIN information_schema.table_constraints n
NATURAL LEFT JOIN information_schema.referential_constraints r)
ON c.table_catalog=k.table_catalog AND c.table_schema=k.table_schema AND c.table_name=k.table_name AND c.column_name=k.column_name
LEFT JOIN information_schema.key_column_usage k2
ON k.position_in_unique_constraint=k2.ordinal_position AND r.unique_constraint_catalog=k2.constraint_catalog AND r.unique_constraint_schema=k2.constraint_schema AND r.unique_constraint_name=k2.constraint_name
WHERE t.TABLE_TYPE='BASE TABLE' AND t.table_schema NOT IN('information_schema','pg_catalog');
This command will create a dump file containing all the table structure containing each constraint available, this is usually needed when you need to analyze ER (Entity Relation) diagram. You could example paste the output of this command on Lucid Chart to analyze entity relationship.
A break down of this is, the SELECT command will query all table structure and schema.
Switches Legend: \o => outputs to file \O => turns off the output to file feature
The output file will be generated on the same directory where you run the psql command.
So guys, when on vacation what are the things you can do on a slow internet and a rented computer? Hope you enjoyed this article!
When you can’t find the sunshine, be the sunshine!
Have you ever dream of building your own app, but think its too hard. Why don’t you try flutter…
First of all you need flutter, just follow the steps below in order to run install it.
Building Hello World
First we will install flutter, depending on your operating system you could find the details on how to install flutter here. On arch Linux you could find it on AUR repository.
After installing the flutter package. Run flutter doctor to check for any dependency error.
And now we begin, to start a flutter project you need to type in flutter create <project-name>. For example I’m building a hello world project named stocks.
flutter create stocks
The command will create a directory named stocks which contains minimal running app template. What we do first is open the file lib/main.dart using your favorite text editor and rename the app title Flutter Demo to Hello World. Then remove the whole Scaffold block as we will create our own scaffold. After the changes your _MyHomePageState class would look like this.
Clean up the unused functions and variable like _counter and _incrementCounter. If your editor has integrated linter and dart analyzer it would complain regarding unused variable. Once cleanup’s done, implement now a centered hello world text by adding body to the scaffold.
Now run your code using the command flutter run. If a device’s connected it will show an app displaying a centered hello world. You could also use an emulator by running flutter launch before running flutter run.
So what’s next?
Now after everything’s done, we will continue building our stocks monitor app on the next chapter. Stay tuned. Hit like if you like, subs if you love and as always live life.