Where It All Started.

Where It All Started.

Life, Stock Trading, Investments, Business and Startup. Most are programming stuff.

Year: 2019

Using Vim Hex Editor To View Keyboard Key Hex Code

The best way to predict the future is to create it.

— Anonymous.

In this TIL (Today I Learned), we will review a way on how to view keyboard key hex code. As I modify my iTerm2 (a popular terminal emulator for macOS) key shortcuts to map my tmux Ctrl + b keys, I wonder how to get the keyboard key hex codes easily.

Then I remembered that there is the xxd (a command line hex viewer and editor which is part of the vim package) command which can process keys and convert them to hex code.

To start off, we run xxd from the terminal. It will wait for a read line. Execute your keystrokes (e.g. Ctrlb) then press enter to create a new line. After the new line add EOF (End Of File) which would corresponds to the keyboard keys Ctrl + d. After doing the process above xxd would output a hex representation of the keyboard key code that you desire.1

Another trick using xxd command is to reverse hex string like this.

echo <hex code> | xxd -revert -plain | rev | tr -d '\n' | xxd -plain

An example hex code would be 030201. That would output a reverse 010203. The rev command will reverse the output while the tr would trim newline.

  1. https://stackoverflow.com/questions/36321230/finding-the-hex-code-sequence-for-a-key-combination ↩︎

Ten Techniques to Build Rapport

We can all fight against loneliness by engaging in random acts of kindness.

— Gail Honeyman.

Hello guys, in life no one lives alone, and no one can live alone. In this TIL (Today I Learned) we will discuss the things I’ve learned when trying to socialize with other people building rapport and connections.

  1. Establish artificial time constraints. Allow the potential source to feel that there is an end in sight.
  2. Remember non-verbals. Ensure that both your body language and voice are nonthreatening.
  3. Speak slower. Do not oversell and talk too fast. You lose credibility quickly and appear too strong and threatening.
  4. Have a sympathy or assistance theme. Human beings want to provide assistance and help. It also appeals to their ego that they may know more than you.
  5. Suspend your ego. This probably represents the hardest technique but, without a doubt, is the most effective. Do not build yourself up—build someone else up, and you will have strong rapport.
  6. Validate others. Human beings crave feeling connected and accepted. Validation feeds this need, and few offer it. Be the great validator and have instant, valuable rapport.
  7. Ask “how, when, and why” questions. When you want to dig deep and make a connection, asking these questions serves as the safest, most effective way. People will tell you what they are willing to talk about.
  8. Connect using quid pro quo. Some people are more guarded than others. Allow them to feel comfortable by sharing a little about yourself if needed. Do not overdo it.
  9. Give gifts (reciprocal altruism). Human beings reciprocate gifts given. Give a gift, either intangible or material, and seek a conversation and rapport in return.
  10. Manage expectations. Avoid feeling and embodying disappointment by ensuring that your methods focus on benefiting the targeted individual, not you. Ultimately, you will win, but your mind-set needs to focus on the other person.

Humans will be humans and humans are very dependent creature. That’s all for it thanks for reading. Follow me on my social media accounts and also on my podcasts.

Checkout Specific Directory Within Git Repo

I believe that the first test of a truly great man is his humility. Really great men have a curious feeling that the greatness is not in them but through them. And they see something divine in every other man and are endlessly, incredibly merciful.

— John Ruskin.

One day I was working on a driver port to macOS (Apple Macintosh OS) and the only opensource code for it can be found on Linux kernel.

Heck! The Linux kernel repository is around 2GB including all history and I only needed a specific directory inside the repository. After searching the whole internet I found an answer1.

Here are the steps to clone a specific directory from a git repository:

  1. First and foremost you need to create a local blank repository on your workstation. git init <repo-url>
  2. Inside the created bare repository, map the remote URL of the remote repository you want to clone. cd <repo-name> git remote add origin <remote-repo-url>
  3. Then, setup the git config and specify that you’ll be doing a sparse checkout. git config core.sparsecheckout true
  4. Create and add all the directories you want to checkout in the sparse-checkout file that can be found in .git/info/sparse-checkout. echo "<needed-directory>/*" >> .git/info/sparse-checkout
  5. When all the above steps is done, finally pull the repository objects. git pull --depth=1 origin master

