{"id":108,"date":"2014-05-26T15:20:25","date_gmt":"2014-05-26T14:20:25","guid":{"rendered":"http:\/\/code.sualdea.com\/?page_id=108"},"modified":"2020-02-14T03:51:24","modified_gmt":"2020-02-14T02:51:24","slug":"quick-notes","status":"publish","type":"page","link":"https:\/\/code.sualdea.com\/?page_id=108","title":{"rendered":"[ snippets and notes ]"},"content":{"rendered":"<h3>convert a video to standard avi format<\/h3>\n<pre><code>ffmpeg -i input.mkv -vcodec mpeg4 -b 4000k -acodec mp2 -ab 320k output.avi<br \/>\n<\/code><\/pre>\n<h3>extract audio from video using ffmpeg<\/h3>\n<pre><code>ffmpeg -i video.avi -q:a 0 -map a audio.mp3<br \/>\n<\/code><\/pre>\n<h3>add time to bash prompt<\/h3>\n<pre><code>export PS1=\"\\e[0;31m$(date +%H:%M:%S) ${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[01;34m\\] \\w \\$\\[\\033[00m\\] \"<br \/>\n<\/code><\/pre>\n<h3>create keys for a ssh session<\/h3>\n<pre>from the client machine and user<br \/><code><br \/>\nssh-keygen -t rsa -P \"\" -f ~\/.ssh\/id_rsa<br \/>\ncat ~\/.ssh\/id_rsa.pub &gt;&gt; ~\/.ssh\/authorized_keys<br \/>\nssh-copy-id -i \/home\/user\/.ssh\/id_rsa.pub user@host<br \/>\nssh user@host<br \/>\n<\/code><\/pre>\n<h3>bash, convert space delimited string into array<\/h3>\n<p><code><br \/>\narr=($line)<br \/>\necho ${arr[2]}<br \/>\n<\/code><\/p>\n<p>\u00a0<\/p>\n<h3>ccmake release with debug info<\/h3>\n<pre>RelWithDebInfo<\/pre>\n<h3>eclipse indexer does not find std::shared_ptr<\/h3>\n<p>Right click your project and click Properties<br \/>Under C\/C++ General click &#8220;Preprocessor Include Paths, Macros&#8221;<br \/>Select the Providers tab<br \/>There should be an item in the list that says something like &#8220;GCC Built in Compiler Settings&#8221;. Select this entry.<br \/>Uncheck the &#8220;Use global provider&#8230;&#8221; option<br \/>Under the list there&#8217;s an box that says &#8220;Command to get compiler specs.&#8221; Append &#8220;-std=c++0x&#8221; to this.<br \/>Move the &#8220;GCC Built in Compiler Settings&#8221; provider at the top of the list using the &#8216;Move Up&#8217; button on the right.<br \/>Click Apply and then OK.<br \/>Back in your Eclipse workspace, select the Project Menu, C\/C++ Index, and click &#8220;Re-resolve unresolved includes.&#8221;<\/p>\n<p>from <a href=\"http:\/\/stackoverflow.com\/questions\/17457069\/enabling-c11-in-eclipse-juno-kepler-luna-cdt\">stackoverflow<\/a><\/p>\n<h3>linux clean cache disk<\/h3>\n<p><code>sync ; sudo sh -c 'echo 3 &gt; \/proc\/sys\/vm\/drop_caches'<\/code><\/p>\n<h3>linux disable paste on middle mouse button<\/h3>\n<p><code># disable middle button<br \/>\nxmodmap -e \"pointer = 1 0 3 4 5\"<\/code><\/p>\n<h3>sudo withno password for a user<\/h3>\n<p><b>in the last line<\/b> of \/etc\/sudoers<br \/><code>user ALL=(ALL) NOPASSWD: ALL<\/code><\/p>\n<h3>compiling in ubuntu<\/h3>\n<pre>\/usr\/bin\/ld: cannot find crt1.o: No such file or directory<\/pre>\n<p><code>sudo ln -s \/usr\/lib\/x86_64-linux-gnu \/usr\/lib64<\/code><\/p>\n<h3>get parts of filenames with bash<\/h3>\n<p>A file named (for example) \/etc\/ntp.conf<br \/><code><br \/>\nsh#fname=\"etc\/ntp.conf\"<br \/>\nsh#echo ${fname%%.*}<br \/>\n\/etc\/ntp<br \/>\nsh#basename $fname<br \/>\nntp.conf<br \/>\nsh#basename ${fname%%.*}<br \/>\nntp<br \/>\nsh#dirname $fname<br \/>\n\/etc<br \/>\nsh#echo ${fname##*.}<br \/>\nconf<br \/>\n<\/code><\/p>\n<table>\n<tbody>\n<tr>\n<td>echo ${fname%%.*}<\/td>\n<td>\/etc\/ntp<\/td>\n<\/tr>\n<tr>\n<td>basename $fname<\/td>\n<td>ntp.conf<\/td>\n<\/tr>\n<tr>\n<td>basename ${fname%%.*}<\/td>\n<td>ntp<\/td>\n<\/tr>\n<tr>\n<td>dirname $fname<\/td>\n<td>\/etc<\/td>\n<\/tr>\n<tr>\n<td>echo ${fname##*.}<\/td>\n<td>conf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>disable buffering in stdout for shell | pipes<\/h3>\n<p>To disable completely<br \/><code>stdbuf -i0 -o0 -e0 command<\/code><br \/>To do it for line (faster)<br \/><code>stdbuf -oL -eL command<\/code><br \/>from <a href=\"http:\/\/unix.stackexchange.com\/questions\/25372\/turn-off-buffering-in-pipe\" target=\"_blank\" rel=\"noopener noreferrer\">stackoverflow<\/a><\/p>\n<h3>when gdb fails to set an exception raise event &#8230;<\/h3>\n<p>And says<br \/><code>breakpoint.c:5997: internal-error: print_one_breakpoint_location: Assertion `b-&gt;loc == NULL || b-&gt;loc-&gt;next == NULL' failed.<\/code><br \/>use function breakpoint on __cxa_throw<br \/><code>break __cxa_throw<\/code><\/p>\n<h3>gdb for everyone in ubuntu<\/h3>\n<p>open <strong>\/etc\/sysctl.d\/10-ptrace.conf<\/strong> and set <strong>kernel.yama.ptrace_scope = 0<\/strong><\/p>\n<p>or<\/p>\n<p><code># echo 0 &gt; \/proc\/sys\/kernel\/yama\/ptrace_scope<\/code><\/p>\n<h3>Error : \/bin\/rm: Argument list too long<\/h3>\n<p>Alternative:<br \/><code>find \/path\/to\/files -name \"*\" | xargs rm<\/code><\/p>\n<h3>get part of file using tail and head<\/h3>\n<pre><code><br \/>\n#start line<br \/>\nstart=10<br \/>\n#how many lines to show<br \/>\npage=5<br \/>\nhead -n $(($start + $page)) filename | tail -n $page<br \/>\n<\/code><\/pre>\n<h3>grep xml files with xpath<\/h3>\n<pre>Use <a href=\"http:\/\/wohlberg.net\/public\/software\/xml\/xgrep\/\">xgrep <\/a><br \/><code><br \/>\necho 'hola'| xgrep -x '\/root\/value\/text()'<br \/>\n<\/code><\/pre>\n<h3>ping all hosts in a ipv4 C network<\/h3>\n<p>Sends pings to 1-254 addresses simultaneously<\/p>\n<pre><code>#!\/bin\/bash<\/code><br \/>if [ \"$1\" == \"\" ]; then<br \/>echo \"$ping all hosts in a ipv4 C network0 C network\"<br \/>echo example: $0 192.168.1<br \/>exit<br \/>fi<br \/>function ping_to_server {<br \/>ip=$1<br \/>ping -c 2 $1 &gt; \/dev\/null 2&gt;&amp;1<br \/>if [ $? -eq 0 ]; then<br \/>echo \"$ip alive\";<br \/>fi<br \/>}<br \/><code><\/code><\/pre>\n<pre><code>for a in $(seq 1 254); do<br \/>   ping_to_server $1.$a &amp;<br \/>done<br \/><\/code><br \/><br \/>example use:<br \/><code><br \/>\nalex@paco ~ $ bash ping.sh 192.168.1<br \/>\nalex@paco ~ $ 192.168.1.39 alive<br \/>\n192.168.1.1 alive<br \/>\n192.168.1.35 alive<br \/>\n192.168.1.250 alive<br \/>\n192.168.1.34 alive<br \/>\n<\/code><\/pre>\n<p><code><code><\/code><\/code><\/p>\n<h3>little shellscript to sync two folders automatically<\/h3>\n<pre><code><br \/>\n#!\/bin\/bash<br \/><\/code>if [ \"$(which inotifywait)\" == \"\" ]; then<br \/>echo \"inotify-tools package needed, please install it.\"<br \/>exit<br \/>fi<br \/>if [ \"$1\" == \"\" ] || [ \"$2\" == \"\" ]; then<br \/>echo \"help: $0 source_folder destination_folder\";<br \/>exit<br \/>fi<br \/>source=$1<br \/>destination=$2<br \/>while inotifywait -r -e modify,create,delete \"$source\"; do<br \/>rsync -avz \"$source\" \"$destination\"<br \/>done<\/pre>\n<p><code>\n<\/code><\/p>\n<p><code><\/code><\/p>\n<h3>linux touchscreen rotation<\/h3>\n<pre><code><br \/>\n    # for asus T101ha is right , device 13<br \/>\n    normal)<br \/>\n      xinput set-prop 13 \"Coordinate Transformation Matrix\" 1 0 0 0 1 0 0 0 1<br \/>\n      ;;<br \/>\n    inverted)<br \/>\n      xinput set-prop 13 \"Coordinate Transformation Matrix\" -1 0 1 0 -1 1 0 0 1<br \/>\n      ;;<br \/>\n    left)<br \/>\n      xinput set-prop 13 \"Coordinate Transformation Matrix\" 0 -1 1 1 0 0 0 0 1<br \/>\n      ;;<br \/>\n    right)<br \/>\n      xinput set-prop 13 \"Coordinate Transformation Matrix\" 0 1 0 -1 0 1 0 0 1<\/code><\/pre>\n<h3><code>\n<\/code>get windows license key<\/h3>\n<p>Using admin CMD:<\/p>\n<pre>wmic path SoftwareLicensingService get OA3xOriginalProductKey<\/pre>\n<p>\u00a0<\/p>\n<p><code><\/code><\/p>\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>convert a video to standard avi format ffmpeg -i input.mkv -vcodec mpeg4 -b 4000k -acodec mp2 -ab 320k output.avi extract audio from video using ffmpeg ffmpeg -i video.avi -q:a 0 -map a audio.mp3 add time to bash prompt export PS1=&#8221;\\e[0;31m$(date +%H:%M:%S) ${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[01;34m\\] \\w \\$\\[\\033[00m\\] &#8221; create keys for a ssh session from the client machine &hellip; <a href=\"https:\/\/code.sualdea.com\/?page_id=108\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">[ snippets and notes ]<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-108","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/code.sualdea.com\/index.php?rest_route=\/wp\/v2\/pages\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.sualdea.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/code.sualdea.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/code.sualdea.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code.sualdea.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=108"}],"version-history":[{"count":42,"href":"https:\/\/code.sualdea.com\/index.php?rest_route=\/wp\/v2\/pages\/108\/revisions"}],"predecessor-version":[{"id":304,"href":"https:\/\/code.sualdea.com\/index.php?rest_route=\/wp\/v2\/pages\/108\/revisions\/304"}],"wp:attachment":[{"href":"https:\/\/code.sualdea.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}