Skip to content

Instantly share code, notes, and snippets.

View tistaharahap's full-sized avatar

Batista Harahap tistaharahap

View GitHub Profile
MariaDB [fun]> EXPLAIN SELECT * FROM users WHERE last_name = 'Harahap';
+------+-------------+-------+------+---------------+------------+---------+-------+------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+------+---------------+------------+---------+-------+------+-----------------------+
| 1 | SIMPLE | users | ref | last_names | last_names | 53 | const | 2 | Using index condition |
+------+-------------+-------+------+---------------+------------+---------+-------+------+-----------------------+
MariaDB [fun]> CREATE INDEX last_names ON users (last_name);
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [fun]> EXPLAIN SELECT * FROM users WHERE last_name = 'Harahap';
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | users | ALL | NULL | NULL | NULL | NULL | 10 | Using where |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)
MariaDB [fun]> SELECT * FROM users WHERE last_name = 'Harahap';
+----+------------+-----------+
| id | first_name | last_name |
+----+------------+-----------+
| 1 | Batista | Harahap |
| 2 | Rinto | Harahap |
+----+------------+-----------+
2 rows in set (0.00 sec)
MariaDB [fun]> EXPLAIN SELECT * FROM users;
+------+-------------+-------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | users | ALL | NULL | NULL | NULL | NULL | 10 | |
+------+-------------+-------+------+---------------+------+---------+------+------+-------+
MariaDB [fun]> SELECT * FROM users;
+----+------------+------------+
| id | first_name | last_name |
+----+------------+------------+
| 1 | Batista | Harahap |
| 2 | Rinto | Harahap |
| 3 | Michael | Jordan |
| 4 | Chris | Martin |
| 5 | Jordan | Sparks |
| 6 | Daniel | Craig |
SELECT
first_name,
last_name
FROM
names
SELECT * FROM users
CREATE TABLE `names` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
`last_name` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@tistaharahap
tistaharahap / CameraPreview.java
Created April 13, 2015 15:38
Android's Camera Preview to be inserted into a FrameLayout
public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
private SurfaceHolder mHolder;
private Camera mCamera;
private Camera.Size previewSize;
private int containerWidth, containerHeight;
public CameraPreview(Context context, Camera camera, int containerWidth, int containerHeight) {
super(context);