Skip to content

Instantly share code, notes, and snippets.

View cuongdcdev's full-sized avatar
🔥
👷🔨🪚💻

Cuong DC cuongdcdev

🔥
👷🔨🪚💻
View GitHub Profile
@cuongdcdev
cuongdcdev / background.js
Created May 28, 2019 01:38 — forked from akirattii/background.js
Message passing of Chrome Extension example
/*****************************************************************
* onMessage from the extension or tab (a content script)
*****************************************************************/
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.cmd == "any command") {
sendResponse({ result: "any response from background" });
} else {
sendResponse({ result: "error", message: `Invalid 'cmd'` });
}
@cuongdcdev
cuongdcdev / woocommerce-input-fields-bootstrap-classes.php
Created May 5, 2019 14:51
Add the Bootstrap input classes to all WooCommerce input fields
<?php
function lv2_add_bootstrap_input_classes( $args, $key, $value = null ) {
/* This is not meant to be here, but it serves as a reference
of what is possible to be changed.
$defaults = array(
'type' => 'text',
'label' => '',
'description' => '',
@cuongdcdev
cuongdcdev / gist:1ac342b052b15f95c11f6a6fcb334dce
Created January 30, 2019 12:33
class-destination-s3.php
<?php
// Amazon S3 SDK v2.8.27
// http://aws.amazon.com/de/sdkforphp2/
// https://github.com/aws/aws-sdk-php
// http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
use Inpsyde\BackWPup\Helper;
/**
* Documentation: http://docs.amazonwebservices.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html
@cuongdcdev
cuongdcdev / download large file with php
Created December 11, 2018 06:43 — forked from damienalexandre/tool.php
Download large file from the web via php
<?php
/**
* Download a large distant file to a local destination.
*
* This method is very memory efficient :-)
* The file can be huge, PHP doesn't load it in memory.
*
* /!\ Warning, the return value is always true, you must use === to test the response type too.
*
* @author dalexandre
@cuongdcdev
cuongdcdev / class-job.php
Created November 27, 2018 12:27
hotfix for config.php file not included on BWU 3.6.5
<?php
/**
* Class in that the BackWPup job runs
*/
final class BackWPup_Job {
const ENCRYPTION_SYMMETRIC = 'symmetric';
const ENCRYPTION_ASYMMETRIC = 'asymmetric';
<?php
/**
* Create Archive
*/
/**
* Class for creating File Archives
*/
class BackWPup_Create_Archive {
@cuongdcdev
cuongdcdev / VideoStream.php
Created September 7, 2018 09:53 — forked from ranacseruet/VideoStream.php
PHP VideoStream class for HTML5 video streaming
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
@cuongdcdev
cuongdcdev / gist:d8df27c7453331ddeb7bd593154d8a97
Created August 17, 2018 11:29
Replace class-create-archive.php content
<?php
/**
* Create Archive
*/
/**
* Class for creating File Archives
*/
class BackWPup_Create_Archive {
<?php
/**
* Folder Downloader
*
* @package Inpsyde\BackWPup
*/
/**
* Class BackWPup_Destination_Folder_Downloader
*
@cuongdcdev
cuongdcdev / blog.md
Created March 23, 2018 04:26 — forked from JacobBennett/blog.md
API Token Authentication in Laravel 5.2 & 5.3

I recently had the need to write a small url shortening application. I am aware that this problem has been solved quite a few times before, but what is being a developer if not reinventing the wheel just for the heck of it? Custom CMS anyone?

Knowing that this was going to be a tiny RESTful API and also knowing that Laravel 5.2 had API rate limiting built in, I was eager to give it a try. Taylor Otwell being Taylor Otwell shipped 5.2 with the rate limiting defaults set up out of the box and I had my application building out short url's in a matter of minutes. The problem for me came when I wanted to start associating those short urls with a user.

Typically my applications have a UI and authentication is done through a simple login page. Obviously for a RESTful API, having a login page isn't ideal. Instead, my hope was to have users append an api_token to the end of their query string and use that to auth