Skip to content

Instantly share code, notes, and snippets.

Muhamad Fajar heyost

Block or report user

Report or block heyost

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
heyost /
Created Aug 23, 2017
Django favicon
# example using favicon on Django Admin
from django.conf.urls import url
from django.contrib import admin
from django.views.generic import RedirectView
from muhfajar.settings import STATIC_URL
urlpatterns = [
url(r'^favicon\.ico$', RedirectView.as_view(url=STATIC_URL + 'path_to_favicon.ico')),
heyost /
Created Jul 26, 2017
Simple script to check new version of Atom on Fedora
# source -
ATOM_INSTALLED_VERSION=$(rpm -qi atom | grep "Version" | cut -d ':' -f 2 | cut -d ' '$
echo Installed version: $ATOM_INSTALLED_VERSION
echo Latest version: $ATOM_LATEST_VERSION
echo ------------------------------------
heyost /
Created Mar 17, 2017
Simple script to change httpd/apache configuration file

First run this outside script sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.bak.conf

Make sure, you have 2 php version installed on computer, and create 2 configuration httpd/apache file to easy change php version

After script created, save on home and use bashrc to create alias e.g. alias switch-php=". ~/Script/" put on last line, restart bash, and excute switch-php 7 to change php to version 7, and switch-php 56 to change to php version 56

heyost /
Created Mar 9, 2017
Update all Python PIP
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 sudo pip install -U
View Powerline show Git
mkdir -p ~/.config/powerline
cat <<-'EOF' > ~/.config/powerline/config.json
"ext": {
"shell": {
"theme": "default_leftonly"
heyost /
Created Sep 17, 2016
simple php server, like "php artisan serve"
# simple php server, like "php artisan serve"
# put this file 1 folder behind root directory
# e.g. this file on folder "project"
# and inside "project" folder have 1 folder contain codeigniter project,
# so root folder is name of folder with contain project
echo "Type root directory, followed by [ENTER]:"
read root
heyost / httpd-vhosts.conf
Last active Aug 7, 2016
Create dynamic Laravel project vhost on Arch Linux
View httpd-vhosts.conf
# Custom vhost laravel wildcard
# enable vhost_alias_module first on httpd.conf
<VirtualHost *:80>
ServerAlias *
# This will be the wildcarded document root. Any folder you create in /srv/http/php/laravel/* will be automatically a subdomain name.
VirtualDocumentRoot /srv/http/php/laravel/%-3/public
heyost / clickable_url.php
Created Jun 30, 2016
Regex clickable URL from plain string
View clickable_url.php
function clickable_url($plain_text)
// check all url with http:// pattern
$pattern_http = '~([^<>]*>)(*SKIP)(*F)|'; // skip url check if inside html tag
$pattern_http .= '([-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+.[a-zA-Z])(*SKIP)(*F)|'; // skip email pattern
$pattern_http .= '(?:(?:ht|f)tps?://)'; // find url with http | https | ftp | ftps
$pattern_http .= '[\w-]+'; // host name
$pattern_http .= '(?:\.[\w-]+)+'; // domain name
$pattern_http .= '[\w-.,@?^=%&:/\~+#!]*[\w-@?^=%&/\~+#]~xiuS'; // path name
View get_past_1_week_and_1_week_present_on_MySQL.sql
# 1 week past
SELECT DATE_ADD("2016-02-04", INTERVAL(-6-DAYOFWEEK("2016-02-04")) DAY) AS start, DATE_ADD("2016-02-04", INTERVAL(0-DAYOFWEEK("2016-02-04")) DAY) AS FINISH
# present week
SELECT DATE_ADD("2016-02-04", INTERVAL(1-DAYOFWEEK("2016-02-04")) DAY) AS start, DATE_ADD("2016-02-04", INTERVAL(7-DAYOFWEEK("2016-02-04")) DAY) AS FINISH
heyost / polymer-import.php
Last active Dec 18, 2015
Simple polymer custom elements import using PHP
View polymer-import.php
$list = ['custom_elements_folder1', 'custom_elements_folder2'];
$num = 0;
for($num; $num < count($list); $num++){
$dir = glob($list[$num] . '/*');
foreach ($dir as $file) {
if(is_file($file) && strpos($file, '.html')){
echo "<link rel=\"import\" href=\"" . $file . "\">\n";
} else{
echo $file[0];
You can’t perform that action at this time.