Skip to content

Instantly share code, notes, and snippets.

View lordhasyim's full-sized avatar
🏠
Working from home

ahmadhasyim lordhasyim

🏠
Working from home
View GitHub Profile
@lordhasyim
lordhasyim / bongo.sh
Created September 12, 2017 09:32 — forked from smashew/bongo.sh
This one works... Tested
LOADING=false
usage()
{
cat << EOF
usage: $0 [options] dbname
OPTIONS:
-h Show this help.
-l Load instead of export
@lordhasyim
lordhasyim / pagination.html.twig
Created September 26, 2017 05:53 — forked from SimonSimCity/pagination.html.twig
A gist for pagination in Twig, based on the total number of pages, the current page and some URL-settings.
{#
Source: http://dev.dbl-a.com/symfony-2-0/symfony2-and-twig-pagination/
Updated by: Simon Schick <simonsimcity@gmail.com>
Parameters:
* currentFilters (array) : associative array that contains the current route-arguments
* currentPage (int) : the current page you are in
* paginationPath (string) : the route name to use for links
* showAlwaysFirstAndLast (bool) : Always show first and last link (just disabled)
* lastPage (int) : represents the total number of existing pages
@lordhasyim
lordhasyim / README.md
Created October 2, 2017 15:23 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@lordhasyim
lordhasyim / GitCommitEmoji.md
Created October 4, 2017 04:28 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji

Say I have 5 files: (file1, file2, ... file5).

All have been commited.

Say now all 5 files have been changed.

When you issue git status, all 5 files should be shown as (red) unstaged status.

Say I am happy with the changes in file1 to file4, but not file5 (i.e. I'd like to revert file5 to the last committed stage).

@lordhasyim
lordhasyim / git_cheat-sheet.md
Created October 9, 2017 03:35 — forked from davfre/git_cheat-sheet.md
git commandline cheat-sheet
@lordhasyim
lordhasyim / objects_arrays.md
Created October 9, 2017 07:08 — forked from nikic/objects_arrays.md
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

[abc] A single character: a, b or c
[^abc] Any single character but a, b, or c
[a-z] Any single character in the range a-z
[a-zA-Z] Any single character in the range a-z or A-Z
^ Start of line
$ End of line
\A Start of string
\z End of string
. Any single character
\s Any whitespace character

@lordhasyim
lordhasyim / Artisan.php
Created December 21, 2017 09:20
Laravel Cheat Sheet
php artisan --help OR -h
php artisan --quiet OR -q
php artisan --version OR -V
php artisan --no-interaction OR -n
php artisan --ansi
php artisan --no-ansi
php artisan --env
// -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
php artisan --verbose
@lordhasyim
lordhasyim / linkify.php
Created January 2, 2018 04:26 — forked from jasny/linkify.php
PHP function to turn all URLs in clickable links
<?php
/**
* Turn all URLs in clickable links.
*
* @param string $value
* @param array $protocols http/https, ftp, mail, twitter
* @param array $attributes
* @param string $mode normal or all
* @return string
*/