Skip to content

Instantly share code, notes, and snippets.

@linuslundahl
linuslundahl / _mixins.sass
Last active October 27, 2015 09:37 — forked from simme/_mixins.sass
SASS Mixins and Functions
// Rounds all the corners of a box
@mixin vector-bg-with-fallback($name) {
background-image: image-url('#{$name}.png');
background-image: none, image-url('#{$name}.svg');
}
@mixin border-radius($radius, $clip: padding-box)
-webkit-border-radius: $radius
-moz-border-radius: $radius
-o-border-radius: $radius
@linuslundahl
linuslundahl / jquery.el-in-view.js
Created December 10, 2011 11:20
jQuery Function that checks if an element is currently in the browser viewport.
function isScrolledIntoView(elem) {
var $win = $(window),
$elem = $(elem),
docViewTop = $win.scrollTop(),
docViewBottom = docViewTop + $win.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
@linuslundahl
linuslundahl / move_wordpress_blog.php
Created February 11, 2011 10:32
Change wordpress url in code, when there's no access to phpMyAdmin.
global $wpdb;
$query = "UPDATE $wpdb->posts SET post_content = REPLACE (
post_content,
'http://old.com',
'http://new.com')";
$wpdb->query($query);
$query = "UPDATE $wpdb->posts SET guid = REPLACE (
@linuslundahl
linuslundahl / remove-wp-attachment-thumbs.php
Created November 28, 2010 19:27
Remove generated attachment thumbnails from wordpress database.
global $wpdb;
$query = "SELECT meta_value, meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata'";
$result = $wpdb->get_results($query);
foreach ($result as $item) {
$meta = unserialize($item->meta_value);
unset($meta['sizes']);
$wpdb->update( 'wp_vira_postmeta', array('meta_value' => serialize($meta)), array('meta_id' => $item->meta_id) );
}
@linuslundahl
linuslundahl / Ignore .DS_Store forever
Created September 13, 2010 09:55
Make git always ignore .DS_Store
$ git config --global core.excludesfile ~/.gitignore
$ echo .DS_Store >> ~/.gitignore
@linuslundahl
linuslundahl / .inputrc
Created February 9, 2010 20:52
Bash key shortcuts
"\e[1~": beginning-of-line # Home key
"\e[4~": end-of-line # End key
"\e[3~": delete-char # Delete key
"\e[5C": forward-word # Ctrl+right
"\e[5D": backward-word # Ctrl+left
"\e\e[C": forward-word # Alt+right
"\e\e[D": backward-word # Alt+left
"\C-K": unix-line-discard # Ctrl+K
"\e\"": "@{}\e[D" # Insert @{} move cursor into braces