List of helpful shortcuts for faster coding
If you have any other helpful shortcuts, feel free to add in the comments of this gist :)
#!/bin/bash | |
#Please note - This script tested on Centos-6,7/Redhat-6,7. | |
#Check Internet Connection | |
IS=`/bin/ping -c 5 4.2.2.2 | grep -c "64 bytes"` | |
if (test "$IS" -gt "2") then | |
internet_conn="1" | |
#Check Gdrive Software Install Or Not | |
file="/usr/bin/gdrive" | |
if [ -f "$file" ] | |
then |
Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".
Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).
Let's dig in:
package main | |
import ( | |
"fmt" | |
"net/http" | |
"sort" | |
"time" | |
) | |
// a struct to hold the result from each request including an index |