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>
@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
import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
return None
@laocoi
laocoi / haproxy.config
Created June 22, 2018 11:47 — forked from hzbd/haproxy.config
Sample HAProxy config with logging.
global
pidfile /var/run/haproxy.pid
log 127.0.0.1 local0 info
ulimit-n 65536
defaults
mode http
clitimeout 600000 # maximum inactivity time on the client side
srvtimeout 600000 # maximum inactivity time on the server side
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software