Skip to content

Instantly share code, notes, and snippets.

# see: https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html
LOGLEVELS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN].freeze
LOGGER = Logger.new(STDOUT)
level ||= LOGLEVELS.index ENV.fetch("LOG_LEVEL","WARN") # default to WARN index: 2
level ||= Logger::WARN # FIX default in case of environment LOG_LEVEL value is present but not correct
LOGGER.level = level
# Usage:
# before launching the program:
# $ export LOG_LEVEL=DEBUG
# PID 1 is the process that I want to observe
$ ps -p 1 -o args
COMMAND
java -Dvertx.cacheDirBase=/tmp -javaagent:/opt/jolokia/jolokia.jar=config=/opt/jolokia/etc/jolokia.properties -XX:+UseParallelGC -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRati
# best alternatives when the above method truncate the command
## alt-1
$ xargs -0 printf '%s\n' </proc/1/cmdline
java
-Dvertx.cacheDirBase=/tmp
# .1: GET API SERVERS
$ oc config view | grep server
server: https://127.0.0.1:8443
server: https://192.168.65.2:8443
server: https://192.168.99.100:8443
server: https://api.starter-us-east-1.openshift.com:443
$ oc config view | grep server | cut -f 2- -d ":"
https://127.0.0.1:8443
https://192.168.65.2:8443
> kextstat | grep -Eiv com.apple
Index Refs Address Size Wired Name (Version) UUID <Linked Against>
155 0 0xffffff7f80d26000 0x2000 0x2000 com.nvidia.CUDA (1.1.0) 4329B052-6C8A-3900-8E83-744487AEDEF1 <4 1>
156 3 0xffffff7f83a90000 0x61000 0x61000 org.virtualbox.kext.VBoxDrv (5.1.14) 08D6FFCF-2BDF-305C-8824-89E69602C30D <7 5 4 3 1>
160 0 0xffffff7f83af1000 0x14000 0x14000 com.intel.kext.intelhaxm (6.0.5) 8C4C5339-F7AA-36E5-A052-3D2E7DC6DF16 <7 5 4 3 1>
164 0 0xffffff7f83b05000 0x8000 0x8000 org.virtualbox.kext.VBoxUSB (5.1.14) BF0B350D-C893-37DF-82F0-BE86ABA49D26 <163 156 52 7 5 4 3 1>
165 0 0xffffff7f83b0d000 0x5000 0x5000 org.virtualbox.kext.VBoxNetFlt (5.1.14) 0291FFCC-8E46-3FFD-B674-BFA42D4E67E4 <156 7 5 4 3 1>
166 0 0xffffff7f83b12000 0x6000 0x6000 org.virtualbox.kext.VBoxNetAdp (5.1.14) EFBEE858-A3D7-3C61-86C0-F6AFDCA48229 <156 5 4 1>
$ rvm list
rvm rubies
jruby-9.1.5.0 [ x86_64 ]
=* ruby-2.3.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
bitnami@linux ~/projects/so-test/ruby-rio
06:34:45 $ irb
2.3.2 :001 > require 'rio'
=> true
2.3.2 :002 > rio('nice.jpg').binmode < rio('http://farm4.static.flickr.com/3134/3160515898_59354c9733.jpg?v=0')
=> #<Rio:0xe28524:"nice.jpg" (Stream::Reset)>
2.3.2 :003 > exit
bitnami@linux ~/projects/so-test/ruby-rio
06:35:39 $ ls -lrt nice.jpg
-rw-rw-r-- 1 bitnami bitnami 199369 Nov 19 06:35 nice.jpg
#!/usr/bin/env bash
name=ronda
ruby -e "(-12..42).each { |i| print \"#{i}:\"; o=''; ARGV[0].each_byte { |x| o+=(x.ord-i).chr }; p o}" $name | grep 32 | sed "s/.*:\"\(.*\).$/\1/"
@rondinif
rondinif / meteor's mongodb README.md
Last active February 6, 2016 09:28
meteor's mongodb
welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-36-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Last login: Sat Feb  6 04:52:13 2016 from 192.168.56.1
  bitnami@linux ~  
 05:03:01 $ ps aux | grep 'mongod'
bitnami  11224  1.6  1.0 634572 39284 pts/1    Sl+  05:01   0:01 /home/bitnami/.meteor/packages/meteor-tool/.1.1.10.ki0ccv++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/mongodb/bin/mongod --bind_ip 127.0.0.1 --smallfiles --port 3001 --dbpath /home/bitnami/projects/coursera/meteor-development/dev/image_share/.meteor/local/db --oplogSize 8 --replSet meteor
bitnami  11311  0.0  0.0  10464   896 pts/2    S+   05:03   0:00 grep mongod
  bitnami@linux ~  
student=1
topic=DownloadBoundServiceAsync
gdsrc=~/projects/coursera/posa-002/POSA-14-20140706/grading-drivers/week-8-assignment-7/W8-A7-ThreadedDownloads-BoundServices/src/edu/vuum/mocca/$topic.java
peer_assesment=./peer-assessments/week8/s$student/$topic.java
tmp_peer_assesment=./tmp/$topic.java
awk '{ sub(/\r$/,""); print }' < $peer_assesment > $tmp_peer_assesment
opendiff $gdsrc $tmp_peer_assesment
@rondinif
rondinif / gist:9876953
Created March 30, 2014 17:59
Some CVS transformation in Ruby
> cat workfile.csv | ruby -rcsv -ne '
row = CSV.parse_line($_)
puts CSV.generate_line(row, {col_sep: ";" })
' > work1.csv
> cat workfile.csv | ruby -rcsv -ne '
row = CSV.parse_line($_)
row.each {|elem| elem.tr!(",.",".,") if elem.match(/^-?[0-9,.]+$/)}
puts CSV.generate_line(row, {col_sep: ";" })