Access Laravel Site Without “Public” Folder Using Alias in AWS EC2

Recently, I had an issue with laravel project settings, especially to get rid of public and index.php from url to access the site. For example, http://example.com/mylaravel/public/challenges, or, http://example.com/mylaravel/index.php/challenges, etc.

I came through some solutions from StackOverflow or whatever, and they suggested me to use .htaccess, apache rewrite, or aliasing, etc. Some gave good solution, and some others not. Although they somehow worked, I felt a bit tempting to know the best practices, especially to prevent  attacher/hacker.

So overall, I received two recommendations: using .htaccess or aliasing in apache configurations (please let me know if anyone of you know any better options, that would be much appreciated). However, I will only put my solution here. Continue reading

Aplikasi Kasir Sederhana untuk POS

Aplikasi kasir untuk POS ini menghadirkan fitur-fitur yang sederhana tapi esensial. Aplikasi ini khusus dibuat untuk kafe atau restoran kecil yang baru mulai dan hanya membutuhkan aplikasi kasir sederhana. Silakan menghubungi saya apabila tertarik untuk memperoleh jasa pemasangan aplikasi ini. Untuk memperjelas, fitur-fitur dan kebutuhan-kebutuhan yang disediakan antara lain:

1. Monitoring pengunjung

Monitoring Continue reading

Python Bit Manipulation

Bit manipulation is used to solve variety of problems. Furthermore, its purpose is simply for optimizing code. However, every language has different implementation of bit manipulation. This piece of writing delivers the idea of python ways to do bit manipulation.

Documentation of bit manipulation in python could be found here, https://wiki.python.org/moin/BitManipulation. Furthermore there is also bitwise operator https://wiki.python.org/moin/BitwiseOperators.

Additionally, python bit manipulation has similar way with C. Basically, “&”, “|”, and “^” is just the same. However, ~ is a complement in python. Practices could be found below.

In Bit 

1001 + 0010 = 1011 0011 * 0010 = 0110 (shift to left 1) 0010 + 0010 = 0100
0110 + 0100 = 1010 0010 * 0100 = 1000 (shift to left 2) 0011 * 0011 = 1001
1000 – 0010 = 0110 0101 >> 2 = 0001 1001 ^ (~1001) = 1 (xor with negative)
0100 – 0010 = 0010 1010 ^ 0011 = 1001 0011 & (~0 << 2) = 1111

In python

>>>17 + 2 >>>3 << 1 >>>2 + 2
>>> 6 + 4 >>> 2 << 2 >>> 3 * 3
>>>8 – 2 >>>5 >> 2 >>> 9 ^ ~9 (complement)
>>> 4 – 2 >>>10 ^ 3 3 & (~0 << 2) (complement)

Codeforces #1A: Theatre Square

You can find this in: http://codeforces.com/problemset/problem/1/A

My solution: https://github.com/masphei/ProblemSolver/tree/master/Square

Theatre Square
time limit per test2 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output

Theatre Square in the capital city of Berland has a rectangular shape with the size n?×?m meters. On the occasion of the city’s anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a?×?a.

What is the least number of flagstones needed to pave the Square? It’s allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It’s not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square.

Input
The input contains three positive integer numbers in the first line: n,??m and a (1?=??n,?m,?a?=?109).

Output
Write the needed number of flagstones.

Sample test(s)
input
6 6 4
output
4

 

Flow Control Using UDP in Linux

Problem

Flow control mechanism is needed by tools which transfer data faster than its data consuming mechanism. Practically, it transfers data quickly, but consumes data slowly. Flow control happens in layer data link.

Conditions:

  • There are two programs which are transmitter and receiver.
  • Sender: sending messages
  • Receiver: receiving messages
  • Sender sends messages too fast
  • Receiver consumes messages too slow

Solution: Buffering

Issue: buffering does not solve the exact problems, it only holds overflow and overrun.

Alternatives:

  • Feedback-based flow control
  • Rate-based flow control (discussed later)

Continue reading