Skip to content

Instantly share code, notes, and snippets.

View alvinnguyen's full-sized avatar

Alvin Nguyen alvinnguyen

View GitHub Profile
@alvinnguyen
alvinnguyen / varnish_reload.sh
Last active August 2, 2016 13:40
Reload Varnish server using command line (not service varnish reload)
varnishadm
vcl.load reload01 /usr/local/etc/varnish/default.vcl
vcl.use reload01
varnishadm "ban.url ." # Matches all URLs
varnishadm "ban req.http.host == opensourcehacker.com"
function validateEmail(email) {
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
}
@alvinnguyen
alvinnguyen / EastBay Size Notification
Created April 12, 2015 23:23
Notify stock availability for a specific size
<?php
function checkStock($url,$sku,$size, $nick = null){
$content = file_get_contents($url);
$find = $sku.'":["<span class';
$start = strpos($content,$find);
$end = strpos($content,"]]",$start);
$substr = substr($content,$start,$end-$start);
if (strpos($substr,$size) !== false){