George Opritescu

Developer from somewhere

convert dot file to png

Problem: have a dot file I’d like to view as a png.

Solution: found here

  • install graphviz
brew install graphviz
  • generate png:
dot -Tpng DocName.dot -o DocName.png
Read More

kotlin data class spring default constructor

Problem: data class generated by kotlin does not have a no arg constructor.

Solution: Solution found here. Add kotlin-noarg to build.gradle ( change if using other versions, more lines than needed are shown for context ) :

buildscript {
    ext {
        kotlinVersion = '1.1.4-3'
        springBootVersion = '2.0.0.M3'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-noarg:${kotlinVersion}")
    }
}

...

apply plugin: "kotlin-jpa"
Read More

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