Skip to content

Instantly share code, notes, and snippets.

View phamquocbuu's full-sized avatar
💻

Buu Pham phamquocbuu

💻
View GitHub Profile
@phamquocbuu
phamquocbuu / email.php
Created November 6, 2012 15:44 — forked from michaelaguiar/email.php
PHP - Send Email
<?php
// Configuration
$myEmail = 'YOUR EMAIL HERE';
$error = '';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
function getRealIpAddr() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet
$ip=$_SERVER['HTTP_CLIENT_IP'];
} else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@phamquocbuu
phamquocbuu / gist:7f911484ee496292219d
Last active December 14, 2015 13:38 — forked from eriwen/gist:187610
Pythonic site monitor
#!/usr/bin/env python
# sample usage: checksites.py eriwen.com nixtutor.com yoursite.org
import pickle, os, sys, logging
from httplib import HTTPConnection, socket
from smtplib import SMTP
def email_alert(message, status):
fromaddr = 'you@gmail.com'
@phamquocbuu
phamquocbuu / raspberry-pi-edimax-wifi-and-motion-sensor.md
Created January 13, 2016 13:36 — forked from eduardschaeli/raspberry-pi-edimax-wifi-and-motion-sensor.md
My notes on setting up a Raspberry Pi with an Edimax EW-7811UN WiFi Dongle and motion sensors

Raspberry Pi, WiFi and motion sensors

My notes on setting up a Raspberry Pi with an Edimax EW-7811UN WiFi Dongle and motion sensors.

We intend to use a few Raspberry Pis around the office, in order to find out if certain rooms are beeing used or not. For this, we need to get WiFi and a motion sensor working.

@phamquocbuu
phamquocbuu / cpu_load.py
Last active August 19, 2016 18:25 — forked from tott/gist:3895832
create cpu load in python
#!/usr/bin/env python
"""
Produces load on all available CPU cores
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
def f(x):
while True:
@phamquocbuu
phamquocbuu / proxy.pac
Created September 15, 2016 03:11 — forked from swinton/proxy.pac
Example proxy.pac, using a SOCKS proxy for certain hosts.
function FindProxyForURL(url, host) {
var useSocks = ["imgur.com"];
for (var i= 0; i < useSocks.length; i++) {
if (shExpMatch(host, useSocks[i])) {
return "SOCKS localhost:9999";
}
}
return "DIRECT";
@phamquocbuu
phamquocbuu / FacebookDebugger.php
Created June 11, 2017 08:26 — forked from FrostyX/FacebookDebugger.php
Facebook API - Force facebook to reload cache from your website
<?php
class FacebookDebugger
{
/*
* https://developers.facebook.com/docs/opengraph/using-objects
*
* Updating Objects
*
* When an action is published, or a Like button pointing to the object clicked,
* Facebook will 'scrape' the HTML page of the object and read the meta tags.
@phamquocbuu
phamquocbuu / Git push deployment in 7 easy steps.md
Created June 24, 2017 15:08 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook