Skip to content

Instantly share code, notes, and snippets.

View cuongdcdev's full-sized avatar
🤔
~~~

Cuong DC cuongdcdev

🤔
~~~
View GitHub Profile
@cuongdcdev
cuongdcdev / DNS Prefetch domains
Created October 4, 2019 02:31 — forked from lukecav/DNS Prefetch domains
WP Rocket - Advanced Options Prefetch DNS requests
//maps.googleapis.com
//maps.gstatic.com
//fonts.googleapis.com
//fonts.gstatic.com
//ajax.googleapis.com
//apis.google.com
//google-analytics.com
//www.google-analytics.com
//ssl.google-analytics.com
//youtube.com
@cuongdcdev
cuongdcdev / verification.php
Created July 28, 2019 18:02 — forked from jxlwqq/verification.php
Input verification on front and back ends
<?php
protected function form()
{
$form = new Form(new ModelName);
$form->text('title')->rules('required')->required()->help('This field must be required');
$form->text('number')->rules('required|regex:/\d{3}/')->pattern('\d{3}')->help('This field must be three digits');
return $form;
}
@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 / 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 / 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 / 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

@cuongdcdev
cuongdcdev / index.htm
Created March 12, 2018 09:31 — forked from AllThingsSmitty/index.htm
Simple responsive table in CSS (no JS)
<table>
<thead>
<tr>
<th>Payment</th>
<th>Issue Date</th>
<th>Amount</th>
<th>Period</th>
</tr>
</thead>
<tbody>
@cuongdcdev
cuongdcdev / facebook-mass-delete-group-members.js
Created February 3, 2018 11:15 — forked from michaelv/facebook-mass-delete-group-members.js
This javascript removes all users from a facebook group. It works with the new facebook layout. Paste this in the javascript console. Script tested in Firefox. Known issues: 1. when facebook responds slowly, the script might experience hickups.. 2. occasionially, the error 'this user is not a member of the group' pops up.. IMPORTANT: add your ow…
var deleteAllGroupMembers = (function () {
var deleteAllGroupMembers = {};
// the facebook ids of the users that will not be removed.
// IMPORTANT: add your own facebook id here so that the script will not remove yourself!
var excludedFbIds = ['1234','11223344']; // make sure each id is a string!
var usersToDeleteQueue = [];
var scriptEnabled = false;
var processing = false;
deleteAllGroupMembers.start = function() {
@cuongdcdev
cuongdcdev / um-favicons.txt
Created December 23, 2017 09:11 — forked from wpdelighter/um-favicons.txt
List of font icons used in Ultimate Member Profile Tabs
um-icon-alert
um-icon-alert-circled
um-icon-android-add
um-icon-android-add-circle
um-icon-android-alarm-clock
um-icon-android-alert
um-icon-android-apps
um-icon-android-archive
um-icon-android-arrow-back
um-icon-android-arrow-down