tag:blogger.com,1999:blog-32739622772842126112024-02-20T02:37:37.922-08:00Programming RouteAnonymoushttp://www.blogger.com/profile/08581627550605750566noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-3273962277284212611.post-86110715137968440222016-11-14T01:49:00.000-08:002017-04-06T03:53:49.976-07:00Basic git console commands every programmer must know<div dir="ltr" style="text-align: left;" trbidi="on">
To be able to work and moreover understand the underlying mechanics of powerful GIT tool, You should recognise how some actual commands work even if U use GUI to perform for ex git-flow. In different situations You may need to execute some commands via terminal on the server - the best way to do this is to know basic commands, here we go:<br />
<br />
<span style="font-family: "arial";"><span style="font-size: 14.6667px;"><b>git init</b> - initialise local git repository</span></span><br />
<br />
<span id="docs-internal-guid-f7b39ca1-6228-ce4d-c824-044eb0aaeaf5" style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git remote add origin <url></b> - add remote url to Your local copy</span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><br /></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git remote set-url origin <url></b> - set another (change) remote url</span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><br /></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git remote -v</b> - list remote urls</span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><br /></span>
<span style="font-family: "arial";"><span style="font-size: 14.6667px;"><b>git add</b> - add file to branch</span></span><br />
<span style="font-family: "arial";"><span style="font-size: 14.6667px;"><br /></span></span>
<span style="font-family: "arial";"><span style="font-size: 14.6667px;"><b>git commit</b> - commit all changes to local repo</span></span><br />
<span style="font-family: "arial";"><span style="font-size: 14.6667px;"><br /></span></span>
<span style="font-family: "arial";"><span style="font-size: 14.6667px;"><b>git push</b> - push out all changes to remote</span></span><br />
<span style="font-family: "arial";"><span style="font-size: 14.6667px;"><br /></span></span>
<span id="docs-internal-guid-f7b39ca1-6234-27d9-3fff-82f6f52176a2" style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git push origin master --force </b>- push latest changes to remote branch overriding it, use with caution</span><br />
<span style="font-family: "arial";"><span style="font-size: 14.6667px;"><br /></span></span>
<span id="docs-internal-guid-f7b39ca1-622b-8593-e52d-19e29374b4e7" style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git add . && git commit -a -m 'some comment' && git push</b> - combination of all commands to sync local and remote branch</span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><br /></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git pull</b> - pull all changes from remote </span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><br /></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span id="docs-internal-guid-f7b39ca1-6233-2ddd-adb3-746535702994" style="font-size: 14.6667px; vertical-align: baseline;"><b>git pull origin <branch> - </b>pull particular branch</span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><br /></span>
<br />
<div dir="ltr" id="docs-internal-guid-f7b39ca1-622d-a952-a019-f83ceddd91f1" style="line-height: 1.38; margin-bottom: 10pt; margin-top: 0pt;">
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git update-index --assume-unchanged <file> </b>- mark file/dir as unchanged</span></div>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><b>git update-index --no-assume-unchanged <file> </b>- the backward of previous command</span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><br /></span></span>
<br />
<div dir="ltr" id="docs-internal-guid-f7b39ca1-622f-1ebb-c5f4-d98fda18d44c" style="line-height: 1.38; margin-bottom: 10pt; margin-top: 0pt;">
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git rm --cached <file></b> - remove file in remote repo</span></div>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><b>git rm -r --cached </b></span></span></span><span style="font-family: "arial"; font-size: 14.6667px; line-height: 20.24px;"><b><file></b> - remove dir in remote repo</span><br />
<span style="font-family: "arial"; font-size: 14.6667px; line-height: 20.24px;"><br /></span>
<span id="docs-internal-guid-f7b39ca1-6230-8f24-50f0-4ece5e7c3c1a" style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git reset --hard HEAD</b> - reset all changes to the latest commit in current branch</span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><br /></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span id="docs-internal-guid-f7b39ca1-6231-aa9c-7968-ce26cf368f08" style="font-size: 14.6667px; vertical-align: baseline;"><b>git log -p</b> or <b>git log -p <filename> - </b>see latest changes to file(s)</span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><br /></span></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span id="docs-internal-guid-f7b39ca1-6235-ad0c-0dc0-439c0a7a3c08" style="font-size: 14.6667px; vertical-align: baseline;"><b>git clean -df - </b>clean all local changes</span></span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><br /></span></span></span>
<br />
<div dir="ltr" id="docs-internal-guid-f7b39ca1-6236-a0e6-acb2-027aee8c9def" style="line-height: 1.38; margin-bottom: 10pt; margin-top: 0pt;">
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><b>git tag -a v1.2.5 -m 'comment’ </b>- create tag</span></div>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><b>git push origin --tags - </b>push created tag to remote</span></span></span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><br /></span></span></span></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span id="docs-internal-guid-f7b39ca1-9aa9-577d-1e45-fb2a50972a2a" style="font-family: "arial"; font-size: 14.6667px; font-weight: 700; vertical-align: baseline;">git branch -d the_local_branch </span><span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;">-</span><span style="font-family: "arial"; font-size: 14.6667px; font-weight: 700; vertical-align: baseline;"> </span><span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;">delete a local branch</span></span></span></span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><br /></span></span></span></span></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span id="docs-internal-guid-f7b39ca1-9aaa-88fc-725f-9669800bd938" style="font-size: 14.6667px; font-weight: 700; vertical-align: baseline;">git push origin :the_remote_branch </span><span style="font-size: 14.6667px; vertical-align: baseline;">- remove a remote branch semicolon is mandatory</span></span></span></span></span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><br /></span></span></span></span></span></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span id="docs-internal-guid-f7b39ca1-9aac-7699-99be-178039630075" style="font-size: 14.6667px; font-weight: 700; vertical-align: baseline;">git revert --strategy resolve 028fd6c </span><span style="font-size: 14.6667px; vertical-align: baseline;">- sometimes the shit happens, this command saved my life in those moments =)</span></span></span></span></span></span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><br /></span></span></span></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;">// renaming branch remotely </span></span></span></span><br />
<table class="highlight tab-size js-file-line-container" data-tab-size="8"><tbody>
<tr><td class="blob-code blob-code-inner js-file-line" id="file-gistfile1-sh-LC1"><b>git branch -m old_branch new_branch</b> -<span class="pl-c"> Rename branch locally </span></td>
</tr>
<tr>
</tr>
</tbody></table>
<table class="highlight tab-size js-file-line-container" data-tab-size="8"><tbody>
<tr><td class="blob-code blob-code-inner js-file-line" id="file-gistfile1-sh-LC2"><b>git push origin :old_branch</b> -<span class="pl-c"> Delete the old branch </span></td>
</tr>
<tr>
</tr>
</tbody></table>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><b> git push --set-upstream origin new_branch</b> -<span class="pl-c"> Push the new branch, set local branch to track the new remote</span></span></span></span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;">// =====</span></span></span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><br /></span></span></span></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;">// convenient command in case U need to remove cached files from .gitignore and there are a lot</span></span></span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><span id="docs-internal-guid-f7b39ca1-9aa3-40b2-200f-a082f745d036" style="font-family: "arial"; font-size: 14.6667px; font-weight: 700; vertical-align: baseline;">git rm --cached `git ls-files -i --exclude-from=.gitignore`</span></span></span></span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><br /></span></span>
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;">That's it, hope this information helped anyone to collect their knowledges about GIT.</span></span><br />
<span style="font-family: "arial"; font-size: 14.6667px; vertical-align: baseline;"><span style="font-size: 14.6667px; vertical-align: baseline;"><br /></span></span></div>
Anonymoushttp://www.blogger.com/profile/08581627550605750566noreply@blogger.com0tag:blogger.com,1999:blog-3273962277284212611.post-35998992622052559422016-08-03T08:11:00.002-07:002016-08-03T08:11:20.261-07:00Fundamental Science for Programmers<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<b>Fundamental Science for Programmers</b></div>
<div style="text-align: center;">
<b><br /></b></div>
<div style="text-align: left;">
You all should understand in the world of concurrency there are a lot of "specialists" or "professionals" and specialists or professionals, they just like You - people, they know many techs, programming languages and frameworks and it is natural how can You outrun them - fundamental science knowledge.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
For programming there is a math, if You good at it, then most probably You`ll be good with programming in any distance. </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
As a programmer You <b>MUST</b> know <b>discrete math</b>, here are the most important branches (without them programming is stupid and empty labor):</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
- graph theory</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
- set theory</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
- Boolean algebra </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
- combinatorics</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
- functions </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
- Relations </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
- logic and proof</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Also, You may wish to learn some aspects of <b>Mathematical analysis </b>- which will help You understand estimation of functions execution time and difficulty.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>Probability theory </b>- will definitely help You with any kind of task where You need to predict any state of anything, for ex.: caching of objects, game development, probability of data growth etc.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Physics - chips, micro-controllers, CPU, ram, transformers etc. You must learn how they work, what is a CPU clock speed, for example and how to calculate amount of operations computer or server can perform for any period of time. How many physical memory Your program needs to perform the task, for example You have a big data and need to sum/count all the data faster then a second it may take much longer if You won`t store the data partially in RAM to speed-up calculations. </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
All these knowledge will help You to be confident about any decision You`ve made, for any architecture part in program.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/08581627550605750566noreply@blogger.com0tag:blogger.com,1999:blog-3273962277284212611.post-71453552000686682532016-07-24T05:09:00.002-07:002016-11-29T07:59:25.915-08:00nix-tools and commands every programmer must know<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
Most common nix-tools<br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>cd</b> /var/some_directory</div>
<div style="text-align: left;">
<b>pwd</b> - print current working directory</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>mkdir</b> - make directory, can be used with -p flag to create recursively nonexistent parent dirs</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>ls -l</b> - list all dirs and files with their permissions and modified time / if U need to print all hidden files + human readable weights of a files You may use - <b>ls -lah</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>nano</b> - the simplest editor to fast edit files</div>
<div style="text-align: left;">
<b><br /></b></div>
<div style="text-align: left;">
<b>vim</b> - more hard to learn then nano, but in practice sometimes U will get in situations where something opened by this editor and U have no choice - learn how to edit text and close it, at least.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>|</b> - this symbol is pipe, that redirects the output to any other stream</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>></b> write line to file</div>
<div style="text-align: left;">
<b>>></b> append line to file</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>echo</b> - print everything to output, ex.: U can use something like this echo "test" >> /var/log/my.log</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>cat</b> - print text from a file to stdout </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>grep</b> - finds text in any file(s), output etc. this tool is tremendously useful, especially in combination with others, later You will see </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>kill</b> / <b>killall</b> - for the 1st U need to provide the pid to kill (sometimes with -9 to send SIGKILL to running program ), for the 2nd the name of a program</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>mc</b> - Midnight Commander, nothing to add just install it by default to do work much faster and transfer anything over the net</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>htop</b> - install this by default either, to monitor LA, CPU, HEAP/SWAP etc</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="font-family: "arial";"><span style="font-size: 18.6667px;"><b>df -h </b>- find out disk space in human readable format</span></span><br />
<span style="font-family: "arial";"><span style="font-size: 18.6667px;"><br /></span></span>
<span style="font-family: "arial";"><span style="font-size: 18.6667px;"><b>find / locate</b> - finds a file</span></span></div>
<div style="text-align: left;">
<span style="font-family: "arial";"><span style="font-size: x-small;"><br /></span></span></div>
<div style="text-align: left;">
<span style="font-family: "arial";"><span style="font-size: 18.6667px;"><b>which</b> - which program used providing absolute path</span></span><br />
<span style="font-family: "arial";"><span style="font-size: 18.6667px;"><br /></span></span>
<span style="font-family: "arial";"><b>netstat</b> - status of connections to server</span><br />
<span style="font-family: "arial";"><b><br /></b></span>
<span style="font-family: "arial";"><b>wget / curl</b> - tools to make requests over the network with many options including for ex.: ssl connections etc</span></div>
<div style="text-align: left;">
<br />
<b>ping</b> - pings the host, checking if it is alive<br />
<br />
<b>telnet</b> - test network connection for IP on any PORT<br />
<br />
<span id="docs-internal-guid-795a0c53-1ccc-3631-62dd-967c6e16a617" style="font-family: "arial"; font-weight: 700; vertical-align: baseline;">traceroute </span><span style="font-family: "arial"; vertical-align: baseline;">- displaying the route and measuring transit delays of packets</span><br />
<br /></div>
<div style="text-align: center;">
Miscellaneous and combination of nix commands/tools</div>
<div style="text-align: center;">
(kids may go to sleep)</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>cat</b> filename <b>| grep</b> sometext - become acquainted this is Your life saver on high-load systems when You try to pick needle in a haystack.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>ps aux</b> <b>| grep</b> program_name - find a special running process </div>
<div style="text-align: left;">
<br />
<b>history | grep</b> %command part% - finds a command previously executed<br />
<br /></div>
<div style="text-align: left;">
<b>tail -fn</b> 20 filename - show last 20 lines of a file and proceed to output last written (appended)</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>head -fn</b> 25 filename - show first 25 lines of a file and proceed to output last written (prepended)</div>
<div style="text-align: left;">
<br />
<span id="docs-internal-guid-795a0c53-1cbd-5ff4-2017-f5e372fdbbcd" style="font-family: "arial"; font-weight: 700; vertical-align: baseline;">netstat -tlpn</span><span style="font-family: "arial"; vertical-align: baseline;"> - show active internet connections</span></div>
<div style="text-align: left;">
<br />
<span id="docs-internal-guid-795a0c53-1cc5-d566-dada-4770adb97754" style="font-family: "arial"; font-weight: 700; vertical-align: baseline;">nmap -p</span><span style="font-family: "arial"; vertical-align: baseline;"> 5123 94.240.126.22 - test PORT for particular IP</span><br />
<br /></div>
<div style="text-align: center;">
Rock `n` Rolling nix commands/tools</div>
<div style="text-align: left;">
<div style="text-align: center;">
(older generation still here?)</div>
<br />
<span id="docs-internal-guid-795a0c53-1cbb-7584-cdcb-711a41b4b88a" style="font-family: "arial"; font-weight: 700; vertical-align: baseline;">du -csh * | sort -n </span><span style="font-family: "arial"; vertical-align: baseline;">- find the most heavy folders and sort them </span><br />
<br /></div>
<div style="text-align: left;">
<span id="docs-internal-guid-795a0c53-1cb5-4616-dfa3-c517582337a7" style="font-family: "arial"; font-weight: 700; vertical-align: baseline;">find /path/to/files* -mtime +5 -exec rm {} \; </span><span style="font-family: "arial"; vertical-align: baseline;">- delete files older then 5 days</span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span id="docs-internal-guid-795a0c53-1cb7-0560-b655-e00eb906234d" style="font-family: "arial"; font-weight: 700; vertical-align: baseline;">find folder -depth -type f -atime +7 -delete </span><span style="font-family: "arial"; vertical-align: baseline;">- find files that have a time of modification older then 7 days</span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span id="docs-internal-guid-795a0c53-1cb8-5d05-9f25-4e08c1565b52" style="font-family: "arial"; font-weight: 700; vertical-align: baseline;">find -vc 'special*' | wc -l </span><span style="font-family: "arial"; vertical-align: baseline;">- find files started with special and print counter</span></div>
<div style="text-align: left;">
<br />
<b>chmod +x $(find /var/www/someproject/ -type d) </b>- chmod only for dirs<br />
<br /></div>
<div style="text-align: left;">
<b>netstat -na</b> <b>| grep</b> 3306 <b>| wc -l</b> - count all processes of mysql-server </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<div dir="ltr" id="docs-internal-guid-795a0c53-1cc8-ecd0-b01e-5803b1493b01" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: "arial"; font-weight: 700; vertical-align: baseline;">grep --include=\*.{c,h} -rnw 'directory' -e "pattern"</span><span style="font-family: "arial"; vertical-align: baseline;"> - search for pattern in directory, including only files with .c/.h extensions</span></div>
<span style="font-family: "arial"; font-weight: 700; vertical-align: baseline;">grep --exclude=*.o -rnw 'directory' -e "pattern" - </span><span style="font-family: "arial"; vertical-align: baseline;">search for pattern in directory, excluding only files with .o extensions</span></div>
<div style="text-align: left;">
<br />
Detect DDoS or frequent connections in the network (graphical way):<br />
<b id="docs-internal-guid-09897982-94ec-e4b9-b842-4f4e40b89e35" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 18.666666666666664px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">netstat -an|grep ESTABLISHED|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|awk '{ printf("%s\t%s\t",$2,$1); for (i = 0; i < $1; i++) {printf("*")}; print ""}'</span></b><br />
<br />
Detect DDoS or frequent connections in the access.log files:<br />
<b>head -n 1000000 /var/log/nginx/yourprojectexample.com.access.log|cut -f 1 -d ' '|sort|uniq -c|sort -nr|more</b><br />
<br />
Examples of output:<b> </b><br />
953558 213.X.X.X<br />
6218 37.X.2.X<br />
2400 46.X.36.X<br />
1128 109.X.124.X<br />
........<br />
<br />
There is an extra one - my favorite, if U`ll ever be in critical situation and need to do things fast with previously performed action - try this: <br />
<b>!</b>ops - this will search in a history for "%ops%" wild-card and run, as an example U might want to connect to mysql-server with command like mysql -u username -h somehost -pPassword db_name by just executing: <b>!</b>mysql<br />
<br /></div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/08581627550605750566noreply@blogger.comtag:blogger.com,1999:blog-3273962277284212611.post-45728943208103687522016-07-23T09:43:00.003-07:002018-01-08T01:03:32.438-08:00Abbreviations every programmer must know<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<div style="text-align: left;">
Here will be introduced several abbreviations <b>every programmer must know</b>, some of them have a fundamental basis for how to improve Your code quality and exponentially evolve Your knowledge in computer science.<br />
</div>
</div>
<div style="text-align: left;">
<h3 style="text-align: left;">
Basic principles:</h3>
<div>
API - Application Programming Interface</div>
<div>
<br /></div>
<div>
SDK - Software Development Kit</div>
<div>
<br /></div>
</div>
<div style="text-align: left;">
OOP - Object Oriented Programming </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
SOLID - Single Responsibility, Open-Closed principle, Liskov`s substitution, Interface Segregation, </div>
<div style="text-align: left;">
Dependency Inversion. (have a discrete mathematical scientific base)</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
RDBMS - Relational DataBase Management System<br />
<br />
SQL - Structured Query Language, special purpose programming language designed for managing data held in RDBMS</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
ACID - Atomicity Consistency Isolation Durability, the main concepts of RDBMS</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
CRUD - CREATE - POST/INSERT, READ - GET/SELECT, UPDATE - PUT-PATCH/UPDATE, DELETE/DELETE, corresponding to HTTP1.1/SQL respectively.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
SIGNALS - Signals in C, some of them are so popular and commonly used, that if U don`t know them - it looks like total lame, they are all started with SIG|TYPEOFSIGNAL ex.: SIGKILL, SIGTERM - polite termination of a program, SIGHUP - terminal disconnected, SIGIO - input/output handling, SIGFPE - floating point or division by zero error, SIGCHILD - when child process is terminating, SIGCONT - continue process execution, SIGPIPE - broken pipe.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
POSIX - Portable Operating System Interface for Unix</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
RC - Race Condition</div>
<div style="text-align: left;">
<br /></div>
DRY - Don`t Repeat Yourself<br />
<br />
KISS - Kip It Simple, Stupid<br />
<div style="text-align: left;">
<br />
YAGNI - You aren't gonna need it<br />
</div>
<div style="text-align: left;">
<h3 style="text-align: left;">
Protocols and references:</h3>
</div>
<div style="text-align: left;">
ISO - International Organization for Standardization, includes members from almost all countries over the world.<br />
<br />
IETF - Internet Engineering Task Force</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
RFC - Request for Comments has a serial number ex.: RFC-6455 winch describes the specifications of a WebSocket protocol intercommunication. </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
HTTP1.0/1.1 - Hypertext Transfer Protocol, in simple words it describes how headers/body of a request/response should be transferred and through winch of methods GET/POST/PUT/PATCH/DELETE/HEAD/OPTIONS and with what rules.</div>
<div style="text-align: left;">
<br />
<div style="text-align: left;">
SOAP/WSDL - Simple Object Access Protocol and Web Services Description Language - based on XML and describes Access to Web-Services.<br />
<br /></div>
<div style="text-align: left;">
RESTfull - Representational State Transfer, describes several constraints like: Client-Server, Stateless, Cacheable, Layered System, Uniform Interface.</div>
<br /></div>
<div style="text-align: left;">
W3C - (not for all programmers, but for Web front-end is a must)<br />
</div>
<div style="text-align: left;">
<h3 style="text-align: left;">
Formats: </h3>
</div>
<div style="text-align: left;">
JSON-RPC - stateless, light-weight remote procedure call (RPC) protocol. For instance, you can call methods of controllers by appending to uri statements like this - &method=getMapObjects <br />
<br />
JSON API - JavaScript Object Notation with Application Programming Interface for server/client intercommunications </div>
<div style="text-align: left;">
<br />
GraphQL - is a query language with types and their restrictions/filters, ex.: required fields, string/boolean/numeric types. Developed and used by FaceBook.<br />
<br /></div>
<div style="text-align: left;">
XML/XSLT - Extensible Markup Language and Extensible Stylesheet Language Transformations<br />
<br />
PSR - PHP Standard Recommendations (not common, only for PHP developers)<br />
</div>
<div style="text-align: left;">
<h3 style="text-align: left;">
Security: </h3>
<div>
SSH - Secured Shell</div>
<div>
<br /></div>
</div>
<div style="text-align: left;">
SSL/TLS - Secure Socket Layer / <span style="background-color: white; color: #222222; font-family: "arial" , sans-serif; font-size: 16px; line-height: 19.2px;">Transport Layer Security (newer version of SSL)</span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
SQL Injection - when hacker can inject some sql-query by inputting extra value to the field of a query, if it hasn`t been protected by param-bindings for example or by string escaping etc</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
CSRF - Cross Site Request Forgery </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
XSS - Cross Site Scripting</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
DDoS - Distributed Denial of Service</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
BruteForce - attack explore weakly programmed input points in application by forcing them with ex.: multiple requests.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Man in the Middle - Asymmetric encryption eavesdropping via TCP/IP socket connection, HTTP over it </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Session Hijacking - it is used to refer to the theft of a magic cookie used to authenticate a user to a remote server.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/08581627550605750566noreply@blogger.com0tag:blogger.com,1999:blog-3273962277284212611.post-10810776213538358572016-07-05T10:48:00.001-07:002016-07-05T10:48:31.718-07:00Why PHP vs JAVA again and who rules the WEB<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
Sure there a are many holly-wars about wich tech is better than the other, but let me explain my point of view as a 14-year experienced programmer.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Experience with PHP 13 years, 7 of them with Java (also worked with C/C++/JS/JQ/SQL).</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
First of all PHP, at this time, is compiled to a byte-code with OPCache since 5.5 version, and it is even much better in PHP7.x versions whether we review processor ops speed (33% faster) or RAM (3 times less memory consumption than in 5.6 version), there was for a long time PThreads lib wich is based on POSIX C Threads supported with thread-safe versions of a PHP core.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Java - integrated Lambda expressions in 8 version, improved GC performance (as always in several JVM Generations), but it seems it is even slower time after time, convenient HTTP1.1 support, multi-threading out of the box etc makes it stuck to the market.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
What I like about PHP7 - it is strong technology, really - stop thinking of it as of simple form-renderer, CMS/CRM based or even worse Joomla sites. It was 10 years ago - forget it. I`ve worked for many international companies that do their business in Russia/US/EU, Brasil, Mexico they were totally (except for some micro-services and SQL/NoSQL dbs) written in PHP 5.5, 5.6, 7.x versions and evolved faster than projects on other techs. In other companies, the core+API-calls were written in PHP successfully.<br />
<br />
As for the last trends in PHP world, there are primitive types (scalar types with type casting) You can do (int), (double), (bool), (string) in any version since 5.x, return type declarations in methods/functions, scalar type declarations in arguments of a method/function, SPL. And as always does - PHP community strongly supports Web protocols, formats.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Java is more like enterprise and it may seem to have things done, but it is not always completely true and what is worse - it is much more difficult than in PHP wich is adopted by static-call functions written in C and closely integrated with Linux functions and tools. Ex.: if U need to delete the file, in PHP U just do unlink($myFile); wich is pure, native and intuitive - sure there are many examples like this - fork(), fread(), fclose() etc<br />
<br />
FrameWorks: everybody misunderstanding that there are 2 great FWs for Java Struts and SpringMVC, may be for the last few years Spark and none of enterprise - production ready FWs for PHP - Nah, totally not a true as with other statements of shallow unprofessional individuals, who can not see beyond their noses in some directions. Proof - there were a long time ZendFW, for those who like MIT license - numerous Symphony, Yii1/2, Laravel5.x, CMS based Drupal and much more, they are really stable, enterprise and production ready.<br />
<br />
Nowadays PHP is the world's biggest and commonly used tech for Web, API, RESTfull services, micro-services, it strongly supports all the RFC recommendations.<br />
<br />
PHP is 21 years old monster in 2016 - it can not be underestimated.<br />
<br />
Thx for reading,<br />
Sincerely Yours, Arthur.<br />
</div>
</div>
Anonymoushttp://www.blogger.com/profile/08581627550605750566noreply@blogger.com