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
# SYNTAX:
var pattern = new RegExp(pattern, attributes); # attributes: g (global); i (case-sensitive); m (multiline matches)
var pattern = /pattern/attributes; # same as above
# BRACKETS:
[...]: Any one character between the brackets.
[^...]: Any one character not between the brackets.
@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 / playstore_crawler.php
Created October 7, 2015 10:52
Playstore Crawler PHP using Symfony/DomCrawler and GuzzleHttp
<?php
use Cache; // alias from laravel
use Symfony\Component\DomCrawler\Crawler;
use GuzzleHttp\Client;
public function parsePlayStore($url='')
{
$parsedUrl = parse_url($url, PHP_URL_QUERY);
$packageNameFromUrl = 'com.inponsel.android';
@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) ) {