Skip to content

Instantly share code, notes, and snippets.

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

Newton iamnewton

🏠
Working from home
View GitHub Profile
@iamnewton
iamnewton / media-queries.css
Created January 1, 2014 03:29
A boilerplate or starter template of media queries for various device widths and orientations.
/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}
@iamnewton
iamnewton / .htaccess
Created January 12, 2014 22:26
Serving web fonts via CDN from David Walsh
# Apache config
<FilesMatch ".(eot|ttf|otf|woff)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
@iamnewton
iamnewton / deferred.js
Created January 13, 2014 02:05
Google's recommended way to defer a script. Just insert the path to the file and place at the bottom of the page just before the <body>.
var createScript = function() {
var script = document.createElement( "script" );
script.src = "path/to/file.js";
document.body.appendChild( script );
};
if ( window.addEventListener ) {
window.addEventListener( "load", createScript, false );
} else {
if ( window.attachEvent ) {
window.attachEvent( "onload", createScript );
@iamnewton
iamnewton / meta-tags.md
Last active February 4, 2016 18:53 — forked from lancejpollard/meta-tags.md
A collection of meta tags supported by most browsers, including the custom ones for various browsers.

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@iamnewton
iamnewton / bash_prompt-ps1-privileges.sh
Created January 15, 2014 21:46
Changes the prompt (PS1) to green text for a normal user, red for root, and yellow for any other user attained via sudo.
color_root=$(tput setaf 1)
color_user=$(tput setaf 2)
color_sudo=$(tput setaf 3)
color_reset=$(tput sgr0)
// root user
if (( EUID == 0 )); then
PS1="\\[$color_root\\]$PS1\\[$color_reset\\]"
// sudo user
elif [[ $SUDO_USER ]]; then
@iamnewton
iamnewton / prompt-switch.sh
Created January 15, 2014 22:41
Ability to turn off complex prompt to revert to a simpler one.
prompt_on() {
PS1="$color_prompt"'\u@\h:\w'"$(prompt_jobs)"'\$'"${color_reset}"' '
}
prompt_off() {
PS1='\$'
}
@iamnewton
iamnewton / totalsize.sh
Created January 16, 2014 00:43
Allows you to grab the total size of the current working directory in bytes. Could be used as standalone script or within PS1.
for filesize in $(ls -l . | grep "^-" | awk '{print $5}')
do
let totalsize=$totalsize+$filesize
done
printf "Total Size: $(tput bold)%s$(tput sgr0)\n" "$totalsize"
@iamnewton
iamnewton / getAllDOMEvents.js
Created January 16, 2014 04:46
Retrieves a list of all possible DOM events and populates an array. Works in IE9+, Chrome, Safari & Firefox.
Object
.getOwnPropertyNames( document )
.concat(
Object.getOwnPropertyNames(
Object.getPrototypeOf(
Object.getPrototypeOf( document )
)
)
)
.concat(
@iamnewton
iamnewton / html5-boilerplate.css
Created January 16, 2014 18:22
7 CSS Snippets from HTML5 Boilerplate
html {
/* ensures scrollbar always appears */
overflow-y: scroll;
/* prevents mobile browsers from adjusting page font */
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
font-size: 100%;
}
::selection {
@iamnewton
iamnewton / html5-boilerplate.htaccess
Created January 16, 2014 18:27
5 .htaccess snippets from HTML5 Boilerplate
# prevents hidden files from being accessible
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</IfModule>
# compress served files by MIME type
<IfModule mod_deflate.c>