Skip to content

Instantly share code, notes, and snippets.

@laocoi
laocoi / sso_login_discourse.php
Created April 26, 2017 10:58 — forked from paxmanchris/sso_login_discourse.php
Discourse sso provider login
<?php
require('mysql.php'); // see https://gist.github.com/paxmanchris/f5d4b94f67a8acd8cefc
$me = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
$sso_secret = 'YOUR_SSO_PROVIDER_KEY_HERE';
$discourse_url = 'http://example.com';
if(!empty($_GET) and isset($_GET['sso'])){
// Written by (C) Rafsun Masud Prince known
if (window.location.hostname != "www.messenger.com") {
alert("Bạn không truy cập trang messenger.com . Vui lòng truy cập trang messenger.com để sử dụng !");
throw new Error("You are not on Messenger. Please visit www.messenger.com then try again.");
}
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
@laocoi
laocoi / ampify_img.php
Created March 23, 2018 05:16 — forked from elalemanyo/ampify_img.php
Make img AMP-ready
<?php
/**
* Replace img tag with amp-img
*
* <amp-img src="[src]"
* width="[width]"
* height="[height]"
* layout="responsive"
* alt="[alt]">
* </amp-img>
$(allInView);
$(window).scroll(allInView);
function isScrolledIntoView(elem) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
var inited = false;
var layiduser = document.querySelectorAll("a._42ft._4jy0._4jy3._517h._51sy");
for (var i = 0; i < layiduser.length; i++) {
(function(i){
window.setTimeout(function(){
layiduser[i].click();
console.log('Thành công ' + i + ' Người đã invite');
}, i * 1000);
}(i));
}
@laocoi
laocoi / imageProxy.php
Created June 2, 2018 12:49 — forked from carloscarucce/imageProxy.php
basic PHP image proxy (that works ... )
<?php
$url = isset($_GET['url']) ? $_GET['url'] : null;
if (!$url) {
die('Please, inform URL');
}
$imgInfo = getimagesize( $url );
@laocoi
laocoi / example.php
Created June 4, 2018 10:35 — forked from juzna/example.php
Lazy-loading for PHP
<?php
class Address {
public $street;
public $town;
}
class Customer {
public $id;
public $name;
@laocoi
laocoi / lazyload.php
Created June 4, 2018 10:35 — forked from md2perpe/lazyload.php
Lazyloading in PHP
<?php
abstract class Loader
{
abstract public function load();
}
class PaymentLoader extends Loader
{
protected $id;
<?php
/**
* Plugin Name: Lazy Load
* Description: Lazy load images to improve page load times. Uses jQuery.sonar to only load an image when it's visible in the viewport.
* Version: 0.5
*
* Code by the WordPress.com VIP team, TechCrunch 2011 Redesign team, and Jake Goldman (10up LLC).
* Uses jQuery.sonar by Dave Artz (AOL): http://www.artzstudio.com/files/jquery-boston-2010/jquery.sonar/
*
* License: GPL2

Example config haproxy ssl with let's encrypt

global
	maxconn 2048
	tune.ssl.default-dh-param 2048
	
defaults	
	option forwardfor
	option http-server-close