Skip to content

Instantly share code, notes, and snippets.

View isogram's full-sized avatar
🙊

Muhammad Shidiq isogram

🙊
View GitHub Profile
@isogram
isogram / .htaccess
Last active August 29, 2015 14:20 — forked from ScottPhillips/.htaccess
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@isogram
isogram / nginx.conf
Last active August 29, 2015 14:20 — forked from neara/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
@isogram
isogram / cronjob
Created June 25, 2015 05:05
Cronjob Manual
# Minute Hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
5 8 * * Sat /usr/bin/find
@isogram
isogram / get_followers_following_list.sql
Created August 18, 2015 05:28
Query to get users by keyword order by match
SELECT
t1.user_id,
t1.user_uuid,
t1.first_name,
t1.last_name,
t1.user_name,
IF (t2.follow_status, 1, 0) AS is_following,
IF (t3.follow_status, 1, 0) AS is_followers
FROM
t_user t1
@isogram
isogram / regex_hashtag.md
Last active August 29, 2015 14:28
Regex Hashtag
  1. Catch hashtag exclude starting and ending with underscore
    (?:\s|^)(?:#(?!(?:\d+|\w+?_|_\w+?)(?:\s|$)))(\w+)(?=\s|$)
  2. Catch hashtag include starting and ending with underscore
    (?:\s|^)(?:#(?!\d+(?:\s|$)))(\w+)(?=\s|$)
  3. Catch repeating words (only catch 1 if duplicate) (?!.*\b\1\b)

You can test regex at https://regex101.com/

Image Processing with ImageMagick

  • Resize and crop with mogrify
    mogrify /path/to/folder/ -format jpg -resize "64x64^" -gravity center -crop 64x64+0+0 +repage *.jpg
    mogrify /path/tp/folder/ -format jpg -thumbnail 64x64^ -gravity center -extent 64x64 *.*
@isogram
isogram / update_mysql_5.5_to_5.6.md
Created December 21, 2015 09:44
Update MySQL version from 5.5 to 5.6 on Ubuntu Server

step 1 : take a backup

mysqldump --lock-all-tables -u root -p --all-databases > dump.sql

step 2 : remove old mysql

sudo apt-get remove mysql-server
sudo apt-get autoremove
@isogram
isogram / jquery.parseparams.js
Created January 11, 2016 10:34 — forked from kares/jquery.parseparams.js
jQuery.parseParams - parse query string paramaters into an object
/**
* $.parseParams - parse query string paramaters into an object.
*/
(function($) {
var re = /([^&=]+)=?([^&]*)/g;
var decodeRE = /\+/g; // Regex for replacing addition symbol with a space
var decode = function (str) {return decodeURIComponent( str.replace(decodeRE, " ") );};
$.parseParams = function(query) {
var params = {}, e;
while ( e = re.exec(query) ) {
@isogram
isogram / app_service_provider.md
Created April 1, 2016 14:50
AppServiceProvider Laravel 5.1 Not Firing

Fix AppServiceProvider Laravel 5.1 not firing

  1. php artisan clear-compiled
  2. Delete file service.json in bootstrap/cache
  3. Change $defer property to false
  4. Check AppServiceProvider, is it working now?
  5. Change back $defer to true again
@isogram
isogram / week_to_date.sql
Created May 13, 2016 10:29
Get Date Range From Week Number
select
STR_TO_DATE(concat(tgl, ' Monday'),'%x%v %W') date_start,
STR_TO_DATE(concat(tgl, ' Sunday'),'%x%v %W') date_end
from
(
select
date_format(updated_at, "%Y%v") as tgl,
count(1) as counter
from table
group by tgl