Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop
    1. Home
    2. lkdev
    3. Best
    • Profile
    • Following 5
    • Followers 2
    • Topics 8
    • Posts 78
    • Best 16
    • Controversial 0
    • Groups 6

    Best posts made by lkdev

    • Most Important Terminal Commands For Developers

      Most Important Terminal Commands For Developers


      The terminal is one of the most important tool for software developers in 2019. Mastering it can have a very positive effect on your workflow, as many everyday tasks get reduced to writing a simple command and hitting Enter. In this article i have prepared for you a collection of Unix commands that will help you get the most out of your terminal. Some of them are built in, others are free tools that are time-tested and can be installed in less than a minute.

      Git


      Git is by far the most popular version control system right now. It is one of the defining tools of modern web dev and we just couldn't leave it out of our list.

      There are plenty of third-party apps and tools available but most people prefer to access git natively though the terminal. The git CLI is really powerful and can handle even the most tangled project history.

      If you want to learn more about git, i recommend checking out this

      SSH


      With the ssh command users can quickly connect to a remote host and log into its Unix shell. This makes it possible to conveniently issue commands on the server directly from your local machine's terminal.

      To establish a connection you simply need to specify the correct ip address or url. The first time you connect to a new server there will be some form of authentication.

      ssh username@remote_host
      

      If you want to quickly execute a command on the server without logging in, you can simply add a command after the url. The command will run on the server and the result from it will be returned.

      ssh username@remote_host ls /var/www
      
      some-website.com
      some-other-website.com
      

      There is a lot you can do with SSH like creating proxies and tunnels, securing your connection with private keys, transferring files and more. You can read more in this guide.

      Tree


      Tree is a tiny command line utility that shows you a visual representation of the files in a directory. It works recursively, going over each level of nesting and drawing a formated tree of all the contents. This way you can quickly glance over and find the files you are looking for.

      tree
      .
      ├── css
      │   ├── bootstrap.css
      │   ├── bootstrap.min.css
      ├── fonts
      │   ├── glyphicons-halflings-regular.eot
      │   ├── glyphicons-halflings-regular.svg
      │   ├── glyphicons-halflings-regular.ttf
      │   ├── glyphicons-halflings-regular.woff
      │   └── glyphicons-halflings-regular.woff2
      └── js
          ├── bootstrap.js
          └── bootstrap.min.js
      
      

      There is also the option to filter the results using a simple regEx-like pattern:

      tree -P '*.min.*'
      .
      ├── css
      │   ├── bootstrap.min.css
      ├── fonts
      └── js
          └── bootstrap.min.js
      
      

      Disk usage - du


      The du command generates reports on the space usage of files and directories. It is very easy to use and can work recursively, going through each subdirectory and returning the individual size of every file.

      A common use case for du is when one of your drives is running out of space and you don't know why. Using this command you can quickly see how much storage each folder is taking, thus finding the biggest memory hoarder.

      # Running this will show the space usage of each folder in the current directory.
      # The -h option makes the report easier to read.
      # -s prevents recursiveness and shows the total size of a folder.
      # The star wildcard (*) will run du on each file/folder in current directory.
      
      du -sh *
      
      1.2G    Desktop
      4.0K    Documents
      40G     Downloads
      4.0K    Music
      4.9M    Pictures
      844K    Public
      4.0K    Templates
      6.9M    Videos
      

      There is also a similar command called df (Disk Free) which returns various information about the available disk space (the opposite of du).

      Tar


      Tar is the default Unix tool for working with file archives. It allows you to quickly bundle multiple files into one package, making it easier to store and move them later on.

      tar -cf archive.tar file1 file2 file3
      

      Using the -x option it can also extract existing .tar archives.

      tar -xf archive.tar
      

      Note that most other formats such as .zip and .rar cannot be opened by tar and require other command utilities such as unzip.

      Many modern Unix systems run an expanded version of tar (GNU tar) that can also perform file size compression:

      # Create compressed gzip archive.
      tar -czf file.tar.gz inputfile1 inputfile2
      
      # Extract .gz archive.
      tar -xzf file.tar.gz
      

      If your OS doesn't have that version of tar, you can use gzip, zcat or compress to reduce the size of file archives.

      md5sum


      Unix has several built in hashing commands including md5sum, sha1sum and others. These command line tools have various applications in programming, but most importantly they can be used for checking the integrity of files.

      For example, if you have downloaded an .iso file from an untrusted source, there is some chance that the file contains harmful scripts. To make sure the .iso is safe, you can generate an md5 or other hash from it.

      md5sum ubuntu-16.04.3-desktop-amd64.iso 
      
      0d9fe8e1ea408a5895cbbe3431989295  ubuntu-16.04.3-desktop-amd64.iso
      

      You can then compare the generated string to the one provided from the original author (e.g. UbuntuHashes).

      Htop


      Htop is a more powerful alternative to the built-in top task manager. It provides an advanced interface with many options for monitoring and controlling system processes.
      0_1547220062757_htop-1.jpg

      Although it runs in the terminal, htop has very good support for mouse controls. This makes it much easier to navigate the menus, select processes, and organize the tasks thought sorting and filtering.

      Ln


      Links in Unix are similar to shortcuts in Windows, allowing you to get quick access to certain files. Links are created via the ln command and can be two types: hard or symbolic. Each kind has different properties and is used for different things (read more).

      Here is an example of one of the many ways you can use links. Let's say we have a directory on our desktop called Scripts. It contains neatly organized bash scripts that we commonly use. Each time we want to call one of our scripts we would have to do this:

      ~/Desktop/Scripts/git-scripts/git-cleanup
      

      Obviously, this is isn't very convinient as we have to write the absolute path every time. Instead we can create a symlink from our Scripts folder to /usr/local/bin, which will make the scripts executable from all directories.

      sudo ln -s ~/Desktop/Scripts/git-scripts/git-cleanup /usr/local/bin/
      

      With the created symlink we can now call our script by simply writing its name in any opened terminal.

      git-cleanup
      

      Curl


      Curl is a command line tool for making requests over HTTP(s), FTP and dozens of other protocols you may have not heard about. It can download files, check response headers, and freely access remote data.

      In web development curl is often used for testing connections and working with RESTful APIs.

      # Fetch the headers of a URL.
      curl -I http://google.com
      HTTP/1.1 302 Found
      Cache-Control: private
      Content-Type: text/html; charset=UTF-8
      Referrer-Policy: no-referrer
      Location: http://www.google.com/?gfe_rd=cr&ei=0fCKWe6HCZTd8AfCoIWYBQ
      Content-Length: 258
      Date: Wed, 09 Aug 2017 11:24:01 GMT
      
      # Make a GET request to a remote API.
      curl http://numbersapi.com/random/trivia
      29 is the number of days it takes Saturn to orbit the Sun.
      

      Curl commands can get much more complicated than this. There are tons of options for controlling headers, cookies, authentication, and more

      posted in General Discussion
      lkdev
      lkdev
    • RE: codeigniter

      you can use laravel eloquent ORM in the codeigniter

      https://blog.sarav.co/integrate-laravel-eloquent-in-code-igniter/

      posted in Web Development
      lkdev
      lkdev
    • RE: React JS Intro

      Good Explanation, react is the future of web frontend

      posted in Front-End Development
      lkdev
      lkdev
    • RE: App for Lanka Developers Community

      මේකනම් good idea එකක් , අපි admin ට මේක කියමු

      posted in General Discussion
      lkdev
      lkdev
    • How to add custom registration fields to Woocommerce checkout ?

      Hi, I need to add to add woocommerce registration fields ( with billing fields (firstname, lastname, address, country, etc ) to login page in the chckout. now woocommerce only showing login fields in the woocommerce checkout authentication page.

      I need to display both login and registration fields in the same checkout authentication page.

      how can i do that ?

      posted in Back-End Development
      lkdev
      lkdev
    • How to secure my Woocommerce site in Nginx server ?

      Hi lankadevs,

      I'm new to nginx server i want to know how to secure my woocommerce site, i'm selling digital contents to my customers (photos, art works , etc), i want to protect digital content in the server side. please help me to achieve this task .

      Thanks guys.

      posted in Information Security
      lkdev
      lkdev
    • RE: [Guide] Online Passive Income By Blogging

      Thnx bro, superb explanation

      posted in Blogs
      lkdev
      lkdev
    • RE: Lanka Developers Meetup

      Nice Idea, we need this.

      posted in General Discussion
      lkdev
      lkdev
    • RE: CSS Grid

      මේක use කරන එකෙයි bootstrap use කරන එකෙයි ලොකු වෙනසක් තියෙනවනේ . bootstrap pre built class use කරලා අපිට ලේසියෙන් හදාගන්න පුළුවන් මේ විදියට custom ගහගෙන වද විදින්න ඕනේ නැනේ. ඔයාට bootstrap ලොකු වැඩි නම් skeleton framwork එක use කරන්න පුළුවන්

      posted in Front-End Development
      lkdev
      lkdev
    • RE: 8 MOST POWERFUL JAVASCRIPT FRAMEWORKS TO LEARN IN 2019

      Thnx mate. Javascript is the trend of 2019.

      posted in Web Development
      lkdev
      lkdev
    • RE: Technology Trends You Need to Know...

      and Blockchains are sooo famous in 2019

      posted in Blogs
      lkdev
      lkdev
    • RE: laravel redirect to wrong url after auth success

      @krisssachintha

      overide login function.

      inside login controller (app/Http/Controllers/Auth/LoginController.php)

      <?php
        
      namespace App\Http\Controllers\Auth;
        
      use App\Http\Controllers\Controller;
      use App\Providers\RouteServiceProvider;
      use Illuminate\Foundation\Auth\AuthenticatesUsers;
      use Illuminate\Http\Request;
      use Auth;
         
      class LoginController extends Controller
      {
          /*
          |--------------------------------------------------------------------------
          | Login Controller
          |--------------------------------------------------------------------------
          |
          | This controller handles authenticating users for the application and
          | redirecting them to your home screen. The controller uses a trait
          | to conveniently provide its functionality to your applications.
          |
          */
        
          use AuthenticatesUsers;
        
          /**
           * Where to redirect users after login.
           *
           * @var string
           */
          protected $redirectTo = RouteServiceProvider::HOME;
         
          /**
           * Create a new controller instance.
           *
           * @return void
           */
          public function __construct()
          {
              $this->middleware('guest')->except('logout');
          }
        
           /**
           * Write code on Method
           *
           * @return response()
           */
          public function login(Request $request)
          {
              $request->validate([
                  'email' => 'required',
                  'password' => 'required',
              ]);
           
              $credentials = $request->only('email', 'password');
              if (Auth::attempt($credentials)) {
        
                  return redirect()->route('home');
              }
          
              return redirect("login")->withSuccess('Oppes! You have entered invalid credentials');
          }
      }
      
      posted in Laravel Framework
      lkdev
      lkdev
    • Serverless with JAMstack

      Traditional Approach


      Traditionally, we’ve built and deployed (Hosted) web applications where we have a 24hrs up and running remote computer called server. Our application runs on that server and we are responsible for provisioning and managing the resources for the severs. There are a few issues with this.

      wOfS8.png

      1. We are charged for keeping the server up and running even when we are not serving out any requests.

      2. We are responsible for uptime and maintenance of the server and all its resources.

      3. We also responsible for applying the appropriate updates and patches to the server.

      As our usage scales we need to manage scaling up our server as well. And as a result manage scaling it down when we don’t have as much usage.

      For smaller companies and individual developers this can be a lot to handle. This ends up distracting from the more important job that we have; building and maintaining the actual application. At larger organisations this is handled by the infrastructure team and usually it is not the responsibility of the individual developer. However, the processes necessary to support this can end up slowing down development times. As you cannot just go ahead and build your application without working with the infrastructure team to help you get up and running. In Other hand we have to do a lot of things to secure the server from viruses plus cyber attacks and also we have to monitor servers 24h, it’s a painless thing for developers. As developers we’ve been looking for a solution to these problems and this is where Serverless comes in.


      What is Serverless?


      Serverless computing (or Serverless for short), is an execution model where the cloud provider (AWS, Azure, or Google Cloud) is responsible for executing a piece of code by dynamically allocating the resources. And only charging for the amount of resources used to run the code. The code is typically run inside stateless containers that can be triggered by a variety of events including http requests, database events, queuing services, monitoring alerts, file uploads, scheduled events (cron jobs), etc. The code that is sent to the cloud provider for execution is usually in the form of a function. Hence serverless is sometimes referred to as “Functions as a Service” or “FaaS”.

      laravelLampStackI1.png


      What is JAMstack ?


      A modern web development architecture based on client-side JavaScripts, reusable APIs, and prebuilt Markup It’s called JAMstack, JAM stands for JavaScript, APIs, Markup. The JAMstack is an approach to frontend web development (the construction of content and interfaces that users interact with). It allows developers to quickly create and efficiently serve static websites to users.

      A JAMstack website or application is constructed using only above three elements. The static website that the user sees is built out of HTML and CSS markup code. JavaScript is used for any necessary dynamic functionality, and for calling APIs. APIs provide the application's backend.

      uHGkEXe8lXJsmj6cZNQmIW3bpsEzn0mU9Eun.png


      JAMstack Example


      A developer builds a web application that provides updates on European football scores. He creates a backend application that runs on a server he operates and constantly checks the scores of the latest matches. When a user opens up the web application, his server generates HTML pages that display those scores, then sends those pages to the user. However, his web application is somewhat slow: before a user can view those pages, they have to wait for the backend application to run, for the HTML to be generated, and for the HTML to reach their device.

      Now suppose the developer rebuilds his entire web application using a JAMstack approach. Instead of writing an entire backend application, he creates a series of lightweight HTML pages that he stores in a CDN (content delivery network). When a user opens up the application, the CDN immediately delivers the corresponding HTML pages to the user, since the CDN is far closer to the user than the developer's server. The application also makes an API call in order to fill out the live football match scores on the page. Now the application loads very quickly for the end user, and from this perspective, there is much less need to write code that will handle the backend, server-side work of updating the scores.


      What are the main benefits of using JAMstack?


      Performance: Almost all of the content in a JAMstack application is made up of static HTML files that are served from a CDN. This is the fastest way to deliver web content to end users.

      Scalability: If an application is "scalable," that means that it responds well to large increases in usage. Because the JAMstack frontend is fast and the backend is lightweight, JAMstack applications are often extremely scalable.

      Developer experience: JAMstack enables developers to focus on building a compelling frontend user experience, without worrying about the backend or performance issues.


      Resources

      https://aws.amazon.com/blogs/compute/the-serverless-lamp-stack-part-4-building-a-serverless-laravel-application/

      https://www.freecodecamp.org/news/an-introduction-to-the-jamstack-the-architecture-of-the-modern-web-c4a0d128d9ca/

      https://www.cloudflare.com/learning/performance/what-is-jamstack/

      posted in Programming
      lkdev
      lkdev
    • RE: Ionic Framework Intro

      Thnx bro, Ionic is the best framewrok for HTML5 Hybrid mobile app development.

      posted in Hybrid App Development
      lkdev
      lkdev
    • Great Emulator for Native / Hybrid Mobile App Developers

      alt text

      ඇත්තටම මේක emulator එකකට වඩා ඔයාගෙම ෆොනේ එක emulator එකක් විදියට use කරන්න පුළුවන් කියුවොත් හරි . මේක හරිම simple case එකක් , ඔයාට app එකක් develope කරද්දී android emulator එක run කරනවා කියන්නේ machine එකේ cpu & ram usage එක high යනවා ඒ වගේම emulator ඇත්ත device එකක් වගේ නෙමේ ටිකක් slow . ඉතින් මම google search කරා මගේ phone එකේ screen එක mirror කරගන්න පුළුවන්ද කියලා computer එකට එතකොට තමා මේ opensource tool එක හම්බුනේ .

      scrcpy කියන්නේ මේ app එකේ නම . මේ app එකෙන් අපිට phone එකේ display එක control කරන්න පුළුවන් . මේක මම නම් use කරේ usb cable එක හරහා ( android usb debugging ) මේක wireless ( wifi ) හරහාත් වැඩ කරනවා කියලා github page එකේ දාලා තියෙනවා. මේ app එක use කරද්දී මට තේරුනේ ඇත්තටම phone එක use කරනවා වගේ. screen quality එක ගොඩක් හොදයි ඒ වගේම response එක පොඩ්ඩක් වත් slow නැ.

      • lightness (native, displays only the device screen)
      • performance (30~60fps)
      • quality (1920×1080 or above)
      • low latency (35~70ms)
      • low startup time (~1 second to display the first image)
      • non-intrusiveness (nothing is left installed on the device)

      මේක computer එකට install කරගත්තට පස්සේ run කරන්න ගොඩක් ලේසි terminal/CMD එක open කරලා "scrcpy" type කරලා enter කරන්න echcharai ( ඔයාගේ computer එකට android usb drivers install කරලා තියෙන්න ඕනේ ) . මේ app එක phone එකට install කරන්න එකක් නැ only computer එකට විතරයි. ( phone එකේ root permissions ඉල්ලන්නෙත් නැ).

      මේ app එකේ තියෙන features ටික

      • Capture configuration
      • Screen Recording
      • Connection ( Multi-devices, SSH tunnel)
      • Window configuration
      • Input control
      • File drop
      • Audio forwarding (Linux-only)

      App Download Link

      posted in Mobile Application Development
      lkdev
      lkdev
    • RE: What is Docker 🐋 ?

      what a nice post. thanks B6 your a amazon guy.

      posted in System & Network Configurations
      lkdev
      lkdev
    • 1 / 1