So guys if you have any questions? hit me up on my social media accounts. That’s all there is that is needed. Now its already cloned and can now be worked on.

❌ Originally posted on August 5, 2019.

  1. https://stackoverflow.com/a/28039894 ↩︎

Naughty Stories Night

Perhaps the best thing about the future is that it comes one day at a time.

— Dean Acheson.

This is one personal journal/memo for me a SOL (Slice Of Life). So to start one evening on clear night sky, my girlfriend who was currently staying on province said she’s on the mood. At the time, where far from each others place and we only message each other through couple’s app. She asked if I could give her a naughty story of what I would do to her when we see each other (that’ll be happening in 2 days time).

I imagined doing her in multiple places and events. After that, I tried to jack off while creating a surreal story of what I would do to her. Piece by piece sending her the story through the app, she read it and guess what she fell asleep. LOL (Laugh Out Loud) and I don’t know if the story was kinda bit boring though. Anyways, imagining her makes me feel horny again. I’ll just call it a day.

Turning Off Completely macOS Mojave Bluetooth

We keep moving forward, opening new doors, and doing new things, because we’re curious and curiosity keeps leading us down new paths.

— Walt Disney.

Recently, as you may have notice from my post. I’ve tried to build a hackintosh1 but my WiFi and BT (Bluetooth) card are not compatible or does not have compatible Kexts (stands for kernel extensions which is a driver module for macOS).

As the BT card installed in my laptop still consumes power, I did become curious on how to disable it. I have tried many ways that are not destructive which corresponds to software config modification. There are success in destructive way according to some forum but I don’t like those (e.g. like soldering certain part of the half-mini PCI-E or PCI Express board and or removing completely the PCI-E board) . I’ll try to explain what works for me in disabling the BT without touching the internals of the laptop.

First and foremost, you need to disable the power state of the BT driver.

defaults write /Library/Preferences/com.apple.Bluetooth.plist ControlPowerState 0

Then we unload it from the system startup, so application that relies from it won’t even load up in user and kernel space.

launchctl unload /System/Library/LaunchDaemons/com.apple.bluetoothd.plist

That’s all to it. Your BT is now completely disabled and not draining anymore power. Anyways, if you want to re-enable BT again in your startup and load it on your system, just execute the code below.

launchctl load /System/Library/LaunchDaemons/com.apple.bluetoothd.plist

launchctl start /System/Library/LaunchDaemons/com.apple.bluetoothd.plist

What this does is put the running daemons back in place on startup execution phase. That’s all and thanks for reading this article.

  1. A Hackintosh (a portmanteau of “Hack” and “Macintosh”), is a computer that runs macOS on a device not authorized by Apple, or one that no longer receives official software updates. ↩︎

How to Have a Good Conversation

Everything about Mark Zuckerberg is pure hacker. Hackers don’t take realities of the world for granted; they seek to break and rebuild what they don’t like. They seek to outsmart the world.

— Sarah Lacy.

Sometimes I need to talk to someone about some things and sometimes the conversation and rapport part doesn’t work out. Here are the things I’ve learned on how to have a good conversation to anyone.

  • Don’t multitask. Be present.
    If you’re the one talking, would you be happy if the listener is doing many things and like don’t care? So be present and active.
  • Don’t pontificate (meaning – express one’s opinions in a way considered annoyingly pompous and dogmatic.).
    Don’t just butt in when someone is speaking with their mind. Its considered rude to just cut someone who is talking, I think its same for every culture.
  • Use open-ended question.
    Go with questions that will create discussion not just question with a single word could answer.
  • Go with the flow.
    Follow the flow of the dialogues, and if you don’t like the subject of the discussion you can always say what you have in mind.
  • If you don’t know, say that you don’t know.
    Don’t be the all-knowing guy. Nobody likes the person who knows and pretend to know everything. Just say you don’t know if you really don’t know, and say no to smarty-pants.
  • Don’t equate your experience with theirs.
    Experience vary from person to person. It has different levels of emotions involved, don’t try.
  • Try not to repeat yourself.
    Speak clearly and with proper tone so the listener will know the intention.
  • Listen.
    Always listen, a great listener can be the most reliable person.
  • Be brief.
    Get to the point and don’t confuse the listener of what you want to say.

