a.txt
aaaa
bbbb
cccc
eeee
eeee
eeee
b.txt
aabb
bbbb
dddd
cccc
diff a.txt b.txt
diff --git a/aaa b/bbb
index fc3703c..11629db 100644
--- a/aaa
+++ b/bbb
@@ -1,6 +1,4 @@
-aaaa
+aabb
bbbb
+dddd
cccc
-eeee
-eeee
-eeee
ed style of result diff a.txt b.txt
1c1
< aaaa
---
> aabb
2a3
> dddd
4,6d4
< eeee
< eeee
< eeee
My line by line diff just only change no add or delete, result in ed style to use in vim diff.
my_diff.py
#!/usr/bin/env python
def diff(file1, file2):
def get_buffer(a, b):
res = ""
for i in a:
res += i
res += '---\n'
for i in b:
res += i
return res
def get_action(start, end):
res = ""
if start == end:
res += "{0}c{0}\n".format(start)
else:
res += "{0},{1}c{0},{1}\n".format(start, end)
return res
buffer_a, buffer_b = [], []
res = ""
with open(file1, 'r') as a, open(file2, 'r') as b:
a = a.readlines()
b = b.readlines()
start, curr, end = 1, 1, 1
for x, y in zip(a, b):
if x == y:
if buffer_a:
res += get_action(start, end)
res += get_buffer(buffer_a, buffer_b)
buffer_a, buffer_b = [], []
start = curr + 1
else:
end = curr
buffer_a.append('< ' + x)
buffer_b.append('> ' + y)
curr += 1
res += get_action(start, end)
res += get_buffer(buffer_a, buffer_b)
buffer_a, buffer_b = [], []
print res,
if __name__ == '__main__':
import sys
diff(sys.argv[1], sys.argv[2])
.vimrc
set diffexpr=MyDiff()
function MyDiff()
silent execute "!python <your_paht>/my_diff.py " . v:fname_in . " " . v:fname_new . " > " . v:fname_out
endfunction
Ref:
A magical, better time in the future never comes - Nell Shamrell - Test Driven Development: A Love Story - Ancient City Ruby 2013
You want people to want more rather than wanting less, because if they want less then they’re probably not coming back - James Maher - 10 Common Mistakes Made by New Photographers
Even perfect code cannot explain its own existence. - How to name things: the hardest problem in programming
Read the source, Luke! - Getting into Linux Kernel Development
You can search Google to understand any hot new technology in a few minutes, but you can’t search Google to balance individual desire - Tech is Not the Problem, People Are
เราไม่ได้เหนื่อยเพราะเรื่องที่จบไปแล้ว แต่เหนื่อยเพราะเรื่องที่ยังเหลือมากกว่า - เมื่อรู้สึกเหนื่อย …
Like any simple practice, there’s lots of devil in the detail - Continuous Integration Improving Software Quality and Reducing Risk
your goal is not to write software. Your goal is to solve problems, and often software is part of the solution. - It’s about solving problems
It’s the small things we do everyday that matter most - Jeff Patton - “How Doing the Little Things Well Makes the Big Things Possible”
เราจะไม่ทำอะไรก็ได้ เราจะทำอะไรที่เป็นเรา คือถ้าเราปล่อยให้ลูกค้าเอาเรฟเฟอเรนซ์มาให้แล้วบอกว่าจะเอาแบบนี้ Eyedropper Fill คงเป็นได้แค่โปรดักชั่นเฮาส์ ซึ่งไม่ได้อยากเป็นแบบนั้น เราอยากเป็นครีเอทีฟ - Eyedropper Fill
“Five minutes” represented “think”, not react. - Give it five minutes
ถ้าคุณไม่สามารถเรียนรู้ได้ทั้งหมด ก็ให้เรียนรู้เท่าที่จําเป็นใน ตอนนั้นแทนสิ - http://www.somkiat.cc
Keep your personal emotions out of it. These people invest in results, not dreams. - Rise of the Planet of the Apes
ความอดทนต่อสถานการณ์ต่างหาก ที่นำอิสรภาพมาให้ - ในวันที่เผลอมองว่าชีวิต “ไม่เป็นดังใจ”
ทำให้มันเสร็จ ทำให้มันดี ทำให้มันเนี้ยบ ทำให้สุด - Thai Robotics Team - เป็นแชมป์หุ่นยนต์แล้วไปไหน
Impossible just a little longer - the Lexus hover board
“Remember, before you can be great, you’ve got to be good. Before you can be good, you’ve got to be bad. But before you can even be bad, you’ve got to try.” – Art Williamsk - The Difference Between Excellent, Good and Bad JavaScript Developers
You can’t optimize what you can’t measure - MongoDB at Scale
เอ้าซอร์สให้ผลลัพธ์ไม่ได้ให้ความรู้ เอ้าซอร์สช่วยประหยัดเวลาไม่ได้ช่วยสร้างประสบการณ์ - Outsourcing Work
Duplication is better than the wrong abstraction - RailsConf 2014 - All the Little Things by Sandi Metz
The Best Programming Advice I Ever Got” with Rob Pike
Ken taught me that thinking before debugging is extremely important. If you
dive into the bug, you tend to fix the local issue in the code, but if you
think about the bug first, how the bug came to be, you often find and correct a
higher-level problem in the code that will improve the design and prevent
further bugs.
If you don’t know where you are going, you’ll end up someplace else - Yogi Berra
“I am not a visionary, I’m an engineer,” - The mind behind Linux by Linus Torvalds
“I’m perfectly happy with all the people who are walking around and just staring at the clouds … but I’m looking at the ground, and I want to fix the pothole that’s right in front of me before I fall in.” - The mind behind Linux by Linus Torvalds
How to Become a Great Front-End Engineer - PHILIP WALTON
I realize that what separates the good people from the really good people
isn’t what they know; it’s how they think. Obviously knowledge is
important—critical in some cases—but in a field that changes so quickly,
how you go about acquiring that knowledge is always going to be more
important (at least in the long term) than what you know at any given time.
And perhaps most important of all: how you use that knowledge to solve
everyday problems.
If you’re working on a big, popular application like Word or Facebook for Android, you can still have plenty of impact that way just due to heft of that application’s user base, but it’s still an application. - Why I Like Systems Programming, DANIEL COLASCIONE
Most Tech Interviews Suck — The Only 4 Questions That Matter - Aaron Batalion
Remember that I’m hiring you to build products not write software.
It’s a very important distinction. You’ll make hundreds of micro
decisions every day about what and how to build products and
I want to know that you understand our business and will put that
as your first priority.
Every design decision involves tradeoffs - Great Design: What is Design? (First Draft) - Joel on Software
คุณจะดีได้แค่เท่ากับคนที่แย่ที่สุดในทีมของคุณ (You are only as good as your weakest link on your team. Lessons on Leading, Jessica Steel) - Piyorot
The number one key to succeeding in becoming a professional developer is to commit. Commit and never stop until you make it happen - How to Go From Hobbyist to Professional Developer - Ken Rogers
Just sitting in the factory, cranking out features, and sending them down the line. - 12 Signs You’re Working in a Feature Factory - John Cutler
When a programmer talks about how they “would love coding more, if it weren’t for all the users”, I assume I am talking to a junior developer. - The Role of a Senior Developer
if you don’t understand the logic behind the code, you won’t be able to write it in any language. - Programming will never be “easy”
often times programmers assume they are getting better, when in reality, the technology/methodology around them is getting better, and their actual skill level is still about the same. - The Violin Effect
Learning Programming Languages Faster
they’re missing the point clearly.
It’s not the learning languages that is important, its the learning how to program.
Its learning how to problem solve.
When you watch a new programmer learn to program,
they’ll think in terms of “What feature would I use to solve this problem”,
if you watch someone who is more experienced they tend to think in terms of “How would I solve this problem”
and then “How would I implement that in this language” or “What tool will I use to implement my solution?”.
The secret to becoming a better programmer isn’t in learning the most languages,
its learning to program the best.
Sometimes it’s important to go back to the basics and remember what we love about programming; sometimes it’s important to remember that programming is an art form; a form of expression as much as a science. - Programming as an Art
Design code without taking team into consideration is like design house without anybody actually living. - No one true way in architecture - Chris
เพราะแม้ความขยัน(ในระดับหนึ่ง)จะเป็นสิ่งจำเป็นต่อความสำเร็จ แต่โลกนี้ไม่เคยวัดกันที่ความขยันมาตั้งแต่แรก แต่วัดกันที่ impact - Charley
As a developer, there is too much out there to master everything. Don’t even try. Learn how you work best as a developer, build a toolset that fits you, and don’t try to have all the answers. Focus on learning how to find the answers quickly. - This Picture Will Change the Way You Learn to Code - Saul Costa
Small – Scalable – Stories in the INVEST Model - Bill Wake
John Gall said, “A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
ou have to start over with a working simple system.”
“TDD is not dead or alive. TDD is subject to tradeoffs, including risk of API changes, skill of practitioner and existing design” — Kent Beck
Nothing is more expensive than a feature that is not delivering any value - Stefan Wolpers
Code review should focus on finding bugs, logic errors, and security vulnerabilities. - MTaylor
The best way to be a 10x developer is to help 5 other developers be 2x developers. - Assessing Employee Performance - Eric Elliott
True value doesn’t appear overnight. Keep your eye on the end game. - Assessing Employee Performance - Eric Elliott
Expecting senior or authority to have it all figure out is really common mistakes. No one have it all figure out. - Chakrit Likitkhajorn
Problem is you try to solving problem with perfect solution all the times. - Greg Young
You don’t need every problem to solve in software - Greg young
Cost benefit analysis (CBA) everything! - Greg young
As CTO, I have one rules that is don’t losing your data - Greg young
In my mind, developers should instead be thinking about logging the right events in the right format for the right consumer - Jon Gifford
Flying more slowly is better than flying blind - Jon Gifford
People dont need a platform, They need solution - Mr. Yossi Shavit “The Road for Successful Startup: Lessons Learned from 500 Failed Startups”
I’m in the camp that there’s something far more interesting to work on than to try to join a three comma club. - DHH
“Software does not have to hurt. Change does not have to hurt, and we can figure it out together and it can be much better.” - DHH
“Indeed, the ratio of time spent reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code. …[Therefore,] making it easy to read makes it easier to write.” - Robert C. Martin
Things You Should Never Do, Part I - JOEL ON SOFTWARE
There’s a subtle reason that programmers always want to throw away the code and start over.
The reason is that they think the old code is a mess. And here is the interesting observation:
they are probably wrong.
The reason that they think the old code is a mess is because of a cardinal, fundamental law of programming:
It’s harder to read code than to write it.
One thing programmers pay close attention to in the day of interviewing is the people they meet. Are they nice? More importantly: are they smart? - JOEL ON SOFTWARE
Developers want to be hired for their skills, and treated as experts, and allowed to make decisions within their own realm of expertise. - JOEL ON SOFTWARE
hit-and-run management !!! management just would not back down on that issue and wouldn’t even take the time to listen to my arguments. - JOEL ON SOFTWARE
The great software developers, indeed, the best people in every field, are quite simply never on the market. - JOEL ON SOFTWARE
Programer VS Marketer - ifew
I’ll keep saying this … if people can’t build monoliths properly, microservices won’t help - Simon Brown
Be aggressive about proving out ideas quickly, scientifically and cost effectively. wait until a product is built before you test it. It’s madness. - UXPERTS
Culture is the thing that make new come and the old dont leave, dont is the competitive salary - Building a Software Development Team - MaRS Best Practices
you can’t be good doing things you do not love - antirez
I believe that the two main drivers of complexity are the unwillingness to perform design sacrifices, and the accumulation of errors in the design activity. - antirez
Perfectionism, I see this as one of the biggest barriers for a programmer to deliver things fast - antirez
The biggest issue on software teams is making sure everyone understands what everyone else is doing - Martin Fowler
“เมื่อเราอยากจะดีขึ้นกว่าที่เราเคยเป็น ทุกอย่างรอบตัวเราจะดีขึ้นเช่นกัน” - 10 คำพูดทรงพลังสอนบทเรียนชีวิตจากหนังสือ The Alchemist
You are not the customer - Developing Good Operations Tools
If somebody offers you an amazing opportunity but you are not sure you can do it, say yes — then learn how to do it later! Richard Branson
Building a software product is a lot like taking a trip between point A and B without really knowing what’s in the middle. - Stop building car boats — tech debt 101 - Ben Longstaff
How not to start a startup - Bram Krommenhoek
But I’m going to take up Sheryl Sandberg’s advice here:
There is no perfect fit when you’re looking for the next big thing to do.
You have to take opportunities and make an opportunity fit for you,
rather than the other way around. The ability to learn is the most
important quality a leader can have.
Companies are slowly shifting from a state where most employees have an operational or project mindset to a customer-facing or product mindset - Why managers shouldn’t measure individual performance in the digital age
Failures are great opportunities to learn. But when you are out of your depth, you won’t even know why you failed. You need to understand the failure to actually learn from it. Failure that you can’t understand also leads to more dissatisfaction. - Lakshmi Mani
การมีความรับผิดชอบอย่างสูงสุด (Full Accountability) นั้นคือความรับผิดชอบต่อคนในทีม ต่อเพื่อนมนุษย์ด้วยกัน ไม่ใช่ต่อตัวเลข KPI บ้าบอนั่น - Piyorot
สำหรับการรับพนักงานใหม่ หนึ่งในคุณสมบัติที่เราต้องการคือคนที่มีความเป็นมนุษย์เยอะๆ มีความเห็นอกเห็นใจ เอาใจเขามาใส่ใจเรา ค้นหาคนแบบนี้มาร่วมงานกับเราให้ได้ อย่าให้ความสำคัญเฉพาะคำโฆษณาในเรซูเม่ (empty) - Piyorot
general on what is considered to be “hot”, rather than solid research and any serious consideration of expected impact on their projects. I call this trend Hype Driven Development - Hype Driven Development - more
A free man sells results, not time - Yegor Bugayenko
” A senior developer understands that you cannot do everything yourself, Thier primary role is to help their team get better…” - Matt Briggr
Your tests may run faster or have more reusable code, but does that make you more or less confident in what is actually being tested? Always remember: There are no points for clever tests. - Testing Essentials
ชีวิตมีทางเลือกไม่จำกัด แต่มีเวลาจำกัด - Kittichai Jirasukhanon
Partnership ช่วยเราโตในช่วงเวลาหนึ่ง แต่ก็ทำให้เรา lost focus ในช่วงเวลานั้นเหมือนกัน - Yaron Zeidman, Agoda CTO
First-time Founders : ความผิดพลาดของ Startup … เรามักจะคิดว่า “ไอเดีย” ที่เราจะเริ่มทำนั้นต้องดูยิ่งใหญ่ ต้องเปลี่ยนแปลงอะไรซักอย่างของโลกให้ได้ นั่นเป็นความผิดพลาดที่เกิดขึ้นบ่อยครั้งของ First time founders ที่ไม่รู้จักเริ่มเล็ก ๆ ในสิ่งที่คุณทำให้เกิดได้ด้วยทีมที่มี, ในตลาดที่คุณรู้จัก, ในงบประมาณที่คุณควบคุมได้ – Sam Altman : Y Combinator
Complain and Propose - Kent beck
View problems as parts of an overall system. My problem is not always the System’s problem. - Roasted Pigs and Digital Transformation
A CTO has to be the person who gets the job done. - CTO ?
If every thing is under control, you are going too slow! - Mario Andrelti
We care so much about things that we can not change, and it ruins our happiness. If you are unhappy about something, and you can change it, then do it. But if you can’t change it, stop giving a fuck. - Mads Olsen
When we lose our principles, we intive chaos. - Mr.Robot S3E1
You can do anything but not everythin - Python Course on Code Academy
*** Settings ***
Documentation <document>
Library <Library>
Library <python pakcage> WITH NAME <ref name>
Resource <file>
Suite Setup <keyword>
Suite Teardown <keyword>
Test Setup <keyword>
Test Teardown <keyword>
*** Test Cases ***
<test name>
<command> or <keyword>
*** Keywords ***
<command>
[Arguments] ${variable}
${variable} = <command> ${variable}
[Return] ${variable}
2+ space - between command and argument (recommend 4 space)
# use ellipsis (...) to continue the previous line
Default Tags a b c
... d e f
support only .html, .xhtml, .htm, .tsv, .txt, .rst, or .rest file in dir
environment variables - %{VARIABLE}
${THRESHOLD} ${65} # 65 is integer
${THRESHOLD} ${67.25} # 67.25 is float
${THRESHOLD} 65 # 65 is string
${true} - python True
${false} - python False
${None} - python None
--test example* #select test
--suite example-?? #select suite
*** Settings ***
Force Tags FunctionalTest
Default Tags ValidTest
*** Test Cases ***
invalid login
[Tags] InvalidTest
# Tag select
$ pybot -i InvalidTest login_tests.txt
$ pybot --include InvalidTest login_tests.html
$ pybot -e InvalidTest login_tests.txt
$ pybot --exclude InvalidTest login_tests.html
init.txt - init test suite file
$ pybot --variable USERNAME:botbot --variable PASSWORD:ibot login_tests.html
$ pybot -d /tmp --variable SERVER:"192.168.59.103" --variable BROWSER:chrome tests/acceptance/
:FOR ${elem} IN @{list}
\ LOG ${elem}
$ brew install chromedriver # chrome driver for osx
$ brew install phantomjs # GUI less driver for osx
$ apt-get install phatomjs # GUI less driver for ubuntu
docker-engine not docker.io anymore
docker.io is old name
# Debian Jessie 8.0 (64-bit) or unstable packages
$ sudo apt-get update
$ sudo apt-get install docker-engine
# if virtualbox not installed, install via homebrew cask
http://docs.docker.com/installation/mac/#from-your-shell
$ brew install caskroom/cask/brew-cask
$ brew cask install dockertoolbox
# start docker engine
$ docker-machine create
$ eval "$(docker-machine env default)"
#debian
$ sudo groupadd docker
$ sudo gpasswd -a ${USER} docker # or sudo adduser ${USER} docker
$ sudo service docker restart
$ docker images --tree #list images in tree structure ('--tree' is deprecated)
$ docker ps -a #List all containers
$ docker ps -l #List lastest containers
$ docker ps -q #List containers display on IDs (quiet)
$ docker run -i -t <image> /bin/bash
docker start `docker ps -q -l` # restart it in the background
docker attach `docker ps -q -l` # reattach the terminal & stdin
$ docker run --rm <imamge>
$ sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm
# if space full in docker engine
$ docker rmi $(docker images | grep '<none>' | tr -s ' ' | cut -d ' ' -f 3)
# or
$ docker images -a | grep none | awk '{print $3}' | xargs docker rmi -f
# $ dokcer pull <images>
# Fix Repository debian already being pulled by another client. Waiting.
$ sudo service docker restart
# docker run option
# -v, --volume=[] create a volume
# -v host:container mount host directory to container
# ex. -v $PWD:/app , mount current path to /app in container
# -w, --workdir="" Working directory inside the container
$ docker run -v <host_dir_path>:<container_dir_path> -w <workdir_path> <image> <cmd>
#!/bin/bash
Q="0"
while [ $Q = "0" ]; do
Q=$(ping -c1 www.google.com 2> /dev/null | grep -c google);
done
echo Connected!
sudo service docker restart
$ docker exec <image> sh -c ‘<cmd>’
$ docker run <image> bash -c ‘<cmd>’
Dockerfile
# Docker env don't pass though cron jobs, you need to save env to file and load it in cron jobs.
# save Docker envoirment to file with command "env > <file>"
# To debug crontab see to run "rsyslogd" and see logs at "/var/log/syslo"
# CMD rsyslogd && && env > /root/env.sh && tail -f /var/log/cron.log
CMD cron && env > /root/env.sh && tail -f /var/log/cron.log
cron_task.sh
env - `cat /root/env.sh` $1
crontab
# always need ot >> to some where to avoid “(CRON) info (No MTA installed, discarding output)” error in the syslog
# http://askubuntu.com/questions/222512/cron-info-no-mta-installed-discarding-output-error-in-the-syslog
* * * * * root crontab_task.sh “<your command>" >> /var/log/cron.log 2>&1
#An empty line is required at the end of this file for a valid cron file.
$ docker-machine upgrade <machine>
$ echo "Asia/Bangkok" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
$ docker login
# docker tag <image> <username/image:version>
$ docker tag viau10-app ibotdotout/viau10-app:latest
# docker push <username/image>
$ docker push ibotdotout/viau10-app
# private registry
$ docker tag <contrainer_id> <your_registry_domain>/<image>
$ docker push <your_registry_domain>/<image>
$ docker build --no-cache .
$ sudo rm -rf /var/lib/docker/aufs
$ docker ps -s
# you can use `docker-machine ssh < machine > instead this
# 192.168.99.100 this is ip for < machine >
# that can check via `docker-machine ip < machine >
$ ssh docker@192.168.99.100
# password: tcuser
# clean your mapping volume on host that was copied to docker machine
$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro -v /var/lib/
``sh $ apt-get update && apt-get upgrade -y $ apt-get install -y python-pip $ pip install -U docker-compose
### Docker-Compose Production
```sh
# https://docs.docker.com/compose/extends/
$ docker-compose -f production.yml
$ apt-get install -y --no-install-recommends <packages>