VIM: Hide hidden files from NERDTree

This is how to hide .git (.swp .bak .tmp) folder from VIM NerdTree :

let NERDTreeShowHidden=1

or use this way to toggle those hidden files and folders

Press Shift+i when in the NerdTree window

Advertisements

Golang Web: Setting Up GIN Framework with Pongo2 template engine on GAE Standard env

What Is Gin

Gin is a web framework written in Golang. It features a martini-like API with much better performance, up to 40 times faster. If you need performance and good productivity, you will love Gin.

What Is Pongo

Pongo is a well-tested template engine which implements a Django template like syntax and pongo2 is the successor of pongo, a Django-syntax like templating-language.

For Pongo documentation on how the templating language works you can head over to the Django documentation. pongo2 aims to be compatible with it (link).

Ok then. let’s start the journey

Installing GIN

go get github.com/gin-gonic/gin

go get github.com/gin-gonic/gin

Installing Pongo2

go get -u github.com/flosch/pongo2 go get -u github.com/flosch/pongo2

Install robvdl/pongo2gin

Package pongo2gin is a template renderer that can be used with the Gin web framework gin-gonic/gin it uses the Pongo2 template library flosch/pongo2 to use pongo2gin you need to set your router.HTMLRenderer to a new renderer instance, this is done after creating the Gin router when the Gin application starts up. You can use pongo2gin.Default() to create a new renderer with default options, this assumes templates will be located in the “templates” directory, or you can use pongo2.New() to specify a custom location.To render templates from a route, call c.HTML just as you would with regular Gin templates, the only difference is that you pass template data as a pongo2.Context instead of gin.H type.

Create app.yml

  runtime: go
  api_version: go1 
  
  handlers:
  - url: /.* 
    script: _go_app
    secure: always
    redirect_http_response_code: 301 

Create main.go

 package main

  import (
      "net/http"

      "github.com/flosch/pongo2"
      "github.com/gin-gonic/gin"
      "github.com/robvdl/pongo2gin"
  )

  func init() {
      r := gin.Default()

      r.HTMLRender = pongo2gin.Default()

      r.LoadHTMLGlob("templates/*.html")

      r.GET("/", func(c *gin.Context) {
          c.HTML(http.StatusOK, "main.html", pongo2.Context{
              "title":    "Hello world !",
              "greating": "Hi, Hello world my mate!",
          })
      })

      http.Handle("/", r)
  }

Create templates/main.html

  <html>
      <head>
          <title>
              {{ .title }}
          </title>
      </head>
      <body>
          {{ .greating }}
      </body>
    
  </html>

Run App engine development server

dev_appserver.py –port=9999 ./The result

Deployment to GAE using gcloud command

gcloud app deploy –verbosity=info

The Final Result On Browser

50.result

Resources: link1

Golang Common Error: missing ‘,’ before newline in composite literal

This is my previous (error) code:

r.GET("/", func(c *gin.Context) {
          c.HTML(http.StatusOK, "main.html", pongo2.Context{
              "title":    "Hello world !",
              "greating": "Hi, Hello world my mate!"
          })
      })  

And here is the changes:

r.GET("/", func(c *gin.Context) {
          c.HTML(http.StatusOK, "main.html", pongo2.Context{
              "title":    "Hello world !",
              "greating": "Hi, Hello world my mate!",
          })
      })

can you find the different ? no ? here is the mitsake:

“greating”: “Hi, Hello world my mate!”,

Yeah the error is because of missing a comma LOL

Using Git Rebase to Squash Commits

A Git command that can be very useful, yet is often overlooked by beginners (such as myself) is the rebase command. I admit to not fully understanding all of its uses, but there is one simple use for it that I have found myself taking advantage of lately. Here’s the scenario:

You have a remote Git repository, perhaps hosted at GitHub. You want to work on a new feature, so you create a local branch on your machine:

git checkout -b newBranch

You make some changes and commit them to the local branch:

git commit -a -m”My first set of changes”

You make some more changes and commit them to the local branch:

git commit -a -m”My second set of changes”

You make some more changes and commit them to the local branch:

