Instantly share code, notes, and snippets.

🏠
Working from home

Fahri Ali Rahman alifahrri

View GitHub Profile
View docker-cheat.md

Docker Cheat Sheet

## List Docker CLI commands
docker
docker container --help

## Display Docker version and info
docker --version
docker version
docker info
View vol-ctrl.py
from subprocess import call
from time import sleep
from datetime import datetime
import argparse
if __name__ == '__main__' :
parser = argparse.ArgumentParser(progname='python vol-ctrl.py', description='decrease volume with delay')
parser.add_argument('-i','--init',type=int,help='initial volume')
parser.add_argument('-r','--rate',type=int,help='decrease rate')
parser.add_argument('-d','--delay',type=int,help='decrease delay in seconds')
View tex-spell-check.md

interactive terminal :

aspell -t -c file.tex

list of misspelled words :

cat file.tex | aspell list -t | sort | uniq
View gif2png.md
convert -coalesce something.gif something.png

or

magick convert -coalesce something.gif something.png

the speed could be known using :

View vid2gif.md
ffmpeg -ss 61.0 -t 2.5 -i StickAround.mp4 -f gif StickAround.gif

-ss 61.0 seek to 61.0 seconds
-t 2.5 only read 2.5 then stop

ffmpeg -ss 61.0 -t 2.5 -i StickAround.mp4 -filter_complex "[0:v] fps=12,scale=480:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" SmallerStickAround.gif
View gzlog.md

playback in gui

gazebo -u -p ~/logs/double_pendulum/2016-01-25T15\:09\:49.677400/gzserver/state.log

from gazebo_ros

rosrun gazebo_ros gazebo --prefix '-u -p 2018-11-20T162127.065690/gzserver/state.log'
View roscpp-cheat.md

yaml

XmlRpc::XmlRpcValue my_list;
nh.getParam("my_list", my_list);
ROS_ASSERT(my_list.getType() == XmlRpc::XmlRpcValue::TypeArray);

for (int32_t i = 0; i < my_list.size(); ++i) 
{
  ROS_ASSERT(my_list[i].getType() == XmlRpc::XmlRpcValue::TypeDouble);
  sum += static_cast<double>(my_list[i]);
View angle-wrap.py
def norm_angle(dw) :
if math.fabs(dw) > math.pi :
return (-2*math.pi + dw) if dw > 0 else (2*math.pi + dw)
else : return dw
View cycheat.md

setup.py

from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("helloworld.pyx")
)

all *.pyx files in a folder

View rospy-cheat.md

get rospy.Time

now = rospy.Time.now()
now = rospy.get_rostime()
rospy.loginfo("Current time %i %i", now.secs, now.nsecs)

get time in seconds

now = rospy.get_time()