Skip to content

Instantly share code, notes, and snippets.

View tuannvm's full-sized avatar
🎯
Focusing

Tommy Nguyen tuannvm

🎯
Focusing
View GitHub Profile
var output = fs.createWriteStream('/where/to/save'+filename);
    output.write(buffer);
    output.end();
@tuannvm
tuannvm / plan.txt
Last active January 27, 2016 23:46
postgre 9.1 to 9.4
#### For Dev1 first ####
#### announce an 30 mins maintenance ####
####backup postgre 9.1 db (about 10 mins)########
su - postgres
pg_dumpall > <backup-db>.sql
####install postgre 9.4 (about 1 mins)####
wget http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-2.noarch.rpm
@tuannvm
tuannvm / Ansible cheatsheet.md
Last active July 1, 2017 01:03 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options

Ansible cheatsheet

@tuannvm
tuannvm / git-cheatsheet.md
Last active July 29, 2019 09:11
#git #cheatsheet
@tuannvm
tuannvm / Docker cheatsheet.md
Last active July 4, 2017 04:30
Docker cheatsheet

Everything about Docker!

- Receive feed: test1.vivatv.vn:80 (rtmp)
- Wowza ACP: test2.vivatv.vn:8443 (http)
- Feed output: test3.vivatv.vn:8080 (http)
bắn feed:
https://i.imgur.com/tvhRZb9.jpg
Link play:
http://test3.vivatv.vn:8080/vivatv-open/<stream key>_aac/playlist.m3u8
#!/bin/bash
root=/root/devops/tasks
find $root -type f -name '*README.txt*' > $root/file.txt
echo "" > $root/subjects.txt
while read line; do
sed -n '/\-\-\-/,/\-\-\-/{/\-\-\-/b;/\-\-\-/b;p}' "$line" >> $root/subjects.txt
done < $root/file.txt
sed -i '/^\s*$/d' $root/subjects.txt
import os
import re
BASEPATH = 'root/devops/tasks'
courses = []
lastLine = []
folders = os.listdir(BASEPATH)
for folder in folders:

You've launched a revolutionary service not long ago, and were busy improving it for the last couple of months. When you finally decided that the service is perfect, you remembered that you created a feedbacks page long time ago, which you never checked out since then. Now that you have nothing left to do, you would like to have a look at what the community thinks of your service.

Unfortunately it looks like the feedbacks page is far from perfect: each feedback is displayed as a one-line string, and if it's too long there's no way to see what it is about. Naturally, this horrible bug should be fixed. Implement a function that, given a feedback and the size of the screen, splits the feedback into lines so that:

each token (i.e. sequence of non-whitespace characters) belongs to one of the lines entirely; each line is at most size characters long; no line has trailing or leading spaces; each line should have the maximum possible length, assuming that all lines before it were also the longest possible. Example