Skip to content

Instantly share code, notes, and snippets.

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

Md Habibullah Al Hadi im4aLL

🏠
Working from home
View GitHub Profile
@im4aLL
im4aLL / Validator.ts
Created July 25, 2018 12:33
angular form custom validation
interface FieldInterface {
name: string;
rules: string[];
}
interface ErrorFieldInterface {
name: string;
message?: string;
}
/*
1. npm install babel-core babel-preset-env babelify browser-sync browserify gulp gulp-autoprefixer gulp-babel gulp-cssnano gulp-rename gulp-sass gulp-uglify gulp-watch vinyl-source-stream --save-dev
2. create file `.babelrc` and insert
{
"presets": ["env"]
}
3. create `src` folder and create `sass` and `js` folder inside. Start file name `style.scss` and `app.js` (if you wish to change then do it in gulpfile)
*/
// tested with gulp 3.9.1
@im4aLL
im4aLL / store-data-google-sheet-javascript.js
Created February 5, 2018 06:39
Store data to google spreadsheet via ajax
// URL needs to be like this
// https://script.google.com/a/example.com/macros/s/id/exec
// https://script.google.com/macros/s/id/exec
// If script isn't loaded - manage version and create new and then again deploy
// ============================================================
// Your clientside script should actually look like this (jquery example):
// ============================================================
@im4aLL
im4aLL / php-template-method-pattern.php
Created November 14, 2017 05:47
Design pattern - template method
<?php
abstract class Transformer {
protected function responseJson($array)
{
return json_encode($array);
}
abstract public function transform($item);
@im4aLL
im4aLL / php-strategy-pattern.php
Created November 14, 2017 05:46
Design pattern - strategy - example
<?php
interface MailServiceInterface {
public function sendEmail();
}
class SMTPService implements MailServiceInterface {
public function sendEmail()
{
@im4aLL
im4aLL / php-decorator-pattern.php
Created November 14, 2017 05:44
Design pattern - decorator example
<?php
/**
* PHP decorator pattern example
*/
interface TransactionInterface {
public function getCost();
}
@im4aLL
im4aLL / chain-of-responsibility-pattern.php
Created November 14, 2017 05:43
Design pattern - chain of responsibility example
<?php
abstract class Status {
protected $successor;
abstract public function check(ServerStatus $serverStatus);
public function succeedWith(Status $status)
{
$this->successor = $status;
@im4aLL
im4aLL / php-adapter-pattern.php
Created November 14, 2017 05:41
Design pattern adapter simple example
<?php
interface NotificationInterface {
public function send();
}
class Notification implements NotificationInterface {
public function send()
{
return 'Default notification service!';
@im4aLL
im4aLL / linkedList.js
Created April 10, 2017 07:10
LinkedList Javascript
function LinkedList() {
this.list = null;
this.length = 0;
}
LinkedList.prototype.add = function(value) {
if( this.list === null ) {
this.list = this._node(value);
}
else {