Skip to content

Instantly share code, notes, and snippets.

@mazell
mazell / box-shadow-top.css
Created March 14, 2014 08:12
CSS: Box Shadow Top
.shadow {
-moz-box-shadow: inset 0px 40px 40px -40px #ccc;
-webkit-box-shadow: inset 0px 40px 40px -40px #ccc;
box-shadow: inset 0px 40px 40px -40px #ccc;
}
@mazell
mazell / url.js
Created April 8, 2014 07:27
js:urlparam
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
@mazell
mazell / param.htaccess
Created April 8, 2014 08:24
config:htaccess param
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /power.php?story=$1 [L]
@mazell
mazell / insetshadow.css
Created April 9, 2014 11:11
CSS: Inset shadow
.some-element{
position: relative;
letter-spacing: 0px;
text-shadow: -1.5px -1px 0px #3a3a3a;
text-decoration: none;
}
.btn-send:before, .btn-send:after {
content: attr(title);
color: rgba(255,255,255,1);
@mazell
mazell / wp-path.php
Created April 20, 2014 17:55
WP: Paths
// Sökvägar
define('WP_SITEURL', 'http://' . DOMAIN . '/wordpress');
define('WP_HOME', 'http://' . DOMAIN);
define('WP_CONTENT_DIR', dirname( __FILE__ ) . '/content');
define('WP_CONTENT_URL', 'http://' . DOMAIN . '/content');
define('WP_DEBUG',false);
@mazell
mazell / commands.txt
Created May 13, 2014 09:49
command: npm access rights
sudo chown -R `whoami` ~/.npm
@mazell
mazell / wp-post-loop.php
Created May 14, 2014 07:12
WP:for-loop over the_loop
<?php for ($currentPost=0; $currentPost < count($the_posts); $currentPost++) {
setup_postdata( $GLOBALS['post'] =& $the_posts[$currentPost] );
?>
<article class="bit-3 box-<?php echo $box_matrix[$currentPost] ?>">
<header>
<h2><?php the_title(); ?></h2>
</header>
<p><?php the_content();?></p>
</article>
<?php
@mazell
mazell / taxanomies.php
Created June 12, 2014 12:50
WP:Taxanomies support pages
function myplugin_settings() {
// Add tag metabox to page
register_taxonomy_for_object_type('post_tag', 'page');
// Add category metabox to page
register_taxonomy_for_object_type('category', 'page');
}
// Add to the admin_init hook of your theme functions.php file
add_action( 'admin_init', 'myplugin_settings' );
@mazell
mazell / GA.js
Created January 28, 2015 13:29
GA.JS
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'INSERT KEY HERE', 'auto');
ga('send', 'pageview');
@mazell
mazell / wait-for-final-event.js
Created February 11, 2015 13:30
WaitForFinalEvent
* Wrap your actions in this function to throttle the frequency of firing them off, for better performance, esp. on mobile.
* ( source: http://stackoverflow.com/questions/2854407/javascript-jquery-window-resize-how-to-fire-after-the-resize-is-completed )
var waitForFinalEvent = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) { uniqueId = "Don't call this twice without a uniqueId"; }
if (timers[uniqueId]) { clearTimeout (timers[uniqueId]); }
timers[uniqueId] = setTimeout(callback, ms);
};