Skip to content

Instantly share code, notes, and snippets.

@minedun6
minedun6 / duplicates.js
Last active June 6, 2018 14:27
get duplicates items from an array of objects
return _.filter(
_.uniq(
_.map(array, function (item) {
if (_.filter(array, {id: item[propertyName]}).length > 1) {
return item;
}
return false;
})),
function (value) {
@minedun6
minedun6 / lambda-helloWorld.php
Created May 14, 2018 21:26 — forked from robinvdvleuten/lambda-helloWorld.php
Invoke sample Lambda function through PHP
<?php
require_once __DIR__.'/vendor/autoload.php';
use Aws\Lambda\LambdaClient;
$client = LambdaClient::factory([
'version' => 'latest',
// The region where you have created your Lambda
'region' => 'eu-west-1',
@minedun6
minedun6 / GoogleDriveServiceProvider.php
Last active May 14, 2018 21:25 — forked from sergomet/GoogleDriveServiceProvider.php
Setup a Laravel Storage driver with Google Drive API
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class GoogleDriveServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
@minedun6
minedun6 / ContactIndexResponse.php
Created April 26, 2018 15:21 — forked from timacdonald/ContactIndexResponse.php
Easily respond to content types and url extensions
<?php
namespace App\Http\Responses;
use App\Models\ContactType;
use App\Factories\CsvFactory;
class ContactIndexResponse extends Response
{
public function __construct($contacts)
@minedun6
minedun6 / http_streaming.md
Created April 2, 2018 09:06 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@minedun6
minedun6 / xlsxParser.js
Created March 12, 2018 09:31 — forked from trevordixon/xlsxParser.js
Parse an Excel xlsx file with javascript, jquery, and zip.js
/*
Relies on jQuery, underscore.js, Async.js (https://github.com/caolan/async), and zip.js (http://gildas-lormeau.github.com/zip.js).
Tested only in Chrome on OS X.
Call xlsxParser.parse(file) where file is an instance of File. For example (untested):
document.ondrop = function(e) {
var file = e.dataTransfer.files[0];
excelParser.parse(file).then(function(data) {
console.log(data);
@minedun6
minedun6 / 01-promise-wait-and-catch.js
Created March 3, 2018 13:46
Promise waitAndCatch
/**
* Wait for a specified number of milliseconds. If a promise hasn't resolved, reject it.
* This is a necessary replacement in some cases since cancellable promises aren't a thing
* and is helpful if you want to wait _no longer than_ a specified amount of time.
* @param {int} time Amount of time to wait before resolving arbitrarily.
* @param {function} fn That returns a Promise. It will be run one tick before the timer starts.
* @return {Promise}
*/
export function waitAndCatch(time, fn) {
return new Promise((resolve, reject) => {
@minedun6
minedun6 / README.md
Created January 11, 2018 13:46 — forked from Alymosul/README.md
[Laravel] Seeding data in testing as part of the application build.

SeedDatabase trait along with SeedDatabaseState class gives your Laravel project the ability to seed the testing database once before running the full suite tests, which improves the speed of the tests than seeding the testing database before each test.

Also, it has the option to run custom seeders instead of the seeders that are called in the run() method of the DatabaseSeeder class you can achieve that as follows

...in the Testcase.php

public function setUp()

{

@minedun6
minedun6 / Filterable.php
Created January 11, 2018 13:46 — forked from Alymosul/Filterable.php
Abstract Layer for Query Filters in Laravel
<?php
namespace App\Filters\Query;
trait Filterable
{
/**
* Apply Filters on the Eloquent Model
*
* @param $query
@minedun6
minedun6 / README.md
Created December 27, 2017 21:27 — forked from CodingDoug/README.md
Uploading images to Cloud Storage via the web and identifying them with Google Cloud Vision API

Uploading images to Cloud Storage via the web and identifying them with Google Cloud Vision API

If you're trying to do this, you came to the right place!

Watch this code work in real time: https://twitter.com/CodingDoug/status/945035556555186176

Setup

These instructions assume that you already have a Firebase project, and billing is enabled. Billing is required to use the Vision API.