That’s all the things I’ve learned with having conversation to different people and walk of life.
Hope you guys, enjoyed this article and as always live life!

Disable mDNS and SSDP Discovery in Google Chrome

We’re born alone, we live alone, we die alone. Only through our love and friendship can we create the illusion for the moment that we’re not alone.

— Orson Welles.

If you ever check your task manager you’ll notice chrome is listening to port 5353 on Linux. Did you know you could stop it? as what this sub-process is specifically doing – listening and doing some device probing like an auto discovery which is similar to avahi. In order to disable this Chrome functionality you need to first create a directory and policy file. You could do this by executing the command below.

sudo mkdir -p /etc/opt/chrome/policies/managed/
sudo touch /etc/opt/chrome/policies/managed/block_mdns_ssdp.json

What this does is first create a directory inside the /etc/opt/chrome which will be used to store manage policies and create the initial policy file that we would be editing.

Then we edit the block_mdns_ssdp.json file that we created earlier and then we put the contents below.

	"EnableMediaRouter": false

This would specifically disable media router and probing of cloud printers utilized by Chrome.

NOTE: Don’t disable this functionality if you use cloud printers.

So to conclude there are some hidden sub process/services Chrome is running under the hood to manage specific Chrome functionality. So guys, what functionality or sub-process you want to disable inside Chrome? Let me know and as always live life and hope you enjoyed this article!

Output File from PSQL Command

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:

\o dump.txt
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!

C# .NET Projects Can Be Compiled and Run in MacOS or Linux

My primary goal of hacking was the intellectual curiosity, the seduction of adventure.

— Kevin Mitnick.

Before I never thought that a .NET solution project can be compiled and run on Linux. But as I’ve checked the GitHub of dotnet-core, I found there were many ways to do it.

First is through Mono, which is a compatible open source alternative to the .NET Framework (the latter is a proprietary of Microsoft). You can create WPF (Windows Presentation Foundation) forms using it and other UI intensive .NET projects. Mono is sponsored by Microsoft, but it is unofficially supported.

The other solution is, if your working on a .NET core project you’ll be using a dotnet-core. Microsoft published last 2014 an open source .NET SDK (Software Development Kit) (bare bones) which was derived from ASP.NET, they’ve called it dotnet-core. Basically, it is a stripped down version of .NET framework without all the heavy UI and forms. The project itself is modular and can be compiled in different platforms.

So if you’re planning to use C# or a .NET dependent language, don’t be afraid as it can be run and created using different platforms.

If you’re planning to install the package on Arch here is the command:

pacman -Sy dotnet-core

Or check the mono flavor:

pacman -Sy mono

That’s it guys, a brand new knowledge for me. Probably on my next project I’ll try to use .NET Core. 🤔 Hope you guys, enjoyed this article and as always live life.

Check Total File Size of Files with Specific File Extension

Posted on by Edward Fitz

It is simply this: do not tire, never lose interest, never grow indifferent—lose your invaluable curiosity and you let yourself die. It’s as simple as that.

— Tove Jansson in Fair Play.

Recently, I wondered on how to check the file size of all files with a specific file extension on a folder / project. This is what I’ve found out after several experimentation using command line tools in Linux, this specific task could be accomplish with just one line of command. Check below for the actual command:

find . -name "*.dart" | xargs cat | wc -c

What this command does, is first find all file with the dart extension. Then pipe the output of that command in xargs converts the standard input to command arguments. After that pipe the output of xargs again to our favorite word counter wc.

Here are the command line tools use in the process.

  • xargs is a command on Unix and most Unix-like operating systems used to build and execute commands from standard input. It converts input from standard input into arguments to a command. Some commands such as grep and awk can take input either as command-line arguments or from the standard input. Wikipedia
  • find is a command-line utility that locates files based on some user-specified criteria and then applies some requested action on each matched object. Wikipedia
  • wc is a command in Unix and Unix-like operating systems. The program reads either standard input or a list of files and generates one or more of the following statistics: newline count, word count, and byte count. If a list of files is provided, both individual file and total statistics follow. Wikipedia

That’s it!

So guys, do you have any one-liner commands that you want to share? Just message me on my social media accounts. Hope you guys enjoyed this article!