Skip to content

Instantly share code, notes, and snippets.

@weishuaiwang
weishuaiwang / README.md
Created April 28, 2017 02:10 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

/**
* Function: recursive_glob
* Recursively goes through a folder and returns all files.
*
* Parameters:
* $pattern - String
* $flags - Boolean
* $path - String
*
* Returns:
@charset "utf-8";
/**
* iPhone 4/4s landscape & portrait
*/
@media only screen
and (min-device-width: 320px)
and (max-device-width: 480px)
and (-webkit-device-pixel-ratio: 2)
and (device-aspect-ratio: 2/3) {
}
@weishuaiwang
weishuaiwang / browser-detect.php
Created June 23, 2014 02:26
访客来源判断
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> 微信浏览器判断 </title>
</head>
<body>
<?php
function is_weixin(){
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
@weishuaiwang
weishuaiwang / dataUri
Created October 21, 2013 07:05
These can be useful for embedding images into HTML/CSS/JS to save on HTTP requests, at the cost of maintainability. More information. There are online tools to do it, but if you want your own very simple utility, here's some PHP to do it:
function data_uri($file, $mime) {
$contents=file_get_contents($file);
$base64=base64_encode($contents);
echo "data:$mime;base64,$base64";
}
@weishuaiwang
weishuaiwang / dataUri
Created October 21, 2013 07:05
These can be useful for embedding images into HTML/CSS/JS to save on HTTP requests, at the cost of maintainability. More information. There are online tools to do it, but if you want your own very simple utility, here's some PHP to do it:
function data_uri($file, $mime) {
$contents=file_get_contents($file);
$base64=base64_encode($contents);
echo "data:$mime;base64,$base64";
}
@weishuaiwang
weishuaiwang / getClientLanguage
Created October 21, 2013 07:04
Detect Browser Language
unction get_client_language($availableLanguages, $default='en'){
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
//start going through each one
foreach ($langs as $value){
$choice=substr($value,0,2);
@weishuaiwang
weishuaiwang / get_client_language
Created October 21, 2013 07:04
Detect Browser Language
unction get_client_language($availableLanguages, $default='en'){
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
//start going through each one
foreach ($langs as $value){
$choice=substr($value,0,2);
@weishuaiwang
weishuaiwang / get_client_language
Created October 21, 2013 07:04
Detect Browser Language
unction get_client_language($availableLanguages, $default='en'){
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
//start going through each one
foreach ($langs as $value){
$choice=substr($value,0,2);
@weishuaiwang
weishuaiwang / passwordStrength
Created October 21, 2013 07:03
password strength
<?php
/**
*
* @param String $string
* @return float
*
* Returns a float between 0 and 100. The closer the number is to 100 the
* the stronger password is; further from 100 the weaker the password is.
*/
function password_strength($string){