Skip to content

Instantly share code, notes, and snippets.

@midoooo
midoooo / remote-file-copy.php
Created January 7, 2016 08:40
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
*/
@midoooo
midoooo / curl_progress.php
Created January 7, 2016 08:27 — forked from bdunogier/curl_progress.php
PHP/cURL download progress monitoring
<?php
file_put_contents( 'progress.txt', '' );
$targetFile = fopen( 'testfile.iso', 'w' );
$ch = curl_init( 'http://ftp.free.org/mirrors/releases.ubuntu-fr.org/11.04/ubuntu-11.04-desktop-i386-fr.iso' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_NOPROGRESS, false );
curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' );
curl_setopt( $ch, CURLOPT_FILE, $targetFile );
@midoooo
midoooo / fbgetalbumphotos.js
Created November 17, 2015 23:14 — forked from hasantayyar/fbgetalbumphotos.js
Get Facebook Albums and Album Photos
function getAlbumPhotos(albumid){
FB.api("/"+albumid+"/photos",function(response){
var photos = response["data"];
var html = "count "+photos.length;
for(var i=0;i<photos.length;i++) {
var images = photos[i]["images"];
html+= "Photo "+(v+1);
html+= '<img src="'+images[(images.length-1)]["source"]+'" />';
var tmp = "";
for(var j = 0 ;j<images.length;j++) {
@midoooo
midoooo / all_my_facebook_photos.html
Created November 17, 2015 23:14 — forked from cbosco/all_my_facebook_photos.html
Simple "get all of my facebook photos" facebook JS SDK + Graph API example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Photos with Friends!</title>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script>
/**
* This is the getPhoto library
*/
@midoooo
midoooo / gist:459722f72cebc93a92c7
Created November 17, 2015 23:13 — forked from magadanskiuchen/gist:3189045
Get All Photos for a Facebook Page
<?php
// make sure you have enough time to download all pictures
ini_set('max_execution_time', 6000);
ini_set('memory_limit', '64M');
// include the Facebook PHP SDK - https://github.com/facebook/php-sdk/
require 'facebook.php';
// enter your App ID and App Secret
// register an FB App at https://developers.facebook.com/apps/
@midoooo
midoooo / learn_crypto.txt
Last active September 17, 2015 15:19 — forked from abderraouf-adjal/learn_crypto.txt
Learn crypto links
أساسيات التشفير - رواق
http://www.rwaq.org/courses/introduction-to-encryption
Applied Cryptography - UDACITY
https://www.udacity.com/course/cs387
Theory and Practice of Cryptography - GoogleTechTalks
http://youtu.be/IzVCrSrZIX8
CISSP Training - Cryptography - The Geek Academy
@midoooo
midoooo / fbUrlCheck.php
Last active August 29, 2015 14:26 — forked from atomicpages/fbUrlCheck.php
A simple facebook URL checker RegEx for PHP or JavaScript
<?php
/**
* A simple regex to test whether or not a facebook url is valid. For basic usage, this will do the job.
* @see Test cases <http://ideone.com/ZMJp4f>
*/
$fbUrlCheck = '/^(https?:\/\/)?(www\.)?facebook.com\/[a-zA-Z0-9(\.\?)?]/';
$secondCheck = '/home((\/)?\.[a-zA-Z0-9])?/';
$validUrl = 'https://www.facebook.com/atomicpages/';
@midoooo
midoooo / unshorten.php
Last active August 29, 2015 14:24 — forked from marijn/unshorten.php
<?php
/**
* @link http://jonathonhill.net/2012-05-18/unshorten-urls-with-php-and-curl/
*/
function unshorten_url($url) {
$ch = curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => TRUE, // the magic sauce
CURLOPT_RETURNTRANSFER => TRUE,
function hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));