George Opritescu

Developer from somewhere

linx #16

Interesting links:

Read More

linx #15

Interesting links:

  • gops - A tool to list and diagnose Go processes currently running on your system
Read More

osx capture output of running process

Problem: want to capture output of an already running process

Solution: found here

capture() {
    sudo dtrace -p "$1" -qn '
        syscall::write*:entry
        /pid == $target && arg0 == 1/ {
            printf("%s", copyinstr(arg1, arg2));
        }
    '
}

after, run:

  • save above code in capture.sh
  • source capture.sh
  • capture PID
Read More

facebook flow comment types

Problem: you want to add flow, but you don’t want to complicate your build process.

Solution: use comment types.

const myInt /*: number */ = 10;
const someFnc = (param /*: number */) => {
  // do something
}
Read More

python SimpleHTTPServer ssl

Problem: wanted to serve some assets over https using SimpleHTTPServer.

Solution: used info from here and here

  • following snippet combines both of those links:
import BaseHTTPServer, SimpleHTTPServer
import ssl

httpd = BaseHTTPServer.HTTPServer(('localhost', 8090), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='~/ssl/server.crt', 
  keyfile='~/ssl/server.key', server_side=True)
httpd.serve_forever()
Read More

spring kotlin Your ApplicationContext is unlikely to start

Problem: started a kotlin spring app. Received this message: Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package. Problem is described here as well.

Solution:

  • move files out of the default package, to a named one.
Read More

find program using port

Problem: find which process is using a specific port.

Solution: found here

lsof -i :8080 | grep LISTEN
Read More

add hours to a datetime object

Problem: want to add hours to a datetime object

Solution: use timedelta

from datetime import datetime, timedelta
print datetime.now() + timedelta(hours=5)
Read More

simple sorting of csv lines via python and pandas

Problem: have a file containing a lot of csv entries that I’d like to sort via a specific column ( published, in my case )

Solution: use pandas:

import pandas as pd
df = pd.read_csv("input.csv")
df.sort_values("published",ascending=False).to_csv('input-sorted.csv', index = False)
Read More

bash run command until status code is not zero

Problem: want to run a command until the exit code is not zero

Solution: found here

while ./runtest; do :; done
Read More