git commit -a -m”My third set of changes”
You now have three separate commits that relate to one feature, and the feature is complete. You could simply push the changes to your remote, but then you’d end up with three commits on the remote that are not particularly meaningful. The only reason you have three commits in your local repo is that you completed the work in three steps. Perhaps you’d rather have just one commit reported in the remote repo for this feature. Thankfully git rebase allows you to do that very simply.
If you issue a git log command, you’ll see something similar to this:
git-log1

 

I can see from this that I have three commits corresponding to the changes that I made for the feature. To squash these three commits into one, and specify a commit message for the group, I can use git rebase, with the -i (which stands for interactive), argument:

git rebase -i HEAD~3

The HEAD~3 tells git that I want to rebase the past three commits.

This will pop open my text editor, which I have configured to be TextMate, with some rebasing instructions. The file will look something like this:

git-rebase-2

This is quite convenient as git actually provides you with some instructions. I want to combine the second and third commit with the first, so I edit the file to look like this:

git-rebase-3

When I save and close the file, git will pop open another file in the editor to edit our commit message:

git-rebase-4

From here I can either choose to accept the three individual commit messages that were picked up from our three commits, or I can remove them (or comment them out) and provide our own commit message. I’m going to remove the original commit messages and replace them with a single one that reads “A bunch of changes to support new feature A”. When I save and close this file I’ll be back at the command line with a message similar to this:

git-rebase-5

Now when I issue the git log command again, I’ll see my previous three commits squashed into one:

git-rebase-6.jpg

It’s as simple as that. Now you do need to be careful using the rebase command with remotes when you are collaborating with others. You should avoid rebasing commits that have already been pushed to a remote. There is also a lot more to rebasing than this simple example, but it’s not a bad place to start. Happy rebasing!

 

Source: link  (link dead)

  • Squash commits to one commit
  • Combine commits to one commit
  • Merge git commits to one commit

Let’s Encrypt on Google App Engine

Let’s Encrypt is free automated, and open certificate authority brought to you by the non-profit Internet Security Research Group (ISRG). it is a pretty awesome initiative to provide free SSL certificates to make creating a secure website easier.

 

Let’s Encrypt is a free, automated, and open Certificate Authority.

Here’s how to use it with App Engine. I used Google Cloud Shell to run these commands.

1.Download letsecrypt script  client using git clone:

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt

so you will have folder containing files like this:

1-clone

2.Generate certificate using letsencrypt:

sudo ./letsencrypt-auto -a manual certonly

3.Challenge and response verification the ownership of your domain.

You’ll see something like this on your console terminal:

mhyusufibrahim@myproject-999999:~/letsencrypt$ sudo ./letsencrypt-auto -a manual certonlySaving debug log to /var/log/letsencrypt/letsencrypt.log

Please enter in your domain name(s) (comma and/or space separated) (Enter ‘c’ to cancel): http://www.mydomain.com

Obtaining a new certificate Performing the following challenges: http-01 challenge for  http://www.mydomain.com

3.revisi

NOTE: The IP of this machine will be publicly logged as having requested this certificate. If you’re running certbot in manual mode on a machine that is not your server, please ensure you’re okay with that. Are you OK with your IP being logged?

(Y)es/(N)o: Y

Make sure your web server displays the following content at

http://www.mydomain.com/.well-known/acme-challenge/nuHnBaCxYzkvcUQkOEjLhpYgY_umLjdCr4gRkby1YCM

before continuing:

nuHnBaCxYzkvcUQkOEjLhpYgY_umLjdCr4gRkby1YCM.qvOvSw_BDrdsxvw_X_ce5IgulKkYBS4BMWrUiaqY4iY

If you don’t have HTTP server configured, you can run the following command on the target server (as root): mkdir -p /tmp/certbot/public_html/.well-known/acme-challenge cd /tmp/certbot/public_html printf “%s” nuHnBaCxYzkvcUQkOEjLhpYgY_umLjdCr4gRkby1YCM.qvOvSw_BDrdsxvw_X_ce5IgulKkYBS4BMWrUiaqY4iY > .well-known/acme-challenge/nuHnBaCxYzkvcUQkOEjLhpYgY_umLjdCr4gRkby1YCM # run only once per server: $(command -v python2 || command -v python2.7 || command -v python2.6) -c \ “import BaseHTTPServer, SimpleHTTPServer; \ s = BaseHTTPServer.HTTPServer((”, 80), SimpleHTTPServer.SimpleHTTPRequestHandler); \ s.serve_forever()” ——————————————————————————-

