Coder Blog by Blaž OražemOne of my most productive days was throwing away 1000 lines of code.http://www.numencode.com/feed2017-02-15T20:00:00+01:00Install the latest version of Composer on Ubuntu<p>If you have previously installed composer with command...</p>
<pre class="nb-console">sudo apt-get install composer</pre>
<p>...it is recommended to uninstall it first. Run the command:</p>
<pre class="nb-console">sudo apt-get purge --auto-remove composer</pre>
<p> </p>
<p>Let's install the latest version now. Go to whatever directory you like and follow the instructions for Command-line installation on the official Composer website: <a href="https://getcomposer.org/download/">https://getcomposer.org/download/</a></p>
<p>After you run the four commands (copy, verify, install, remove), you should end up with a single file named <strong>composer.phar</strong>.</p>
<p>All you have to do now is move this file to the appropriate directory with a command:</p>
<pre class="nb-console">sudo mv composer.phar /usr/local/bin/composer</pre>
<p>Try running this command anywhere...</p>
<pre class="nb-console">composer -V</pre>
<p>...and you should see the latest version of your freshly installed Composer.</p>
<p> </p>
<p>Running composer might display this error message (where [user] is your username):</p>
<pre>Cannot create cache directory /home/[user]/.composer/cache/repo/https---packagist.org/, or directory is not writable.<br />Proceeding without cache<br />Cannot create cache directory /home/[user]/.composer/cache/files/, or directory is not writable. <br />Proceeding without cache</pre>
<p>Set the permissions with these commands (where [user] is your username):</p>
<pre class="nb-console">cd ~</pre>
<pre class="nb-console"> sudo chown [user]:[user] .composer -R</pre>http://www.numencode.com/post/install-the-latest-version-of-composer-on-ubuntu/2017-02-15T20:00:00+01:00How to remove old kernel versions on Ubuntu Server<p>It is recommended to remove old kernel version to clean up the boot menu and to get some extra disk space.</p>
<p><strong>1.</strong> Check which kernel version you're using:</p>
<pre class="nb-console">uname -r</pre>
<p><strong>2.</strong> List all installed kernels and headers on your system:</p>
<pre class="nb-console">dpkg -l | grep linux-image</pre>
<pre class="nb-console">dpkg -l | grep linux-headers</pre>
<p><strong>3.</strong> If you're not using the latest kernel version, try rebooting your system first.</p>
<p><strong>4.</strong> You can remove old kernel versions automatically:</p>
<pre class="nb-console">sudo apt-get autoremove</pre>
<p><strong>5.a.</strong> Or you can remove them manually one by one:</p>
<pre class="nb-console">sudo apt-get purge linux-image-x.x.x.x-generic</pre>
<p><em><strong>Be sure, NOT to remove the version you're using! </strong></em></p>
<p>It is also recommended to leave the previous version on your system.</p>
<p><strong>5.b.</strong> When you're done, update your Grub:</p>
<pre class="nb-console">sudo update-grub2 </pre>
<p><strong>6.</strong> Reboot your system.</p>http://www.numencode.com/post/how-to-remove-old-kernel-versions-on-ubuntu-server/2017-02-08T20:00:00+01:00Awesome Laravel packages<ul>
<li><a href="http://lyften.com/projects/laravel-currency/doc/">Laravel Currency</a> – provides basic multi-currency functions for Laravel - custom exchange rates possible</li>
<li><a href="https://github.com/orchestral/parser">XML Parser</a> – XML Document Parser for Laravel</li>
<li><a href="https://laravel-news.com/uptime-monitor">Uptime Monitor</a> – monitor your Laravel website uptime</li>
<li><a href="https://github.com/laracasts/flash">Laracasts Flash</a> – Easy flash messages</li>
<li><a href="https://github.com/Zizaco/entrust">Entrust</a> – Role based permissions</li>
<li><a href="https://github.com/spatie/laravel-medialibrary">Medialibrary</a> – Associate files with Eloquent models</li>
<li><a href="https://github.com/laracasts/PHP-Vars-To-Js-Transformer">PHP Vars To Js Transformer</a> – Transform PHP types to JavaScript in the most easy way</li>
<li><a href="https://github.com/Intervention/image">Intervention Image</a> – An open source php image handling and manipulation library</li>
<li><a href="https://github.com/jarektkaczyk/eloquence">Eloquence </a>– Extensions for the Eloquent ORM</li>
<li><a href="https://github.com/barryvdh/laravel-debugbar">Laravel Debugbar</a> – Best debug bar for Laravel</li>
<li><a href="https://github.com/rap2hpoutre/laravel-log-viewer">Log viewer</a> – Error logs at a single route with nice UI</li>
<li><a href="https://github.com/tymondesigns/jwt-auth">JWT Auth</a> – JSON Web Token Authentication for Laravel & Lumen</li>
<li><a href="https://laravelcollective.com/docs/5.3/html">Forms & HTML (Lara Collective)</a> – Removed from the core but still maintained</li>
<li><a href="https://github.com/laravel-notification-channels">Notification Channels</a> – You think and its already in there</li>
</ul>http://www.numencode.com/post/awesome-laravel-packages/2017-01-16T20:00:00+01:00Disk Space and Partitions on Linux and UNIX-like systems<h2>Disk Space</h2>
<p>We can check out free disk space on a Linux system with the command:</p>
<pre class="nb-console">df -h</pre>
<p>or</p>
<pre class="nb-console">df -k</pre>
<p>These commands are great for checking overall disk space usage, but since we usually want to check which folder (or file) occupies the most disk space, we can run the command:</p>
<pre class="nb-console">du -sh * | sort -hr</pre>
<p>The first part of the command (left side of the pipe) will return the list of files and folders with corresponding disk usage values.</p>
<p>The second part (right side of the pipe) will sort the results by size (disk space usage) and will put the largest sizes on the top of the list. If you want the largest sizes on the bottom, just remove the 'r' parameter (r - reverse).</p>
<p>This command will list only the files and folders in the path where you are located, when running this command.</p>
<p><strong>A suggestion:</strong></p>
<p>Run the command, then 'cd' into the largest directory and run the command again. By doing that a few times, you will most likely find the source of your largest files and directories.</p>
<p> </p>
<h2>Disk Partitions</h2>
<p>List all partitions and check their size:</p>
<pre class="nb-console">sudo fdisk -l /dev/sda</pre>
<p>Open Linux partition editor in terminal:</p>
<pre class="nb-console">sudo cfdisk</pre>http://www.numencode.com/post/disk-space-and-partitions-on-linux-and-unix-like-systems/2016-11-30T20:00:00+01:00Javascript: Revealing Module Pattern<p>An example of how to use the Revealing Module Pattern:</p>
<pre><code data-language="javascript">var RevealingModuleExample = (function () {
var privateVar = "Jane Doe",
publicVar = "Hello World!";
function privateFunction() {
console.log("Name:" + privateVar);
}
function publicSetName(strName) {
privateVar = strName;
}
function publicGetName() {
privateFunction();
}
// Reveal public pointers to private functions and properties
return {
setName: publicSetName,
greeting: publicVar,
getName: publicGetName
};
})();
RevealingModuleExample.setName( "John Doe" );</code></pre>
<p>The pattern can also be used to reveal private functions and properties with a more specific naming scheme:</p>
<pre><code data-language="javascript">var RevealingModuleExample = (function () {
var privateCounter = 0;
function privateFunction() {
privateCounter++;
}
function publicFunction() {
publicIncrement();
}
function publicIncrement() {
privateFunction();
}
function publicGetCount(){
return privateCounter;
}
// Reveal public pointers to private functions and properties
return {
start: publicFunction,
increment: publicIncrement,
count: publicGetCount
};
})();
RevealingModuleExample.start();</code></pre>
<p><em><small>Source: https://addyosmani.com/resources/essentialjsdesignpatterns/book/#revealingmodulepatternjavascript (Author: Addy Osmani)</small></em></p>http://www.numencode.com/post/javascript-revealing-module-pattern/2016-11-20T20:00:00+01:00Rsync - copy multiple files from one server to another<p>Rsync is a <strong>file transfer program</strong> capable of efficient remote update via a fast differencing algorithm.</p>
<p>Rsync utility is commonly found on Unix-like systems and is used to minimize network usage while copying (or synchronizing) files from one server to another.</p>
<p>If you have SSH access to your server you can use rsync instead of traditional FTP method.</p>
<h2>How to use rsync?</h2>
<p>Let's say, that you want to copy files from server Master to server Slave. You must have SSH access to both servers.</p>
<ol>
<li>SSH to your Master server (<a href="/post/configure-ssh-to-connect-to-a-remote-ubuntu-server/" target="_blank">How-to guide here</a>)<br /><br /></li>
<li>Enter the command:<br />
<pre class="nb-console">rsync -a /path/to/your/files/ slave@192.168.1.100:/path/to/where/you/want/to/copy/the/files</pre>
<em>Be sure to use your own username and IP instead of slave@192.168.1.100.<br /><br /></em></li>
<li>You're done, the files are copied now.</li>
</ol>
<h2>Parameter '-a' explained</h2>
<p>Parameter <strong>-a</strong> (or <strong>--archive</strong>) is 'archive mode' and is equal to <strong>-rlptgoD</strong></p>
<table style="border-color: #cccccc; border-collapse: collapse;" border="1" cellspacing="0" cellpadding="4" bgcolor="#f5f5f5">
<tbody>
<tr>
<td>-r, --recursive</td>
<td>recurse into directories</td>
</tr>
<tr>
<td>-l, --links</td>
<td>copy symlinks as symlinks</td>
</tr>
<tr>
<td>-p</td>
<td>keep partially transferred files & show progress during transfer</td>
</tr>
<tr>
<td>-t, --times</td>
<td>preserve modification times</td>
</tr>
<tr>
<td>-g, --group</td>
<td>preserve group</td>
</tr>
<tr>
<td>-o, --owner</td>
<td>preserve owner (super-user only)</td>
</tr>
<tr>
<td>-D</td>
<td>preserve device files (super-user only) & preserve special files</td>
</tr>
</tbody>
</table>http://www.numencode.com/post/rsync-copy-multiple-files-from-one-server-to-another/2016-06-20T20:00:00+02:00Upgrade Gulp to v4<h2>1. First you need to install gulp 4 globally</h2>
<pre class="nb-console">npm rm -g gulp</pre>
<pre class="nb-console">npm install -g gulp-cli</pre>
<p>Check gulp version</p>
<pre class="nb-console">gulp -v</pre>
<p>You should see this:</p>
<pre>CLI version 1.2.1</pre>
<h2>2. Now you have to install gulp 4 locally in your project folder</h2>
<pre class="nb-console">cd /your_project_folder</pre>
<pre class="nb-console">npm uninstall gulp --save-dev</pre>
<pre class="nb-console">npm install 'gulpjs/gulp.git#4.0' --save-dev</pre>
<p>Check gulp version again</p>
<pre class="nb-console">gulp -v</pre>
<p>And you should see</p>
<pre>CLI version 1.2.1<br />Local version 4.0.0-alpha.2</pre>http://www.numencode.com/post/upgrade-gulp-to-v4/2016-05-20T20:00:00+02:00Git - Part 9: Remote repository on GitHub<p><strong>1.</strong> When logged in to GitHub, click green button "New repository"</p>
<p><strong>2.</strong> Choose repository name, enter description and click "Create repository"</p>
<p><strong>3.</strong> Now you have two options: create a new repository on the command line or push an existing repository on the command line</p>
<h2>New repository on the command line</h2>
<p>Use this option, if you doesn't have an existing local repository initialized.</p>
<pre class="nb-console">echo "# Some text" >> README.md</pre>
<pre class="nb-console">git init</pre>
<pre class="nb-console">git add README.md</pre>
<pre class="nb-console">git commit -m "first commit"</pre>
<pre class="nb-console">git remote add origin git@github.com:username/repository.git</pre>
<pre class="nb-console">git push -u origin master</pre>
<h2>Push an existing repository from the command line</h2>
<p>Use this option, if you already have an existing local repository initialized and you want to push it to GitHub.</p>
<pre class="nb-console">git remote add origin git@github.com:username/repository.git</pre>
<pre class="nb-console">git push -u origin master</pre>
<h1>Cloning remote repositories</h1>
<p>Clone remote repository to a specific folder</p>
<pre class="nb-console">git clone git@github.com:username/repository.git someFolderPath</pre>
<p>Clone remote repository to a folder with the same name as repository</p>
<pre class="nb-console">git clone git@github.com:username/repository.git someDirectoryPath</pre>
<h1>Remote branching</h1>
<p>Checkout (or create) some local branch</p>
<pre class="nb-console">git checkout feature-branch</pre>
<p>Push branch to a remote repository</p>
<pre class="nb-console">git push origin feature-branch</pre>
<p>Delete remote branch</p>
<pre class="nb-console">git push origin :feature-branch</pre>
<p>OR</p>
<pre class="nb-console">git push origin --delete feature-branch</pre>http://www.numencode.com/post/git-part-9-remote-repository-on-github/2016-05-12T20:00:00+02:00Git - Part 8: Connect to GitHub via SSH protocol<p><strong>1.</strong> On your Windows machine I suggest installing <strong>Cmder</strong> console emulator, visit <a href="http://cmder.net/" target="_blank">http://cmder.net/</a> and then download and install the Full package (with git-for-windows)</p>
<p><strong>2.</strong> Open Cmder or other console software on your Windows machine, navigate to root directory, create .ssh directory and enter it</p>
<pre class="nb-console">cd ~</pre>
<pre class="nb-console">mkdir .ssh</pre>
<pre class="nb-console">cd .ssh</pre>
<p><strong>3.</strong> Create SSH key pair id_rsa & id_rsa.pub (-t is type, -b is bytes, -f is filename)</p>
<pre class="nb-console">ssh-keygen -t rsa -b 4096 -f id_rsa -C "email@domain.com"</pre>
<p><em>When prompted for password, just hit Enter key - do not enter the password.</em></p>
<p><strong>4.</strong> Display the public key on the screen, select the printed text and copy it to clipboard</p>
<pre class="nb-console">cat id_rsa.pub</pre>
<p><strong>5.</strong> Open GitHub website (<a href="http://www.github.com" target="_blank">www.github.com</a>) and login with your account</p>
<p><strong>6.</strong> Navigate to Settings / SSH and GPG keys</p>
<p><strong>7.</strong> Click "New SSH key" button on the top right corner</p>
<p><strong>8.</strong> Enter title (can be anything you want), paste previously copied public key to the "Key" text area and click "Add SSH key"</p>
<p><strong>9.</strong> Go back to Cmder (or any other console emulator) and enter</p>
<pre class="nb-console">ssh -T git@github.com</pre>
<p><strong>10.</strong> Enter 'yes' when you get prompted with: Are you sure you want to continue connecting (yes/no)?</p>
<p>That's it. Now you do not have to enter your password every time when you push your code to GitHub.</p>http://www.numencode.com/post/git-part-8-connect-to-github-via-ssh-protocol/2016-05-10T20:00:00+02:00Git - Part 7: Stash away changes<p>Stash away changes</p>
<pre class="nb-console">git stash</pre>
<p>Check stash list</p>
<pre class="nb-console">git stash list</pre>
<p>Apply the most recent stash and leave it on the list</p>
<pre class="nb-console">git stash apply</pre>
<p>Apply specific stash and leave it on the list</p>
<pre class="nb-console">git stash apply stash@{0}</pre>
<p>Apply the most recent stash and clear it from the list</p>
<pre class="nb-console">git stash pop</pre>
<p>Apply specific stash and clear it from the list</p>
<pre class="nb-console">git stash pop stash@{0}</pre>
<p>Delete the most recent stash from the list</p>
<pre class="nb-console">git stash drop</pre>
<p>Delete specific stash from the list</p>
<pre class="nb-console">git stash drop stash@{0}</pre>
<p>Apply stash to a new branch called feature</p>
<pre class="nb-console">git stash branch feature</pre>
<hr />
<h2>Exercise</h2>
<ol>
<li>Create index.html file with content <h1>Hello World!</h1> and blank test.html file
<pre class="nb-console">touch index.html</pre>
<pre class="nb-console">vi index.html</pre>
<pre class="nb-console">touch test.html</pre>
</li>
<li>Add all to staging area and commit to master branch
<pre class="nb-console">git add .</pre>
<pre class="nb-console">git commit -m "Initial commit"</pre>
</li>
<li>Create new branch named 'feature-branch'
<pre class="nb-console">git checkout -b feature-branch</pre>
</li>
<li>Edit file test.html and add content <h2>This is a test</h2>
<pre class="nb-console">vi test.html</pre>
</li>
<li>Stash the changes
<pre class="nb-console">git stash</pre>
</li>
<li>Checkout master branch
<pre class="nb-console">git checkout master</pre>
</li>
<li>Edit file index.html and change <h1> tags to <h3> tags
<pre class="nb-console">vi index.html</pre>
</li>
<li>Add and commit changes
<pre class="nb-console">git add .</pre>
<pre class="nb-console">git commit -m "Change header tags"</pre>
</li>
<li>Checkout branch feature-branch
<pre class="nb-console">git checkout feature-branch</pre>
</li>
<li>Check stash list
<pre class="nb-console">git stash list</pre>
</li>
<li>Apply stash with 'pop' command
<pre class="nb-console">git stash pop</pre>
</li>
<li>Add and commit changes to feature-branch
<pre class="nb-console">git add .</pre>
<pre class="nb-console">git commit -m "Changes applied"</pre>
</li>
<li>Checkout master branch and merge feature-branch
<pre class="nb-console">git checkout master</pre>
<pre class="nb-console">git merge feature-branch</pre>
</li>
</ol>http://www.numencode.com/post/git-part-7-stash-away-changes/2016-05-07T20:00:00+02:00Git - Part 6: Handling Merge Conflicts<p>Creating conflict and merging branches</p>
<pre class="nb-console">git checkout master</pre>
<pre class="nb-console">git merge feature-branch</pre>
<p>Notice on conflicts<br /><em>Automatic merge failed; fix conflicts and then commit the result.</em></p>
<p>Show merge conflicts</p>
<pre class="nb-console">git diff path/to/file.ext</pre>
<p>Merge conflict example</p>
<pre><<<<<<< HEAD<br /> Content on current branch (master)<br />=======<br /> Content on merged branch (feature-branch)<br />>>>>>>> feature-branch</pre>
<hr />
<h2>Exercise</h2>
<ol>
<li>Create Git repository, add and commit file index.html with content <h1>Hello world!</h1>
<pre class="nb-console">git init</pre>
<pre class="nb-console">touch index.html</pre>
<pre class="nb-console">vi index.html</pre>
<pre class="nb-console">git add index.html</pre>
<pre class="nb-console">git commit -m "Initial commit"</pre>
</li>
<li>Create a new branch called 'conflict-branch'
<pre class="nb-console">git checkout -b conflict-branch</pre>
</li>
<li>Edit index.html file and change h1 tags to h2
<pre class="nb-console">vi index.html</pre>
</li>
<li>Add and Commit to conflict-branch branch with a message "Change h1 to h2"
<pre class="nb-console">git add .</pre>
<pre class="nb-console">git commit -m "Change h1 to h2"</pre>
</li>
<li>Checkout master branch
<pre class="nb-console">git checkout master</pre>
</li>
<li>Edit index.html file and change h2 tags to h3
<pre class="nb-console">vi index.html</pre>
</li>
<li>Add and Commit to master branch with a message "Change h1 to h3"
<pre class="nb-console">git add .</pre>
<pre class="nb-console">git commit -m "Change h1 to h3"</pre>
</li>
<li>Merge conflict-branch (see: CONFLICT; Automatic merge failed;)
<pre class="nb-console">git merge conflict-branch</pre>
</li>
<li>Check Git status (see: both modified: index.html)
<pre class="nb-console">git status</pre>
</li>
<li>Edit index.html file and fix conflicts; change:
<pre><<<<<<< HEAD
<h3>Hello World!</h3>
=======
<h2>Hello World!</h2>
>>>>>>> conflict-branch</pre>
To:
<pre><h2>Hello World!</h2></pre>
</li>
<li>Add and Commit to master branch with a message "Fix conflicts"
<pre class="nb-console">git add .</pre>
<pre class="nb-console">git commit -m "Fix conflicts"</pre>
</li>
<li>Check Git log (see: all commits)
<pre class="nb-console">git log --oneline</pre>
</li>
</ol>http://www.numencode.com/post/git-part-6-handling-merge-conflicts/2016-05-06T20:00:00+02:00Git - Part 5: Branching<p>Create and checkout a new branch</p>
<pre class="nb-console">git checkout -b feature-branch</pre>
<p>Checkout existing branch (eg. master)</p>
<pre class="nb-console">git checkout master</pre>
<p>List all branches</p>
<pre class="nb-console">git show-branch --list</pre>
<p>Merge changes from feature branch</p>
<pre class="nb-console">git merge feature-branch</pre>
<p>Delete feature branch</p>
<pre class="nb-console">git branch -d feature-branch</pre>
<hr />
<h2>Exercise</h2>
<ol>
<li>Create new file index.html and add some content
<pre class="nb-console">touch index.html</pre>
</li>
<li>Add index.html to the staging area and commit to master branch
<pre class="nb-console">git add index.html</pre>
<pre class="nb-console">git commit -m "Initial commit"</pre>
</li>
<li>Create new Git branch called 'feature-branch'
<pre class="nb-console">git checkout -b feature-branch</pre>
</li>
<li>Create file feature.html and add some content
<pre class="nb-console">touch feature.html</pre>
</li>
<li>Add and Commit all to this branch with message "Work on branch"
<pre class="nb-console">git add --all</pre>
<pre class="nb-console">git commit -m "Work on branch"</pre>
</li>
<li>Checout master branch
<pre class="nb-console">git checkout master</pre>
</li>
<li>Merge changes from feature-branch
<pre class="nb-console">git merge feature-branch</pre>
</li>
<li>Delete feature-branch
<pre class="nb-console">git branch -d feature-branch</pre>
</li>
<li>Check branch list (see: only master branch)
<pre class="nb-console">git show-branch --list</pre>
</li>
<li>Check git log (see: both commits)
<pre class="nb-console">git log</pre>
</li>
</ol>http://www.numencode.com/post/git-part-5-branching/2016-05-04T21:00:00+02:00Git - Part 4: Fixing and Amending commits<p>Soft reset - resets to the previous state, but leaves your changes</p>
<pre class="nb-console">git reset --soft UniqueHash</pre>
<p>Hard reset - resets everything to the previous state, deletes your changes</p>
<pre class="nb-console">git reset --hard UniqueHash</pre>
<p>Amend commit - saves changes to the same previous commit</p>
<pre class="nb-console">git commit --amend</pre>
<hr />
<h2>Exercise: fixing commit</h2>
<ol>
<li>Create new Git repository
<pre class="nb-console">git init</pre>
</li>
<li>Create a new file index.html with content "Hello Wrold!"
<pre class="nb-console">touch index.html</pre>
<pre class="nb-console">vi index.html</pre>
</li>
<li>Add and Commit index.html file with message "Initial commit"
<pre class="nb-console">git add index.html</pre>
<pre class="nb-console">git commit -m "Initial commit"</pre>
</li>
<li>Check git status (see: On branch master nothing to commit, working directory clean)
<pre class="nb-console">git status</pre>
</li>
<li>Check git log (see:Initial commit)
<pre class="nb-console">git log --oneline</pre>
</li>
<li>Open index.html and change text to "Hello World!"
<pre class="nb-console">vi index.html</pre>
</li>
<li>Add and Commit index.html file with message "Fix typo"
<pre class="nb-console">git add index.html</pre>
<pre class="nb-console">git commit -m "Fix typo"</pre>
</li>
<li>Check git log (see: both commits)
<pre class="nb-console">git log --oneline</pre>
</li>
</ol>
<h2>Exercise: amending commit</h2>
<ol>
<li>Check git log and copy UniqueHash from Initial commit
<pre class="nb-console">git log --oneline</pre>
</li>
<li>Hard reset repository to the initial commit
<pre class="nb-console">git reset --hard UniqueHash</pre>
</li>
<li>Review index.html and check that the typo is there
<pre class="nb-console">cat index.html</pre>
</li>
<li>Open index.html and change text to "Hello World!"
<pre class="nb-console">vi index.html</pre>
</li>
<li>Add index.html to the staging area
<pre class="nb-console">git add index.html</pre>
</li>
<li>Check git status (see: Changes to be committed: modified: index.html)
<pre class="nb-console">git status</pre>
</li>
<li>Amend commit
<pre class="nb-console">git commit --amend</pre>
</li>
<li>Check git log (see: only initial commit)
<pre class="nb-console">git log --oneline</pre>
</li>
<li>Review index.html and check that the typo is fixed
<pre class="nb-console">cat index.html</pre>
</li>
</ol>http://www.numencode.com/post/git-part-4-fixing-and-amending-commits/2016-05-04T20:00:00+02:00Git - Part 3: Status and Log<p>Check git status</p>
<pre class="nb-console">git status</pre>
<p>Check git log</p>
<pre class="nb-console">git log</pre>
<p>One-line git log</p>
<pre class="nb-console">git log --pretty=oneline</pre>
<p>One-line git log with short hash id's</p>
<pre class="nb-console">git log --oneline</pre>
<p>Show the latest commit for current branch</p>
<pre class="nb-console">git branch -v</pre>http://www.numencode.com/post/git-part-3-status-and-log/2016-05-03T20:00:00+02:00Git - Part 2: Repositories<h2>Create a repository</h2>
<p>Initialize a new Git repository</p>
<pre class="nb-console">git init</pre>
<h2>Add and Commit to a repository</h2>
<p>Stage Single file</p>
<pre class="nb-console">git add index.html</pre>
<p>Stage Multiple files</p>
<pre class="nb-console">git add index.html index2.html</pre>
<p>Stage All (new, modified, deleted) files</p>
<pre class="nb-console">git add -A</pre>
<p>Stage All (new, modified, deleted) files</p>
<pre class="nb-console">git add --all</pre>
<p>Stage All (new, modified, deleted) files</p>
<pre class="nb-console">git add .</pre>
<p>Stage Modified and Deleted files only</p>
<pre class="nb-console">git add -u</pre>
<p>Stage New and Modified files only</p>
<pre class="nb-console">git add --ignore-removal .</pre>
<p>Commit to repository</p>
<pre class="nb-console">git commit -m "This is commit message"</pre>
<hr />
<h2>Exercise</h2>
<ol>
<li>Create a new file index.html and add some content
<pre class="nb-console">touch index.html</pre>
</li>
<li>Add index.html to Git
<pre class="nb-console">git add index.html</pre>
</li>
<li>Check git status (see: index.html is ready for commit)
<pre class="nb-console">git status</pre>
</li>
<li>Open index.html and change some of the content
<pre class="nb-console">vi index.html</pre>
</li>
<li>Check git status (see: previous index.html is still ready for commit; index.html is modified)
<pre class="nb-console">git status</pre>
</li>
<li>Commit changes
<pre class="nb-console">git commit -m "Initial commit"</pre>
</li>
<li>Check git status (see: index.html is still modified)
<pre class="nb-console">git status</pre>
</li>
<li>Add index.html
<pre class="nb-console">git add index.html</pre>
</li>
<li>Commit index.html
<pre class="nb-console">git commit -m "Content is changed"</pre>
</li>
<li>Check git status (see: nothing to commit)
<pre class="nb-console">git status</pre>
</li>
<li>Check git log (see: both commits)
<pre class="nb-console">git log</pre>
</li>
</ol>http://www.numencode.com/post/git-part-2-repositories/2016-05-02T21:00:00+02:00Git - Part 1: Settings<p>Global configuration is stored in a file <strong>.gitconfig</strong> your root (cd ~) folder.</p>
<p>Set your name</p>
<pre class="nb-console">git config --global user.name = 'John Doe'</pre>
<p>Set your e-mail</p>
<pre class="nb-console">git config --global user.email = 'info@yourdomain.com'</pre>
<p>Set default editor, which will be used for commit messages, resolving conflicts, etc.</p>
<pre class="nb-console">git config --global core.editor vi</pre>
<p>OR</p>
<pre class="nb-console">git config --global core.editor notepad</pre>
<p>Turn off a warning about LF replacement</p>
<pre class="nb-console">git config --global core.autocrlf true</pre>http://www.numencode.com/post/git-part-1-settings/2016-05-02T20:00:00+02:00Environment setup for Front-end development<p>What do we need to start modern front-end development? Here's my setup (on Windows machine):</p>
<ol>
<li><strong>Git</strong> for windows</li>
<li><strong>GitHub</strong> profile</li>
<li><strong>Cmder</strong> - console emulator</li>
<li><strong>Bash</strong> setup (.bashrc, .bash_aliases)</li>
<li><strong>Node.js</strong> (for <strong>npm</strong>) - javascript runtime</li>
<li><strong>Gulp</strong> - automated task runner</li>
<li><strong>Brackets</strong> - coding editor</li>
</ol>
<p>That's it. Let's see how to install and configure this awesome open-source software!</p>
<hr />
<h1>1. Git for Windows</h1>
<ol>
<li>Visit website <strong><a href="http://www.git-scm.com" target="_blank">www.git-scm.com</a></strong>.</li>
<li>Click the "<strong>Downloads for Windows</strong>" button on the green monitor image.</li>
<li>Run (execute) the installation file, once it downloads to your computer.</li>
<li>During the installation leave everything to default, just be sure to select "<strong>Use Git from the Windows Command Prompt</strong>" and "<strong>Checkout Windows-style, commit Unix-style line endings</strong>" options when prompted.</li>
</ol>
<h1>2. GitHub profile</h1>
<ol>
<li>Visit website <strong><a href="http://www.github.com" target="_blank">www.github.com</a></strong>.</li>
<li>Choose your username, email and password.</li>
<li>Click "<strong>Sign up for GitHub</strong>".</li>
<li>When welcome page is displayed, click "<strong>Finish sign up</strong>" button.</li>
<li>Check your inbox and verify your email addres (click on the link).</li>
<li>I suggest connecting to GitHub via <strong>SSH protocol</strong>, for which you can follow these instructions: <strong><a href="/post/connect-to-github-via-ssh-protocol/">http://www.numencode.com/post/connect-to-github-via-ssh-protocol/</a></strong></li>
</ol>
<h1>3. Cmder</h1>
<ol>
<li>Visit website <strong><a href="http://cmder.net" target="_blank">cmder.net</a></strong> and navigate to the <strong>Download</strong> section.</li>
<li>Download <strong>Mini version</strong>, because you already have Git for Windows installed.</li>
<li>When you receive ZIP archive, extract it to a Cmder folder inside your "<strong>Program Files</strong>" on your system disk (eg. C:\Program Files (x86)\Cmder).</li>
<li>Run cmder.exe file and click "<strong>Unblock and Continue</strong>" when "Warning!" prompt window appears.</li>
<li>Cmder should be running now. Right click the Cmder's titlebar and choose "<strong>Settings...</strong>" (or press Win - Alt - P) and the settings panel should open.</li>
<li>On the left navigation select "<strong>Startup / Tasks</strong>" and click "<strong>Add default tasks...</strong>" button.</li>
<li>On the "<strong>Predefined tasks</strong>" menu select <strong>{Bash::Git bash}</strong> and add text '-new_console:d:C:\www' where 'C:\www' is your working projects root folder (can be any folder you want). The whole setting should look like this:<br />
<pre>"%ConEmuDrive%\Program Files\Git\git-cmd.exe" --no-cd<br />--command=usr/bin/bash.exe -l -i -new_console:d:C:\www</pre>
</li>
<li>Now select "<strong>Startup</strong>" element on the left navigation and select <strong>{Bash::Git bash}</strong> option on the "<strong>Specified named task</strong>".</li>
<li>Click "<strong>Save settings</strong>" on the bottom right corner and you're set to go.</li>
</ol>
<h1>4. Bash setup</h1>
<ol>
<li>Visit <strong><a href="https://gist.github.com/numencode/3ce8d0f9b386ab2342ec0a0c2c5ff728" target="_blank">https://gist.github.com/numencode/3ce8d0f9b386ab2342ec0a0c2c5ff728</a></strong> </li>
<li>Download files <strong>.bashrc</strong> and <strong>.bash_aliases</strong> to your computer (Click "<strong>Raw</strong>" button, press Ctrl - S).</li>
<li>Move the two files to your Windows user folder (eg: C:\Users\JohnDoe).</li>
<li>Open file .bash_aliases with text editor and change alias 'www' to your own projects path.</li>
<li>Check other aliases in file .bash_aliases and customize them if you like.</li>
<li>Start Cmder and type any alias to see if it's working. If you go to any Git project folder, you should be able to see Git branch name.</li>
</ol>
<h1>5. Node.js and npm</h1>
<ol>
<li>Visit website <strong><a href="http://www.nodejs.org" target="_blank">www.nodejs.org</a></strong>.</li>
<li>Choose the green "<strong>Download for Windows</strong>" button - you can choose between a "<strong>LTS</strong>" (long-term-support) version or the latest one, where I suggest the "<strong>Current</strong>" one.</li>
<li>Run (execute) the installation file, once it downloads to your computer.</li>
<li>During the installation leave everything to default.</li>
<li>Once the installation is completed, open <strong>Cmder</strong> and test the <strong>Node</strong> and <strong>npm</strong> by running commands:<br />
<pre class="nb-console"> node -v</pre>
<pre class="nb-console">npm -v</pre>
</li>
</ol>
<h1>6. Gulp - automated task runner</h1>
<ol>
<li>Gulp can be installed with <strong>npm</strong>.</li>
<li>Open <strong>Cmder</strong> and run the command<br />
<pre class="nb-console">npm install gulp -g</pre>
which will install gulp globally to your computer.<br /><em>You might have to run Cmder as an administrator to take this action!</em></li>
<li>Test Gulp installation by running command:<br />
<pre class="nb-console"> gulp -v</pre>
</li>
<li>At the moment, version <strong>4.0.0-alpha.2</strong> can be installed locally for your project. I strongly suggest using <strong>Gulp4</strong>, for which you can follow these instructions: <strong><a href="/post/upgrade-gulp-to-v4/" target="_blank">http://www.numencode.com/post/upgrade-gulp-to-v4/</a></strong></li>
</ol>
<h1>Brackets - coding editor</h1>
<ol>
<li>Visit website <strong><a href="http://www.brackets.io" target="_blank">www.brackets.io</a></strong>.</li>
<li>Click the link "<strong>Download Brackets without Extract</strong>" under the big blue Download button.</li>
<li>Run (execute) the installation file, once it downloads to your computer.</li>
<li>During the installation leave everything to default.</li>
</ol>
<p>Now it's time to install some great plugins for Brackets.</p>
<ol>
<li>Open Brackets editor and navigate to "<strong>File / Extension Manager...</strong>"</li>
<li>You will see three tabs on the top (Available, Themes, Installed), choose "<strong>Themes</strong>" and search for "<strong>Coders Theme</strong>" which is really great.</li>
<li>There's a lot of useful plugins to choose from on "<strong>Available</strong>" tab, from which I recommend these:
<ul>
<li>Bootstrap 3 Snippets</li>
<li>Bootstrap Skeleton</li>
<li>Brackets-Gulp</li>
<li>Color Highlighter</li>
<li>LESS StyleSheets Formatter (nm|tU)</li>
<li>LESSHints</li>
<li>Show Git Branch for project</li>
<li>Tabs - Custom Working</li>
</ul>
</li>
</ol>http://www.numencode.com/post/environment-setup-for-front-end-development/2016-05-01T21:00:00+02:00Cmder - console emulator for Windows<h2>Download and installation</h2>
<p><strong>1.</strong> Open website <a href="http://cmder.net" target="_blank">cmder.net</a> and navigate to the Download section.</p>
<p><strong>2.</strong> You're left with two choices: if you already have Git installed on your Windows machine, download Mini version, otherwise I suggest downloading Full version.</p>
<p><strong>3.</strong> When you receive ZIP archive, extract it to a Cmder folder inside your "Program Files" on your system disk (eg. C:\Program Files (x86)\Cmder).</p>
<p><strong>4.</strong> Run cmder.exe file and click "Unblock and Continue" when "Warning!" prompt window appears.</p>
<p><strong>5.</strong> Cmder should be running now. Let's get ready for some configuration!</p>
<h2>Configuration (for Mini version)</h2>
<p><strong>1.</strong> Right click the Cmder's titlebar and choose "<strong>Settings...</strong>" (or press Win - Alt - P) and the settings panel should open.</p>
<p><strong>2.</strong> On the left navigation select "<strong>Startup / Tasks</strong>" and click "<strong>Add default tasks...</strong>" button.</p>
<p><strong>3.</strong> On the "<strong>Predefined tasks</strong>" menu select <strong>{Bash::Git bash}</strong> and add text '-new_console:d:C:\www' where 'C:\www' is your working projects root folder (can be any folder you want). The whole setting should look like this:</p>
<pre>"%ConEmuDrive%\Program Files\Git\git-cmd.exe" --no-cd<br />--command=usr/bin/bash.exe -l -i -new_console:d:C:\www</pre>
<p><strong>4.</strong> Now select "<strong>Startup</strong>" element on the left navigation and select <strong>{Bash::Git bash}</strong> option on the "<strong>Specified named task</strong>"</p>
<p><strong>5.</strong> Click "<strong>Save settings</strong>" on the bottom right corner.</p>
<h2>Configuration (for Full version)</h2>
<p><strong>1.</strong> Right click the Cmder's titlebar and choose "<strong>Settings...</strong>" (or press Win - Alt - P) and the settings panel should open.</p>
<p><strong>2.</strong> On the left navigation select "<strong>Startup / Tasks</strong>" and click "<strong>Add default tasks...</strong>" button.</p>
<p><strong>3.</strong> On the "<strong>Predefined tasks</strong>" menu select <strong>{Git bash}</strong> and add text '-new_console:d:C:\www' where 'C:\www' is your working projects root folder (can be any folder you want). The whole setting should look like this:</p>
<pre>"%ProgramFiles%\Git\bin\sh.exe" --login -i <br />-new_console:d:C:\www</pre>
<p><strong>4.</strong> Now select "<strong>Startup</strong>" element on the left navigation and select <strong>{Git bash}</strong> option on the "<strong>Specified named task</strong>"</p>
<p><strong>5.</strong> Click "<strong>Save settings</strong>" on the bottom right corner.</p>http://www.numencode.com/post/cmder-console-emulator-for-windows/2016-05-01T20:00:00+02:00Format Hard Drive Partition with DiskPart Command Line<p>Format disk is necessary before using and sometimes you need to format disk partition in a terminal for it to work properly.</p>
<p>It can happen, that some other operating system formatted your disk (or USB drive) and now you don't see it on My computer. In that case, use DiskPart.</p>
<p><strong>1.</strong> Start CMD (Windows Terminal): click Windows button, type 'cmd' and push Enter.</p>
<p><strong>2.</strong> In the command line type:</p>
<pre class="nb-console">diskpart</pre>
<p><strong>3.</strong> Check available disks</p>
<pre class="nb-console">DISKPART> list disk</pre>
<p><strong>4.</strong> Select a disk, you want to format (eg. 3)</p>
<pre class="nb-console">DISKPART> select disk 3</pre>
<p><strong>5.</strong> Clean the selected disk</p>
<pre class="nb-console">DISKPART> clean</pre>
<p><strong>6.</strong> Create a primary partition</p>
<pre class="nb-console">DISKPART> create partition primary</pre>
<p><strong>7.</strong> Select first partition</p>
<pre class="nb-console">DISKPART> select partition 1</pre>
<p><strong>8.</strong> Format the partition (to eg. fat32)</p>
<pre class="nb-console">DISKPART> format fs=fat32 quick</pre>
<p><strong>9.</strong> Exit the DiskPart</p>
<pre class="nb-console">DISKPART> exit</pre>
<p>Your disk is now properly formatted.</p>http://www.numencode.com/post/format-hard-drive-partition-with-diskpart-command-line/2016-04-30T20:00:00+02:00Subversion SVN for command-line (console)<p>Download appropriate package for you OS from: <a href="https://subversion.apache.org/packages.html">https://subversion.apache.org/packages.html</a></p>
<p>I use Win32Svn for Windows and it works great.</p>
<p> </p>
<p>Show SVN help</p>
<pre class="nb-console">svn help</pre>
<p>View SVN info</p>
<pre class="nb-console">svn info</pre>
<p>View SVN status</p>
<pre class="nb-console">svn status</pre>
<p>Update SVN repository</p>
<pre class="nb-console">svn update</pre>
<p>Commit to SVN repository</p>
<pre class="nb-console">svn commit -m "This is a commit message."</pre>
<p>Merge branch</p>
<pre class="nb-console">svn merge ^/branches/branchname</pre>
<p>Checkout branch</p>
<pre class="nb-console">svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch</pre>
<p>Switch to branch</p>
<pre class="nb-console">svn switch http://svn.example.com/repos/calc/branches/my-calc-branch</pre>http://www.numencode.com/post/subversion-svn-for-command-line-console/2016-04-30T20:00:00+02:00Install VMware tools on Ubuntu Server<p><strong>1.</strong> Enable Shared folders</p>
<p>Edit virtual machine settings, go to Options / Shared folders, set to Always enabled and add a host folder to the Folders list. Run virtual machine and login to Ubuntu Server with your username and password.</p>
<p><strong>2.</strong> Update package repository</p>
<pre class="nb-console">sudo apt-get update</pre>
<p><strong>3.</strong> Instal dependencies</p>
<pre class="nb-console">sudo apt-get install gcc binutils make linux-source</pre>
<p><strong>4.</strong> Start with the VMware Tools installation</p>
<p>Click "Install VMware Tools..." in the window menu of the virtual machine. If the prompt window appears (Disconnect anyway and override the lock?), click Yes.</p>
<p><strong>5.</strong> Create mount directory for CD-ROM</p>
<pre class="nb-console">sudo mkdir /mnt/cdrom</pre>
<p><strong>6.</strong> Mount virtual CD-ROM to created folder</p>
<pre class="nb-console">sudo mount /dev/cdrom /mnt/cdrom</pre>
<p><strong>7.</strong> Extract .tar file</p>
<pre class="nb-console">sudo tar xzvf /mnt/cdrom/VMwareTools-?.?.?-???????.tar.gz -C /tmp/</pre>
<p>Tar file should be named as the file that is listed in the /mnt/cdrom folder.</p>
<p><strong>8.</strong> Navigate to the extracted location</p>
<pre class="nb-console">cd /tmp/vmware-tools-distrib</pre>
<p><strong>9.</strong> Run installation</p>
<pre class="nb-console">sudo ./vmware-install.pl -d</pre>
<p><strong>10.</strong> Reboot the system and the VMware Tools are installed.</p>
<pre class="nb-console">sudo reboot</pre>http://www.numencode.com/post/install-vmware-tools-on-ubuntu-server/2016-04-29T20:00:00+02:00Configure static local IP on Raspberry Pi Raspbian<p><strong>1.</strong> Login to your Raspberry Pi and check your networking</p>
<pre class="nb-console">ifconfig</pre>
<pre>eth0 Link encap:Ethernet HWaddr 00:0c:29:7c:05:22 <br /> inet addr:<strong>192.168.1.123</strong> Bcast:<strong>192.168.1.255 </strong>Mask:<strong>255.255.255.0</strong> <br /> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1</pre>
<p><strong>2.</strong> Edit the network config file »interfaces«</p>
<pre class="nb-console">sudo nano /etc/network/interfaces</pre>
<p><strong>3.</strong> You will see these lines</p>
<pre># interfaces(5) file used by ifup(8) and ifdown(8)<br /># Please note that this file is written to be used with dhcpcd<br /># For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'<br /><br /># Include files from /etc/network/interfaces.d:<br />source-directory /etc/network/interfaces.d<br /><br />auto lo<br />auto eth0<br /><br />iface lo inet loopback<br />iface eth0 inet dynamic<br /><br />allow-hotplug wlan0<br />iface wlan0 inet manual<br /> wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf<br /><br />allow-hotplug wlan1<br />iface wlan1 inet manual<br /> wpa-conf /etc/wpa_supplicant/wpa_supplicant.con</pre>
<p><strong>4.</strong> Change the lines to this configuration (don't mind the comments)</p>
<pre># interfaces(5) file used by ifup(8) and ifdown(8)<br /># Please note that this file is written to be used with dhcpcd<br /># For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'<br /><br /># Include files from /etc/network/interfaces.d:<br />source-directory /etc/network/interfaces.d<br /><br />auto lo<br />auto eth0<br /><br />iface lo inet loopback<br />iface eth0 inet static # dynamic is changed to static <br />address 192.168.1.100 # your custom local IP <br />netmask 255.255.255.0 # same as Mask on ifconfig <br />network 192.168.1.0 # same as Bcast on ifconfig but with the zero at the end<br />broadcast 192.168.1.255 # same as Bcast on ifconfig<br />gateway 192.168.1.1 # default local network IP <br />dns-nameservers 8.8.8.8 8.8.4.4 # Google's DNS servers<br /><br />allow-hotplug wlan0<br />iface wlan0 inet manual<br /> wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf<br /><br />allow-hotplug wlan1<br />iface wlan1 inet manual<br /> wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf</pre>
<p><strong>5.</strong> Save the file and restart networking</p>
<pre class="nb-console">sudo /etc/init.d/networking restart</pre>
<p><strong>6.</strong> Check your local static IP</p>
<pre class="nb-console">ifconfig</pre>
<pre>eth0 Link encap:Ethernet HWaddr 00:0c:29:7c:05:22 <br /> inet <strong>addr:192.168.1.100</strong> Bcast:192.168.1.255 Mask:255.255.255.0 <br /> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1</pre>
<p><strong>7.</strong> You may have to reboot your Raspberry Pi</p>
<pre class="nb-console">sudo reboot</pre>
<p><em>Note: You can also edit /etc/resolv.conf but these changes will be overwritten on reboot.</em></p>http://www.numencode.com/post/configure-static-local-ip-on-raspberry-pi-raspbian/2016-04-28T20:00:00+02:00Package repositories on Ubuntu Server<h1>Package repositories</h1>
<p>Update the package repositories from sources with the latest versions</p>
<pre class="nb-console">sudo apt-get update</pre>
<p>A list of repositories, that the server will check for packages, is stored at <strong><em>/etc/apt/sources.list</em></strong></p>
<pre class="nb-console">cat /etc/apt/sources.list</pre>
<p>Extra repositories can be added to <strong><em>/etc/apt/sources.list.d</em></strong></p>
<h1>Package information</h1>
<p>Search for available packages (eg. mysql); to search only by the package name, use -n tag.</p>
<pre class="nb-console">sudo apt-cache search mysql</pre>
<pre class="nb-console">sudo apt-cache search -n mysql</pre>
<p>Get the package information (eg. mysql-server-5.6)</p>
<pre class="nb-console">sudo apt-cache show mysql-server-5.6</pre>
<h1>Install/uninstall a package</h1>
<p>Install a package || without prompting use tag -y || for quiet install use tag -qq</p>
<pre class="nb-console">sudo apt-get install -y mysql-server-5.6</pre>
<p>Uninstall a package ('purge' removes the configuration, 'remove' removes only the package)</p>
<pre class="nb-console">sudo apt-get purge mysql-server-5.6</pre>
<p>After uninstalling use <em>autoremove</em> to remove any dependencies that are not in use by other packages</p>
<pre class="nb-console">sudo apt-get autoremove</pre>
<h1>List all installed packages</h1>
<p>Get a list of packages installed locally (the -v tag "inverts" grep to return non-matching lines)</p>
<pre class="nb-console">dpkg --get-selections | grep -v deinstall</pre>
<p>Get a list of a specific package installed</p>
<pre class="nb-console">dpkg --get-selections | grep mysql</pre>
<p>Alternatively, simply use</p>
<pre class="nb-console">dpkg -l</pre>
<p>Get just the packages which were expressly installed (not just installed as dependencies)</p>
<pre class="nb-console">aptitude search '~i!~M'</pre>
<p> </p>http://www.numencode.com/post/package-repositories-on-ubuntu-server/2016-04-27T21:00:00+02:00Install & configure Samba Server on Ubuntu VM<h1>1. Install Samba</h1>
<p>The first thing we need to do is to update the package repositories and then install Samba.</p>
<pre class="nb-console">sudo apt-get update</pre>
<pre class="nb-console">sudo apt-get install samba</pre>
<h1>2. Configure Samba</h1>
<p>Now we'll have to add a few lines to the Samba configuration file <strong><em>/etc/samba/smb.conf</em></strong> to make everything work.</p>
<pre>[global]<br /> # The following property ensures that the existing files do not have their<br /> # permissions reset to the "create mask" (defined below) if they are changed<br /> map archive = no<br /> <br /> # Notify upon file changes so that Windows can detect such changes<br /> change notify = yes<br /> <br /> # Configure shared folder for your user where "developer" is your Linux username<br /> [developer]<br /> comment = Developer Files<br /> path = /home/shared<br /> guest ok = no<br /> browseable = yes<br /> writable = yes<br /> create mask = 0664<br /> directory mask = 0775</pre>
<p>Save and close the config file and then add a Samba user and password identical to your Linux user account.</p>
<pre class="nb-console">sudo smbpasswd -a developer</pre>
<p>Restart Samba so that the config can be re-read.</p>
<pre class="nb-console">sudo service smbd restart</pre>
<p>Your Windows host should now have access to the shared folder. To access the shared folder, open a folder browser and type in:</p>
<pre>\\*ubuntu-local-ip-address*\developer (e.g. \\192.168.1.100\developer)</pre>
<p>To find out what your local IP address is, got to your Ubuntu server terminal and type:</p>
<pre class="nb-console">ifconfig</pre>
<p> </p>
<p> </p>http://www.numencode.com/post/install-configure-samba-server-on-ubuntu-vm/2016-04-27T20:00:00+02:00Simple CSS Parallax effect<p>Create a div block with class 'parallax'</p>
<pre><div class="parallax"></div></pre>
<p>Apply CSS code (use your own background image path)</p>
<pre>.parallax {<br /> min-height: 600px;<br /> background-image: url("images/background.jpg");<br /> background-position: 50% 50%;<br /> background-repeat: no-repeat;<br /> background-attachment: fixed;<br /> background-size: cover;<br />}</pre>http://www.numencode.com/post/simple-css-parallax-effect/2016-04-26T20:00:00+02:00Apache2 - Configure multiple websites (virtual hosts)<p><strong>1.</strong> Login to your Ubuntu Server, navigate to and list »sites-available« directory</p>
<pre class="nb-console">cd /etc/apache2/sites-available </pre>
<pre class="nb-console">ll</pre>
<p><strong>2.</strong> You should see the files:</p>
<pre>000-default.conf<br />default-ssl.conf</pre>
<p><strong>3.</strong> Disable the default site configuration</p>
<pre class="nb-console">sudo a2dissite 000-default.conf </pre>
<p><strong>4.</strong> Create a copy of the default configuration file and open it for edit</p>
<pre class="nb-console">sudo cp 000-default.conf yourdomain-com.conf </pre>
<pre class="nb-console">sudo nano yourdomain-com.conf </pre>
<p><strong>5.</strong> Enter the configuration (you can delete the comments) in this manner</p>
<pre><VirtualHost *:80><br /> ServerName yourdomain.com<br /> ServerAdmin info@yourdomain.com<br /><br /> DocumentRoot /var/www/yourdomain.com<br /><br /> ErrorLog ${APACHE_LOG_DIR}/yourdomain.com-error.log <br /> CustomLog ${APACHE_LOG_DIR}/yourdomain.com-access.log combined <br /></VirtualHost> </pre>
<p><strong>6.</strong> Save and exit the file edit mode</p>
<p><strong>7.</strong> Enable the yourdomain.com site configuration</p>
<pre class="nb-console">sudo a2ensite yourdomain-com.conf </pre>
<p><strong>8.</strong> Be sure to create appropriate directory and set permissions</p>
<pre class="nb-console">cd /var/www/</pre>
<pre class="nb-console">sudo mkdir yourdomain.com</pre>
<pre class="nb-console">sudo chown username:username yourdomain.com -R</pre>
<p>(use your own Ubuntu Server username)</p>
<p><strong>9.</strong> Reload Apache2 server</p>
<pre class="nb-console">sudo service apache2 reload</pre>http://www.numencode.com/post/apache2-configure-multiple-websites-virtual-hosts/2016-04-12T21:00:00+02:00Configure SSH to connect to a Remote Ubuntu Server<p><strong>1.</strong> On your Windows machine I suggest installing <strong>Cmder</strong> console emulator, visit <a href="http://cmder.net/" target="_blank">http://cmder.net/</a> and then download and install the Full package (with git-for-windows)</p>
<p><strong>2.</strong> Open Cmder or other console software on your Windows machine, navigate to root directory, create .ssh directory and enter it</p>
<pre class="nb-console">cd ~</pre>
<pre class="nb-console">mkdir .ssh</pre>
<pre class="nb-console">cd .ssh</pre>
<p><strong>3.</strong> Create SSH key pair id_rsa & id_rsa.pub (-t is type, -b is bytes, -f is filename)</p>
<pre class="nb-console">ssh-keygen -t rsa -b 4096 -f id_rsa -C "email@domain.com"</pre>
<p><strong>4.</strong> Display the public key on the screen, select the printed text and copy it to clipboard</p>
<pre class="nb-console">cat id_rsa.pub</pre>
<p><strong>5.</strong> Login to your Ubuntu Server and install OpenSSH in case you don't have it yet</p>
<pre class="nb-console">sudo apt-get install openssh-server</pre>
<p>Before you do that, don't forget to update the repositories with:</p>
<pre class="nb-console"> sudo apt-get update</pre>
<p><strong>6.</strong> On your Ubuntu Server machine, navigate to root directory, create .ssh directory and enter it</p>
<pre class="nb-console">cd ~</pre>
<pre class="nb-console">sudo mkdir .ssh</pre>
<pre class="nb-console">cd .ssh </pre>
<p><strong>7.</strong> Create a file authorized_keys and open it for edit</p>
<pre class="nb-console">touch authorized_keys </pre>
<pre class="nb-console">nano authorized_keys </pre>
<p><strong>6.</strong> Paste previously copied public key and paste it to this file</p>
<p><strong>7.</strong> Logout from Ubuntu Server and try to login from your Windows machine</p>
<pre class="nb-console">ssh username@<em>192.168.1.100</em></pre>
<p>(use your own Ubuntu Server root username & IP address)</p>
<p><strong>8.</strong> If you're connecting to eg. GitHub via SSH, test your connection with this command:</p>
<pre class="nb-console">ssh -T git@github.com</pre>
<hr />
<h2>Copy public SSH key to your server</h2>
<p>When you create SSH key pair on your computer, you can copy the public key to your server via terminal (console).</p>
<pre class="nb-console">cat ~/.ssh/id_rsa.pub | ssh username@<em>192.168.1.100</em> 'cat >> .ssh/authorized_keys && echo "Key copied"'</pre>http://www.numencode.com/post/configure-ssh-to-connect-to-a-remote-ubuntu-server/2016-04-12T20:00:00+02:00Configure static local IP on Ubuntu Server<p>1. Login to your Ubuntu Server and check your networking</p>
<pre class="nb-console">ifconfig</pre>
<pre>eth0 Link encap:Ethernet HWaddr 00:0c:29:7c:05:22 <br /> inet addr:<strong>192.168.1.123</strong> Bcast:<strong>192.168.1.255 </strong>Mask:<strong>255.255.255.0</strong> <br /> inet6 addr: fe80::20c:29ff:fe7c:522/64 Scope:Link</pre>
<p>2. Edit the network config file »interfaces«</p>
<pre class="nb-console">sudo nano /etc/network/interfaces</pre>
<p>3. You will see these two lines</p>
<pre>auto eth0 <br />iface eth0 inet static</pre>
<p>4. Change the lines to this configuration (don't mind the comments)</p>
<pre>auto eth0 <br />iface eth0 inet static #dynamic is changed to static <br />address 192.168.1.100 #your custom local IP <br />netmask 255.255.255.0 #same as on ifconfig Mask <br />gateway 192.168.1.1 #default local network IP <br />broadcast 192.168.1.255 #same as on ifconfig Bcast <br />dns-nameservers 8.8.8.8 8.8.4.4 #Google's DNS servers</pre>
<p>5. Save the file and restart networking</p>
<pre class="nb-console">sudo /etc/init.d/networking restart</pre>
<p>6. Check your local static IP</p>
<pre class="nb-console">ifconfig</pre>
<pre>eth0 Link encap:Ethernet HWaddr 00:0c:29:7c:05:22 <br /> inet <strong>addr:192.168.1.100</strong> Bcast:192.168.1.255 Mask:255.255.255.0 <br /> inet6 addr: fe80::20c:29ff:fe7c:522/64 Scope:Link</pre>
<p>7. Important: if you're doing this on virtual machine (VirtualBox, VMware), you may have to reboot</p>
<pre class="nb-console">sudo reboot</pre>http://www.numencode.com/post/configure-static-local-ip-on-ubuntu-server/2016-04-11T20:00:00+02:00Apache2 enable / disable sites & modules<p>Enable site (virtual host)</p>
<pre class="nb-console">sudo a2ensite [filename.conf]</pre>
<p>Disable site</p>
<pre class="nb-console">sudo a2dissite [filename.conf]</pre>
<p>Enable an apache2 module</p>
<pre class="nb-console">sudo a2enmod [module_name]</pre>
<p>Disable an apache2 module</p>
<pre class="nb-console">sudo a2dismod [module_name]</pre>
<p>Force reload the server</p>
<pre class="nb-console">sudo /etc/init.d/apache2 force-reload</pre>
<p>OR</p>
<pre class="nb-console">sudo service apache2 reload</pre>http://www.numencode.com/post/apache2-enable-disable-sites-modules/2016-04-10T20:00:00+02:00