Skip to content

Instantly share code, notes, and snippets.

View grim-reapper's full-sized avatar

Imran Ali grim-reapper

View GitHub Profile
@grim-reapper
grim-reapper / database.php
Created April 2, 2017 10:01 — forked from jonmarkgo/database.php
Twilio SMS Verification Example
<?php
$db_host='dbserver';
$db_name='dbame';
$db_user='dbuser';
$db_passwd='dbpassword';
mysql_connect($db_host, $db_user, $db_passwd)
or die('Could not connect: ' . mysql_error());
mysql_select_db($db_name) or die('Could not select database');
@grim-reapper
grim-reapper / Floating Menu JS
Created April 12, 2017 12:51 — forked from burners77/Floating Menu JS
Floating Menu JS
// JavaScript Document
$(function(){
$(function() {
function moveFloatMenu() {
var menuOffset = menuYloc.top + $(this).scrollTop() + "px";
$('#floatMenu').animate({
top: menuOffset
}, {
duration: 700,
queue: false,
@grim-reapper
grim-reapper / gist:90cbb9408ff4c6f13a5501188e5dc85b
Created June 15, 2017 11:53 — forked from strangerstudios/gist:3678054
Extend Expiration Dates For Renewed Memberships in Paid Memberships Pro
/*
Important note! This code is included in PMPro versions 1.5.7 and later.
Adding this code will add 2x the number of days to the end of the subscription.
*/
//if checking out for the same level, add remaining days to the enddate
function my_pmpro_checkout_level($level)
{
global $pmpro_msg, $pmpro_msgt;
//does this level expire? are they an existing user of this level?
@grim-reapper
grim-reapper / php-html-css-js-minifier.php
Created December 5, 2017 13:20 — forked from Rodrigo54/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
@grim-reapper
grim-reapper / font-awesome-form-elements.css
Created January 12, 2018 07:42 — forked from pom-pom/font-awesome-form-elements.css
Font Awesome Radio Buttons and Checkboxes
/*Custom Radio Buttons and Checkboxes using Font Awesome*/
input[type=radio],
input[type='checkbox'] {
display: none;
}
input[type=radio] + label {
display: block;
}
input[type='checkbox'] + label:before,
@grim-reapper
grim-reapper / slugify.php
Created March 1, 2018 10:35 — forked from james2doyle/slugify.php
Simple slugify function for PHP. Creates a slug for the passed string, taking into account international characters as well.
<?php
function slugify($string, $replace = array(), $delimiter = '-') {
// https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Utils/Slug.php
if (!extension_loaded('iconv')) {
throw new Exception('iconv module not loaded');
}
// Save the old locale and set the new locale to UTF-8
$oldLocale = setlocale(LC_ALL, '0');
setlocale(LC_ALL, 'en_US.UTF-8');
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
@grim-reapper
grim-reapper / function_v1.php
Created March 20, 2018 08:35 — forked from b-b3rn4rd/function_v1.php
Convert adjacency list into tree without recursion and second array.
<?php
function array_to_tree(array $array, $parent_id = 0)
{
$array = array_combine(array_column($array, 'id'), array_values($array));
foreach ($array as $k => &$v) {
if (isset($array[$v['parent_id']])) {
$array[$v['parent_id']]['children'][$k] = &$v;
}
@grim-reapper
grim-reapper / ajax-send.js
Created March 30, 2018 10:36 — forked from jakebellacera/ajax-send.js
JQuery validate form that submits via AJAX
/*
ajax-send.js - copyright Jake Bellacera (http://jakebellacera.com)
This script uses JQuery & JQuery Validate (https://github.com/jzaefferer/jquery-validation)
For this example, we will have a form named '#ajaxform', you can of course change this to whatever you'd like.
*/
$(function(){
$('#submitbutton').click(function() {
@grim-reapper
grim-reapper / .htaccess
Created September 17, 2018 11:39 — forked from tavy315/.htaccess
Enable GZip compression & Leverage browser caching
AddDefaultCharset UTF-8
Options -Indexes
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
@grim-reapper
grim-reapper / remote-file-copy.php
Created September 19, 2018 06:54 — forked from kongondo/remote-file-copy.php
Remote file copying with progress reporting in PHP.
<?php
/*
* Remote File Copy PHP Script 2.0.0
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/