Press Enter to – NOTE: The IP of this machine will be publicly logged as having requested this certificate. If you’re running certbot in manual mode on a machine that is not your server, please ensure you’re okay with that. Are you OK with your IP being logged?

(Y)es/(N)o: y

Press Enter to Continue

Waiting for verification…Cleaning up challenges

IMPORTANT NOTES: – Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/http://www.mydomain.com/fullchain.pem. Your cert will expire on 2017-09-26. To obtain a new or tweaked version of this certificate in the future, simply run letsencrypt-auto again. To non-interactively renew *all* of your certificates, run “letsencrypt-auto renew” – If you like Certbot, please consider supporting our work by: Donating to ISRG / Let’s Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le

3.Get your private key.

sudo openssl rsa -inform pem -in /etc/letsencrypt/live/www.mydomain.com/privkey.pem -outform pem | less

5.rsaprivkey

4.Get your public key certificate.

sudo less /etc/letsencrypt/live/http://www.mydomain.com/fullchain.pem

6.pubkey.png
Don’t forget to press enter to scroll down the text

 

Keep in mind that /etc/letsencrypt is not persisted through Cloud Shell restarts, so if you need to keep your private key, you can copy it to your home directory or save it.

5.Upload the certificate to the Google Cloud.

App Engine -> Settings -> SSL Certificate

8.webINterface

10.uploadcert

11.savecert12.savedCert

The final result

15.result.png

Installing and Unistalling SpaceVim / SpaceVim on UBuntu Linux (Or just Linux in General)

I just Installed /SpaceVim on my Ubuntu 14.04 Laptop but I realized that It was wrong because my VIM IDE turned to unfamiliar IDE for me, and the worse case was my previous setting and configurations in my .vimrc are no longer working.

Here is the SpaceVim installation step:

curl -sLf https://spacevim.org/install.sh | bash

spacevim

Installation result (Open the VIM first), beautiful but I think it’s better to use it later…

spacevim100

And here is how to uninstall / remove  SpaceVim from your LInux Computer:

curl -sLf https://spacevim.org/install.sh | bash -s — uninstall

remove-spaceVIM

Finally I get my standard VIM back…

myvim1.png

Laravel PHPUnit: Check form submit redirection

I just made a Laravel  UnitTest to test and make sure that my create function is working and redirects user to the right url after form post submitted , this is how I make it work:


public function testSurveysCreateSuccess()
    {
        $form = [
            'name' => 'New Survey',
            'type' => 'Lecturer',
            'description' => 'It\'s a text'
        ];

        $url =  '/admin/courses/'.$this->course->id.'/surveys';

        $response = $this->actingAs($this->user)->call('POST', $url, $form);
        $this->assertEquals(302, $response->status());
        $redirect_to = $response->getTargetUrl();

        $this->assertEquals($redirect_to, $this->baseUrl.$url);
    }

Cara pengajuan kepemilikan kartu kredit Bank

Kepemilikan kartu kredit saat ini sudah tidak dapat lagi dihindari terutama untuk mereka yang bekerja dan berbisnis menggunakan teknologi berbasis teknologi informasi komputer, kebutuhan kartu kredit mulai dari membayar tagihan server, cloud hosting hingga membayar berbagai layanan online dan offline banyak yang mensyaratkan penggunaan kartu kredit sebagai sarana pembayaran yang disarankan (atau kadang satu-satunya layanan pembayaran yang ditawarkan).

Mungkin beberapa orang belum faham bagaimana cara mengajukan kepemilikan kartu kredit ke Bank yang ada di Indonesia, cara termudah untuk mendapatkan kepemilikan kartu kredit adalah dengan menghubingi marketing kartu kredit yang telah berpengalaman untuk mengurus pengajuan kartu kredit dan tentunya dapat membantu anda dalam menyiapkan berbagai persayaratan dan juga memberikan anda masukan bagaimana dan apa yang harus dikatakan kepada surveyor kartu-kredit bila nanti mereka menelpon maupun mendatangi kantor dan rumah anda.

