Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
Cool

Awolad hossain awolad

😎
Cool
View GitHub Profile
@awolad
awolad / bash_strict_mode.md
Created Jul 1, 2021 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
View bash_strict_mode.md

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
View apitest-cells.php
<?php
require_once realpath(dirname(__FILE__) . '/vendor/autoload.php');
include_once "google-api-php-client/examples/templates/base.php";
$client = new Google_Client();
/************************************************
ATTENTION: Fill in these values, or make sure you
have set the GOOGLE_APPLICATION_CREDENTIALS
@awolad
awolad / Laravel-Container.md
Created May 16, 2020 — forked from davejamesmiller/Laravel-Container.md
Laravel's Dependency Injection Container in Depth
View Laravel-Container.md

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

@awolad
awolad / post-type.php
Created Oct 17, 2019 — forked from forkbombe/post-type.php
An example of how to create a WordPress Custom Post type using an Object Oriented approach
View post-type.php
<?php
/**
* Use namespace to avoid conflict
*/
namespace PostType;
/**
* Class Event
* @package PostType
*
@awolad
awolad / group-objects-by-property.md
Created Jun 21, 2019 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value
View group-objects-by-property.md

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
View javaScriptMergeObject.js
var array1 = [{
agentID: 28,
bookingDates: ["2019-02-01,2019-03-04"],
roomNo: [101],
roomID: [1]
}, {
agentID: 29,
bookingDates: ["2019-02-01,2019-03-02"],
roomNo: [301],
roomID: [3]
View inArrayMultiDymension.php
<?php
// check only array value
function in_array_r($needle, $haystack, $strict = false)
{
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) ||
(is_array($item) && in_array_r($needle, $item, $strict))) {
return true;
}
@awolad
awolad / iterm2-solarized.md
Created Dec 19, 2018 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)
View iterm2-solarized.md

Default

Default

Powerlevel9k

Powerlevel9k

View atom.js
// Packages:
// file-icons
// language-vue
// platformio-ide-terminal
View visualStudioCode.js
// Extension: beautify, Material icon theme, Material theme, Atom one dark, vtuer
// Options: auto save enabled, Vue file formatting: "vetur.format.defaultFormatter.html": "js-beautify-html" (https://github.com/vuejs/vetur/issues/543)
------------------------------------------------------------------------------------------
// setting from Japanese during working on igs - grow-academic-dashboard
{
"editor.formatOnSave": true,
"workbench.colorTheme": "Atom One Dark",
"workbench.iconTheme": "material-icon-theme",
"editor.fontSize": 16,