Skip to content

Instantly share code, notes, and snippets.

View ahmu83's full-sized avatar
🎯
Focusing

Ahmad Karim ahmu83

🎯
Focusing
View GitHub Profile
@phuze
phuze / dropbox-php-auth.md
Last active February 2, 2024 13:46
Dropbox API V2: PHP Authentication Process

Effective September 2021, Dropbox will be deprecating long-lived access tokens.

This GIST generally describes how to authenticate requests to Dropbox API v2, for anyone working on a server-side PHP Dropbox implementation.

It's important to understand three types of codes you'll encounter:

  1. Access Code - this is a one-time code that represents user-granted app access.
  2. Access Token - this is short-lived token that provides access to Dropbox API endpoints.
  3. Refresh Token - this is a long-lived token that allows you to fetch a fresh Access Token.
@zecka
zecka / html-purifier-example-use.php
Created May 27, 2020 12:51
Example use of HTMLPurifier PHP
<?php
// composer install ezyang/htmlpurifier
require 'vendor/autoload.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.AllowedElements', 'a,i,b,p,div,strong,h1,h2,h3,h4,h5,ol,ul,li,br');
$config->set('HTML.AllowedAttributes', 'href,title,target,name');
$config->set('HTML.Attr.Name.UseCDATA', true);
$config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
$config->set('Attr.AllowedFrameTargets', ['_blank']);
@robhrt7
robhrt7 / MySQL_5-7_macOS.md
Last active February 28, 2024 03:48 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL 5.7 on macOS using Homebrew

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
@idleberg
idleberg / sublime-text-macos-context-menu.md
Last active February 20, 2024 09:37 — forked from vincentmac/sublime-text-osx-context-menu.md
“Open in Sublime Text” in macOS context-menu

This list has been updated for Big Sur (and later). Since I don't use these versions, this guide might still need further improvements. For older macOS versions, please see this older revision.

Open in Sublime Text

  • Open Automator
  • Quick Action
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n "$@"
  • Set “Pass input” to as arguments
@stefanmaric
stefanmaric / copy-to-clipboard-bookmarklet.md
Created September 7, 2016 20:54
Create Bookmarklet (browser bookmark that executes Javsacript) to copy a given text to Clipboard

Copy-to-clipboard Bookmarklet

Create Bookmarklet (browser bookmark that executes Javsacript) to copy a given text to Clipboard.

This is the base javascript:

(function (text) {
  var node = document.createElement('textarea')
  var selection = document.getSelection()
@wpsmith
wpsmith / sanitize_phone.php
Created June 5, 2014 17:00
PHP: Sanitize & Format US Phone Numbers
<?php
function sanitize_phone( $phone, $international = false ) {
$format = "/(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/";
$alt_format = '/^(\+\s*)?((0{0,2}1{1,3}[^\d]+)?\(?\s*([2-9][0-9]{2})\s*[^\d]?\s*([2-9][0-9]{2})\s*[^\d]?\s*([\d]{4})){1}(\s*([[:alpha:]#][^\d]*\d.*))?$/';
// Trim & Clean extension
$phone = trim( $phone );
$phone = preg_replace( '/\s+(#|x|ext(ension)?)\.?:?\s*(\d+)/', ' ext \3', $phone );
@adilapapaya
adilapapaya / README
Last active June 27, 2020 11:58
Export Table Data to CSV using Javascript
Example code for exporting data in a table to a csv file.
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@stut
stut / gist:6438640
Last active November 3, 2020 03:00
100 first names and 100 last names.
<?php
$first_names = array(
'Abigail', 'Alice', 'Amber', 'Amelia', 'Amy', 'Ava', 'Brooke',
'Caitlin', 'Charlotte', 'Chloe', 'Daisy', 'Elizabeth', 'Ella', 'Ellie',
'Emily', 'Emma', 'Erin', 'Eva', 'Evie', 'Freya', 'Grace', 'Hannah',
'Holly', 'Imogen', 'Isabel', 'Isabella', 'Isabelle', 'Isla', 'Jasmine',
'Jessica', 'Katie', 'Keira', 'Leah', 'Lilly', 'Lily', 'Lola', 'Lucy',
'Matilda', 'Megan', 'Mia', 'Millie', 'Molly', 'Olivia', 'Phoebe',
'Poppy', 'Ruby', 'Scarlett', 'Sophia', 'Sophie', 'Summer', 'Adam',
'Alex', 'Alexander', 'Alfie', 'Archie', 'Benjamin', 'Callum',