Skip to content

Instantly share code, notes, and snippets.

View fhdalikhan's full-sized avatar
🏠
Working from home

Fahad Ali Khan fhdalikhan

🏠
Working from home
  • Karachi, Pakistan.
View GitHub Profile
@hiddenpearls
hiddenpearls / listallfiles.php
Created September 6, 2015 18:21
Google Drive APIs with PHP - List all files and folders
function listAllFiles($driveService){
$parameters = array(
'maxResults' => '100'
);
$results = $driveService->files->listFiles($parameters);
echo '<table>';
@hiddenpearls
hiddenpearls / fetch-files-google-drive.php
Created September 2, 2015 04:28
Fetch latest files from Google Drive using PHP
<?php
// Display erros if any on the page.
error_reporting(E_ALL);
ini_set("display_errors", 1);
session_start();
if(isset($_GET['action']) and $_GET['action'] == 'logout'){
unset($_SESSION['accessToken']);
@ajaegers
ajaegers / git-move-files-in-subfolder.md
Last active March 16, 2025 18:34
Git: move files in an subfolder keeping history

Change structure of project folder with Git

I have this structure:

 project-folder/
     .git
     wp-admin/
     wp-content/
     wp-includes/

.htaccess

@webdevilopers
webdevilopers / CompartmentFilter.php
Created February 26, 2015 11:03
Doctrine ORM custom Aware Filter and Event in Symfony
<?php
namespace Plusquam\Bundle\ContractBundle\Filter;
use Doctrine\ORM\Query\Filter\SQLFilter;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Common\Annotations\Reader;
class CompartmentFilter extends SQLFilter
{
@toddsby
toddsby / backup.php
Last active December 30, 2021 06:01 — forked from menzerath/backup.php
backup.php
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* (c) 2012-2014: Marvin Menzerath - http://menzerath.eu
* contribution: Drew Toddsby
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit','1024M');
@seanuk
seanuk / Standard Terms & Conditions.md
Last active April 16, 2023 02:24
My standard terms & conditions for web projects. Together with a signed project proposal it forms a working agreement. Includes bits borrowed from https://gist.github.com/malarkey/4031110 & https://gist.github.com/maban/6098135

Standard Terms & Conditions

The following terms and conditions, together with a signed project proposal, form an agreement that is intended to protect both parties, and is no way meant to trick or deceive you. We have tried to keep the wording as plain as possible, but if anything is unclear we will be more than happy to clarify it with you.

In short, [CLIENT COMPANY] (referred to herein as “you”) is engaging SJD Digital (referred to herein as “us” & “we”), to undertake the work as specified in the attached proposal, and under the requirements of these terms and conditions.

Deadlines

We will do our best to meet all agreed deadlines. You agree to review our work and provide feedback and approval in a timely manner. You accept that delays in supplying required information or materials may result in longer delays to the delivery of the finished work.

@aymanfarhat
aymanfarhat / sendmail.py
Created January 1, 2014 10:24
Python snippet for sending email using unix sendmail
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from subprocess import Popen, PIPE
html = MIMEText("<html><head><title>Test Email</title></head><body>Some HTML</body>", "html")
msg = MIMEMultipart("alternative")
msg["From"] = "[email protected]"
msg["To"] = "[email protected]"
msg["Subject"] = "Python sendmail test"
@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@atenni
atenni / README.md
Last active March 17, 2025 12:15
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

@nikic
nikic / microbench.php
Created June 22, 2012 23:42
Microbenchmark of generator implementation
<?php
error_reporting(E_ALL);
function xrange($start, $end, $step = 1) {
for ($i = $start; $i < $end; $i += $step) {
yield $i;
}
}