Skip to content

Instantly share code, notes, and snippets.

Docker basics commands:
ii) stop a container:
$ docker stop <container_name>
a) to stop and remove container
$ docker rm -f <container_id>
iii) attach to a running container:
$ docker exec -it <container_ID> bash
above bash is saying that i have to connect to terminal
iv) check running docker processes:
$ docker ps
#!/bin/bash
isPsRunning=0
## iterating 'ps' command output for watch_mongo_n_monitor_proc_scheduler.py
#ps aux | grep watch_mongo_n_monitor_proc_scheduler.py | while read line; do
while read line; do
## checking if 'python3 watch_mongo_n_monitor_proc_scheduler.py' is in 'line' variable
if [[ $line == *"python3 /usr/local/src/python_scripts/live_stream_app/watch_mongo_n_monitor_proc_scheduler.py"* ]]; then
echo "It's there!"
@sham-hq
sham-hq / setup_monit_with_port
Created October 28, 2017 16:24
steps to setup monit for application port
Monitor in Monit with web-app port:
First made a script which will check port is used or not using netstat command. filename is: check-netstat-5000.sh
#!/bin/bash
output=`netstat -ntlp | grep 5000`
if [ -z "$output" ]
then
@sham-hq
sham-hq / kill_java_process.sh
Created October 28, 2017 16:09
bash script to kill previously running java process using jps command
#!/bin/bash
# below JavaApp is the name of running Java process
pids=( $(jps | grep JavaApp | awk '{print $1}') )
for pid in "${pids[@]}"; do
echo "killing $pid"
kill -9 $pid
done
@sham-hq
sham-hq / ga_realtime_page_views.py
Created October 23, 2017 12:51
python script to get realtime active users count from Google Analytics
"""
NOTE: client_secrets.json given by GA will be in same directory as this file
Steps are:
1. Get GA count for now at every 5 seconds.
2. compare count with previous count
3. If current count is greater than previous count then override previous count with current count
4. Save also time of greater count
5. at every 12 hours shoot a mail saying max count for last 12 hours with the time of max count
"""
@sham-hq
sham-hq / rename_copy_file.sh
Created September 8, 2017 09:46
script to find file with .log extension then rename them from there directory name, then copy them to a new location
#!/bin/bash
files=`find . -name "*.log"`
for word in $files
do
echo $word
# below splitting file-path with slash(/) and store it in fileArr
IFS=/ read -a fileArr <<< $word
#echo ${fileArr[4]}
@sham-hq
sham-hq / find_and_unzip.sh
Created September 8, 2017 09:41
find some file then run unzip on each return file
#!/bin/bash
find . -name "*.zip" | xargs -n1 unzip

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter