Skip to content

Instantly share code, notes, and snippets.

View fredchu's full-sized avatar
🏠
Working from home

Fred Chu fredchu

🏠
Working from home
View GitHub Profile
@fredchu
fredchu / style.css
Created June 24, 2014 15:57
Increase the height of <select> for webkit on Mac
.target {
-webkit-appearance: menulist-button;
}
@fredchu
fredchu / styling-a-without-href.css
Created June 26, 2014 07:06
Styling <a> without href attribute
a:not([href]) {
/* Styles for anchors without href */
}
@fredchu
fredchu / a-way-to-get-the-accurate-type-of-a-variable.js
Last active August 29, 2015 14:03
A way to get the accurate type of a variable
{}.toString.call(arg);
@fredchu
fredchu / is-running-web-app-mode-for-iOS-Safari.js
Created June 27, 2014 16:45
Check the web page if is added to homescreen (web app mode for iOS Safari)
if (window.navigator.standalone) {
// The app is running in standalone mode.
}
// or
if (window.navigator.standalone && navigator.userAgent.match( /like Mac OS X/i )) {
// added to homescreen by mobile Safari
}
@fredchu
fredchu / javascript-speed-test.js
Created June 27, 2014 16:56
JavaScript speed test
console.time('a');
// execute some JavaScript
console.timeEnd('a');
// the result showed in console is the duration that block of JavaScript spent
@fredchu
fredchu / regex-getting-youtube-id.js
Created June 27, 2014 17:07
Regex for getting YouTube id from YouTube url
var _regex = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var videoUrl = 'http://www.youtube.com/watch?v=D1GmL_mvmwY&feature=g-high-u';
// there you go~
var youtubeId = videoUrl.match(_regex)[7];
@fredchu
fredchu / overriding-the-default-text-selection-color-with-css.css
Created June 27, 2014 17:19
Overriding The Default Text Selection Color With CSS
/* draw any selected text yellow on red background */
::-moz-selection { color: gold; background: red; }
::selection { color: gold; background: red; }
/* draw selected text in a paragraph white on black */
p::-moz-selection { color: white; background: black; }
p::selection { color: white; background: black; }
@fredchu
fredchu / horizontal-scroll.css
Created June 27, 2014 17:21
Horizontal scroll
.scrolls {
overflow-x: scroll;
overflow-y: hidden;
height: 80px;
white-space: nowrap;
}
.imageDiv img {
display: inline-block;
*display:inline;/* For IE7*/
@fredchu
fredchu / change-the-color-tapping-ios-mobile-safari.css
Created June 27, 2014 17:29
Change the color showing when tapping in iOS mobile Safari
-webkit-tap-highlight-color: #f00;
@fredchu
fredchu / hide-text-in-submit-button.css
Created June 27, 2014 17:32
Hide text in submit button
.submit-button {
line-height: 999px;
overflow: hidden;
font-size: 0;
}