Skip to content

Instantly share code, notes, and snippets.

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

Joshy Francis JoshyFrancis

🏠
Working from home
View GitHub Profile
@bsalim
bsalim / php speed up tips.html
Created January 3, 2013 09:09
63 Tips for speeding up PHP
<html>
<body>
<p>Here are Webber’s points:</p>
<ul>
<li>If a method can be static, declare it static. Speed improvement is by a factor of 4.</li>
<li>echo is faster than print.(<em>* compare with list from phplens by John Lim</em>)</li>
<li>Use echo’s multiple parameters instead of string concatenation.</li>
<li>Set the maxvalue for your for-loops before and not in the loop.</li>
<li>Unset your variables to free memory, especially large arrays.</li>
<li>Avoid magic like __get, __set, __autoload</li>
@spoeken
spoeken / Accurate Human Logical Time Difference Javascript Function
Last active August 7, 2024 13:39
A time difference function in javascript, logical to humans. Outputs the difference of two dates in years, months, days, hours, minutes and seconds.
// Time difference function
function timeDiff(start, end) {
//today, now!
//Get the diff
var diff = end - start;
//Create numbers for dividing to get hour, minute and second diff
var units = [
1000 * 60 * 60 *24,
1000 * 60 * 60,
1000 * 60,
@raveren
raveren / cryptographically_secure_random_strings.php
Last active November 21, 2023 12:35
Generate cryptographically secure random strings. Based on Kohana's Text::random() method and this answer: http://stackoverflow.com/a/13733588/179104
function random_text( $type = 'alnum', $length = 8 )
{
switch ( $type ) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'hexdec':
@sepehr
sepehr / get_month_diff.php
Last active May 4, 2020 23:59
PHP: Get month difference between two timestamps
<?php
/**
* Calculates how many months is past between two timestamps.
*
* @param int $start Start timestamp.
* @param int $end Optional end timestamp.
*
* @return int
*/
@laminr
laminr / ResizeImage.php
Last active August 23, 2022 16:21
PHP Resize image with transparency
<?php
/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ranacseruet
ranacseruet / VideoStream.php
Last active March 18, 2025 14:40
PHP VideoStream class for HTML5 video streaming
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
@steve-ng
steve-ng / nginx.conf
Last active May 28, 2024 08:27
Nginx reverse proxy wss with ssl
server {
listen 443 ssl;
server_name xxx.xx.io
ssl on;
ssl_certificate /etc/asterisk/certs/xxx.io.pem;
ssl_certificate_key /etc/asterisk/certs/xxx.io.key;
ssl_session_timeout 5m;
@kosinix
kosinix / resumable-download.php
Created September 22, 2014 08:46
PHP - resumable download
<?php
class ResumeDownload {
private $file;
private $name;
private $boundary;
private $delay = 0;
private $size = 0;
function __construct($file, $delay = 0) {
if (! is_file($file)) {
@Netzvamp
Netzvamp / module_websocketclient.pb
Last active July 12, 2024 10:40
Purebasic Websocketclient
; Websocketclient by Netzvamp
; Version: 2016/01/08
DeclareModule WebsocketClient
Declare OpenWebsocketConnection(URL.s)
Declare SendTextFrame(connection, message.s)
Declare ReceiveFrame(connection, *MsgBuffer)
Declare SetSSLProxy(ProxyServer.s = "", ProxyPort.l = 8182)
Enumeration
@sabl0r
sabl0r / confirm.js
Created December 11, 2015 08:48 — forked from stefket/confirm.js
JavaScript confirm with magnific popup
var confirmDialog = function(message, headline, cb) {
var dialog = '<div class="dialog confirm mfp-with-anim">';
if (headline) {
dialog += '<h2>' + headline + '</h2>';
}
dialog += '<div class="content"><p>' + message + '</p></div>';
dialog += '<div class="actions">';
dialog += '<button type="button" class="btn btn-default btn-cancel">Abbrechen</button> ';
dialog += '<button type="button" class="btn btn-primary btn-submit">OK</button>';
dialog += '</div>';