Category Archives: Programming
[Android Study Jam] Unit 1: Kotlin basics for Android (Notes)
Install Ruby on Rails with rbenv on RHEL 7.5
Install Dependencies
yum install git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl postgresql-devel
Install rbenv
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec $SHELL
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
exec $SHELL
Rails authentication with Microsoft Active Directory
Following sample code shows how Rails integrates with Microsoft Active Directory using net-ldap gem.
Active Directory Environment: Windows Server 2012 R2
Development Environment: CentOS 7.5
Rails Version: 5.2.0
Continue reading
Using popen to get stdout
This is an example to check connection state for a specific port number. It returns command output.
Sorting – Quick Sort
Time complexity:
Worst-case: \(O(n^2)\)
Best-case: \(O(nlog(n))\)
Average-case: \(O(nlog(n))\)
Pick a random element (pivot) and partition the array.
[all numbers that are less than the pivot] pivot [all numbers that are greater than the pivot]
Sorting – Merge Sort
Time complexity:
Worst-case: \(O(nlog(n))\)
Best-case: \(O(nlog(n))\)
Average-case: \(O(nlog(n))\)
Merge sort divides the array in half, sorts each of those halves, and them merges them back together.
Sorting – Selection Sort
Time complexity:
Worst-case: \(O(n^2)\)
Best-case: \(O(n^2)\)
Average-case: \(O(n^2)\)
Find the smallest element and move it to the front. Then, find the second smallest and move it.
Sorting – Bubble Sort
Time complexity:
Worst-case: \(O(n^2)\)
Best-case: \(O(n)\)
Average-case: \(O(n^2)\)
Sort array elements in ascending order. If the first element is greater than the second element, swap the first two elements.
Then, we go to the “next pair” and so on.
C Pointer
Pointer Related: Array, Structure, Single Pointer (*), Double Pointer (**), Reference (&)