linx #16
Interesting links:
- what to do if you get a black screen when booting your mac - happened to me today. The tip with Shift+Control+Option+Power was what I needed.
 
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
 
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
}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()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.
 
find program using port
Problem: find which process is using a specific port.
Solution: found here
lsof -i :8080 | grep LISTENadd 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)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)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