Skip to content

Instantly share code, notes, and snippets.

View habibtalib's full-sized avatar

Habib Talib habibtalib

View GitHub Profile
@habibtalib
habibtalib / gup-to-webpack.md
Created March 14, 2017 14:14 — forked from rap2hpoutre/gup-to-webpack.md
Laravel 5.4: migrate from gulp to webpack
  • Create a webpack.mix.js file in root directory:
const { mix } = require('laravel-mix');

mix.js('resources/assets/js/app.js', 'public/js')
  .sass('resources/assets/sass/app.scss', 'public/css');
  
/* Optional: uncomment for bootstrap fonts */
// mix.copy('node_modules/bootstrap-sass/assets/fonts/bootstrap/','public/fonts/bootstrap');
<!-- HTML heavily inspired by http://blueimp.github.io/jQuery-File-Upload/ -->
<div class="table table-striped" class="files" id="previews">
<div id="template" class="file-row">
<!-- This is used as the file preview template -->
<div>
<span class="preview"><img data-dz-thumbnail /></span>
</div>
<div>
<p class="name" data-dz-name></p>
@habibtalib
habibtalib / ultimate-ut-cheat-sheet.md
Created May 8, 2017 13:00 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@habibtalib
habibtalib / sendsqs.js
Created May 15, 2017 08:17
AWS Lambda sample: Send received events to SQS as Message
var QUEUE_URL = 'https://sqs.us-east-1.amazonaws.com/{AWS_ACCUOUNT_}/matsuoy-lambda';
var AWS = require('aws-sdk');
var sqs = new AWS.SQS({region : 'us-east-1'});
exports.handler = function(event, context) {
var params = {
MessageBody: JSON.stringify(event),
QueueUrl: QUEUE_URL
};
sqs.sendMessage(params, function(err,data){
// Codility Bbinary Gap Test
function solution($N) {
// write your code in PHP5.5
$binaryNumber = decbin($N); // binary conversion of number
$trimmed = trim($binaryNumber, 0); // trim to remove trailing zeros
$binaryGap = explode("1",$trimmed); // explode
$binaryCount = array_map('strlen', $binaryGap);
return max($binaryCount); // returns the longest binary gap
<?php
namespace App\Http;
/**
* Description of VideoStream
*
* @author Rana
* @link https://gist.github.com/vluzrmos/d5682ad426525196d069
*/
@habibtalib
habibtalib / promise_while_loop.js
Created July 20, 2017 08:20 — forked from victorquinn/promise_while_loop.js
Promise "loop" using the Bluebird library
var Promise = require('bluebird');
var promiseWhile = function(condition, action) {
var resolver = Promise.defer();
var loop = function() {
if (!condition()) return resolver.resolve();
return Promise.cast(action())
.then(loop)
.catch(resolver.reject);

Stop the MySQL Service

I'm using Homebrew to stop the service

brew services stop mysql

Locate MySQL Data Directory

@habibtalib
habibtalib / amz-s3-bucket-policy
Created October 11, 2017 16:26 — forked from alicial/amz-s3-bucket-policy
Amazon S3 Bucket Policy to prevent hot linking
{
"Version": "2008-10-17",
"Id": "0c762de8-f56b-488d-a4a4-20d1cb31df2f",
"Statement": [
{
"Sid": "Allow in my domains",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
@habibtalib
habibtalib / generate_reference_number.php
Created December 2, 2017 16:15 — forked from nasrulhazim/generate_reference_number.php
Generate Document Reference Number
<?php
/**
* I use abbrv() function in https://gist.github.com/nasrulhazim/df8f4046cceb37ab61fa5d5c0c65dba6
* And for str_random() from Laravel Framework
**/
if (!function_exists('generate_reference_number')) {
function generate_reference_number($module_label, $module_component = null)
{
if (empty($module_label)) {