Skip to content

Instantly share code, notes, and snippets.

View grim-reapper's full-sized avatar

Imran Ali grim-reapper

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS drop-shadows without images</title>
<style>
body {
padding:20px 0 30px;
font:14px/1.5 Arial, sans-serif;
text-align:center;
@grim-reapper
grim-reapper / .htaccess
Created December 24, 2018 06:17 — forked from AndrewChamp/.htaccess
Force Port 80 or Port 443 via .htaccess. This will also remove www. from the url.
# FORCE PORT 80 (insecure / regular traffic)
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
###########################################################
#FORCE PORT 443 && REMOVE WWW. (secure / SSL)
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
@grim-reapper
grim-reapper / calculate_profile_percentage.php
Created April 1, 2019 17:39 — forked from azimidev/calculate_profile_percentage.php
Calculates how much percentage of a profile is completed. It stripes off timestamps like created_at updated_at and primary keys like ids. Usually beneficial when using Laravel
<?php
/**
* Calculate how much a profile is completed
*
* @param $profile
* @return float|int
*/
function calculate_profile($profile)
{
if ( ! $profile) {
@grim-reapper
grim-reapper / example.html
Created April 24, 2019 10:35 — forked from andrewlimaza/example.html
Print certain div / elements using window.print()
<script>
function printDiv(divName){
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
@grim-reapper
grim-reapper / .htaccess
Created July 11, 2019 07:46 — forked from Darep/.htaccess
PHP CSS&JS auto-versioning function.
# CSS/JS auto-versioning
RewriteEngine On
RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]
@grim-reapper
grim-reapper / Paypal Rest API Codeigniter
Created July 11, 2019 10:33 — forked from RobertoNovelo/Paypal Rest API Codeigniter
CodeIgniter 3.x Paypal Rest API Authorize Capture Wrapper
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(BASEPATH . '../application/libraries/PayPal-PHP-SDK/autoload.php');
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Api\Capture;
use PayPal\Api\Authorization;
use PayPal\Api\Amount;
use PayPal\Exception\PayPalConnectionException;
@grim-reapper
grim-reapper / php-headers.php
Created July 29, 2019 07:02 — forked from reinink/php-headers.php
PHP header examples
<?php
// Source: http://www.jonasjohn.de/snippets/php/headers.htm
// Use this header instruction to fix 404 headers
// produced by url rewriting...
header('HTTP/1.1 200 OK');
// Page was not found:
header('HTTP/1.1 404 Not Found');
@grim-reapper
grim-reapper / disableBodyScroll.js
Created July 30, 2019 11:21 — forked from thuijssoon/disableBodyScroll.js
iOS disable body scroll
/**
* Prevent body scroll and overscroll.
* Tested on mac, iOS chrome / Safari, Android Chrome.
*
* Based on: https://benfrain.com/preventing-body-scroll-for-modals-in-ios/
* https://stackoverflow.com/a/41601290
*
* Use in combination with:
* html, body {overflow: hidden;}
*
@grim-reapper
grim-reapper / password-regex.txt
Created August 1, 2019 13:04 — forked from shankara-subramani/password-regex.txt
password regex with optional special characters
^(?=.*\d)(?=.*[a-z])[\w~@#$%^&*+=`|{}:;!.?\"()\[\]-]{6,8}$
@grim-reapper
grim-reapper / Obfuscator.php
Created August 2, 2019 12:01 — forked from adhocore/Obfuscator.php
Obfuscator - The naive and trivial PHP Code obfuscator | deobfuscator
<?php
/**
* Obfuscator - The naive and trivial PHP Code obfuscator | deobfuscator
*
* generate() Generates a obfuscated string of given code
* also gives the chunk value required by work()
* work() Reverses the obfuscated string using chunk value given by generate()
* to original code and then execute the code and returns response
*