Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Newton iamnewton

🏠
Working from home
View GitHub Profile
@iamnewton
iamnewton / media-queries.css
Created Jan 1, 2014
A boilerplate or starter template of media queries for various device widths and orientations.
View media-queries.css
/* 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 Jan 12, 2014
Serving web fonts via CDN from David Walsh
View .htaccess
# Apache config
<FilesMatch ".(eot|ttf|otf|woff)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
@iamnewton
iamnewton / deferred.js
Created Jan 13, 2014
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>.
View deferred.js
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 Feb 4, 2016 — forked from lancejpollard/meta-tags.md
A collection of meta tags supported by most browsers, including the custom ones for various browsers.
View meta-tags.md

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 Jan 15, 2014
Changes the prompt (PS1) to green text for a normal user, red for root, and yellow for any other user attained via sudo.
View bash_prompt-ps1-privileges.sh
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 Jan 15, 2014
Ability to turn off complex prompt to revert to a simpler one.
View prompt-switch.sh
prompt_on() {
PS1="$color_prompt"'\u@\h:\w'"$(prompt_jobs)"'\$'"${color_reset}"' '
}
prompt_off() {
PS1='\$'
}
@iamnewton
iamnewton / totalsize.sh
Created Jan 16, 2014
Allows you to grab the total size of the current working directory in bytes. Could be used as standalone script or within PS1.
View totalsize.sh
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 Jan 16, 2014
Retrieves a list of all possible DOM events and populates an array. Works in IE9+, Chrome, Safari & Firefox.
View getAllDOMEvents.js
Object
.getOwnPropertyNames( document )
.concat(
Object.getOwnPropertyNames(
Object.getPrototypeOf(
Object.getPrototypeOf( document )
)
)
)
.concat(
@iamnewton
iamnewton / html5-boilerplate.css
Created Jan 16, 2014
7 CSS Snippets from HTML5 Boilerplate
View html5-boilerplate.css
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 Jan 16, 2014
5 .htaccess snippets from HTML5 Boilerplate
View html5-boilerplate.htaccess
# 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>