Berikut persyaratan dan informasi umum yang diminta oleh Bank dalam mengajukan kepemilikan kartu-kredit oleh karyawan:

  • KTP
  • NPWP
  • No HP yang aktif
  • No Kantor
  • No Keluarga yang tidak serumah
  • Nama lengkap Ibu kandung
  • Pendidikan terakhir
  • Status kepemilikan rumah
  • Alamat tempat tinggal (Alamat bila berbeda sesuai KTP)
  • Lama menempati rumah tersebut
  • Alamat Kantor
  • No Telp Kantor
  • Slip Gaji Tiga bulan terakhir
  • Posisi di perusahaan
  • Lama bekerja diperusahaan (Biasanya min 2 tahun)

Tips Pengajuan kartu kredit

  • Untuk no keluarga yang tidak serumah pastikan mereka diberitahu bila akan dihubungi oleh Bank terkait pengajuan Kartu kredit anda.
  • Pastikan anda sudah bekerja minimun lebih dari 2 tahun untuk kantor current company.
  • Gaji diatas 4 Juta.
  • Selalu ada orang dirumah dan di kantor supaya ada yang menjawab pertanyaan-pertanyaan surveyor kartu kredit yang datang ke rumah maupun untuk menjawab telepon.

 

 

Bank Tempat Penukaran Uang ke Pecahan Kecil Recehan untuk Lebaran

Saat mendekati lebaran biasanya tempat penukaran uang recehan ramai dipenuhi masyarakat yang ingin menukarkan uangnya ke pecahan kecil misalnya pecahan 1000, 2000, 5000, 10000, nah opsi yang paling mudah adalah dengan menggunakan jasa penukaran uang dipinggir jalan, hanya saja penukaran uang recehan dipinggir jalan tentunya tentunya uang yang kita tukarkan bukan senilai yang kita berikan, misal uang 100rb paling kalo di tukar hanya cair 90rb atau 95rb saja.

pernukaran uang

 

Kebetulah hari ini saya juga berniat menukarkan uang ke nominal kecil/receh setelah melakukan googling dan tanya sana sini akhirnya saya tahu bahwa Bank BI sudah menunjuk beberapa Bank untuk melayani penukaran uang ke nominal kecil

Nah supaya lebih irit dan tidak kehilangan sejumlah nilai uang saat di tukarkan ada baiknya kita pergi ke Bank saja untuk menukarkan uang kita dengan uang recehan, adapun bank-bank umum yang melayani penukaran uang pecahan kecil / receh adalah sebagai berikut:

Menukarkan uang di Bank Umum

  • Bank Mestika,
  • Bank BCA,
  • Bank Mandiri,
  • Bank Sumut,
  • Bank BNI,
  • Bank Mega,
  • Bank BRI,
  • Bank Permata,
  • Bank Danamon,
  • Bank CIMB Niaga,
  • Bank Mandiri Syariah,
  • Bank BRI Syariah,
  • Bank BNI Syariah,
  • Bank Maybank,
  • Bank Muamalat.

Menukarkan Uang di BPR, Selain 15 bank umum itu, BI juga bekerja sama dengan 14 Bank Perkreditan Rakyat (BPR) untuk melayani penukaran uang pecahan kecil kebutuhan Ramadan dan Lebaran. Ke 14 BPR itu yakni :

  • BPR Disky Surya Jaya,
  • BPR Duta Paramarta,
  • BPR Guna Rakyat,
  • BPR Hombar Makmur,
  • BPR Karyabhakti Ugahari,
  • BPR Laksana Abadi Sunggal,
  • BPR Mitra Sumber Makmur,
  • BPR Milala, BPR NBP13,
  • BPR NBP18,
  • BPR NBP22,
  • BPR NBP25,
  • BPR Prima Madani,
  • BPR Prima Tata Patumbak.

Maksimum penukaran uang per-hari:

“Tiap-tiap masyarakat per harinya dapat menukarkan uang pecahan kecil dengan nilai Rp.3.250.000,”

Demikian Bank-bank umum dan BPR yang bisa digunakan sebagai pilihan kita menukarkan uang, semoga bermanfaat dan selamat berpuasa…