Skip to content

Instantly share code, notes, and snippets.

@ninnypants
ninnypants / bem-nesting.scss
Last active August 29, 2015 13:57
BEM Sass with nesting
.object {
/* styles */
&__child {
/* styles */
&--modifier {
/* styles */
}
}
@ninnypants
ninnypants / bem.scss
Created March 13, 2014 05:32
BEM Sass without nesting
.object {
/* styles */
}
.object__child {
/* styles */
}
.object__child--modifier {
/* styles */
@ninnypants
ninnypants / test.php
Last active January 3, 2016 16:59
Error while trying to use WP_Mock::expectActionAdded()
There was 1 error:
1) Admin_Tests::test_setup
Mockery\Exception\InvalidCountException: Method intercepted() from intercept should be called
at least 1 times but called 0 times.
@ninnypants
ninnypants / body-class.php
Created November 8, 2013 05:51
add body class to WordPress admin
<?php
add_filter( 'admin_body_class', 'blew_admin_body_class' );
function blew_admin_body_class( $body_class = '' ) {
$screen = get_current_screen();
if ( 'my-screen' == $screen->id ) {
$body_class .= ' my-class';
}
return $body_class;
}
@ninnypants
ninnypants / .gitignore_global
Created November 5, 2013 17:00
WordPress section of .gitignore_global
wp-config.php
wp-config-sample.php
bb-config.php
/wp-content/uploads
/wp-content/*.dir
/wp-content/blogs.dir/
/wp-content/upgrade
@ninnypants
ninnypants / head.txt
Created November 5, 2013 16:47
Head requests to inmonsey.com
$ curl -I http://www.inmonsey.com
HTTP/1.1 301 Moved Permanently
Server: cloudflare-nginx
Date: Tue, 05 Nov 2013 16:45:54 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: __cfduid=d940d8f2566861fa392c2e1920860fcbd1383669954425; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.inmonsey.com; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
X-Pingback: http://inmonsey.com/xmlrpc.php
@ninnypants
ninnypants / my-widget.php
Created October 29, 2013 17:20
Example method for registering a WordPress widget
<?php
class My_Widget extends WP_Widget {
// normal logic here
public static function register() {
register_widget( __CLASS__ );
}
}
add_action( 'widgets_init', 'My_Widget::register' );
@ninnypants
ninnypants / .htaccess
Created October 10, 2013 15:45
Hack plugin that showed up on one of our client's server in the directory `wp-content/plugins/gtw`
<Files gtw.php>
order allow,deny
deny from all
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_COOKIE} 5ddbd0b828686cf8f3996daf5e5f642f
@ninnypants
ninnypants / rgb-to-hex.js
Created September 9, 2013 20:49
Bookmarklet to quickly parse an rgb value into a hex vaule
/**
* RGB to HEX
* @author ninnypants
*/
(function(){var b=prompt("","rgb( 255, 255, 255 )");var a=b.match(/(?:rgba?\()?\s*(\d{1,3}),?\s*(\d{1,3}),?\s*(\d{1,3}),?\s*(?:\d?\.?\d+)?(?:\))?/);var c="#"+parseInt(a[1]).toString(16)+parseInt(a[2]).toString(16)+parseInt(a[3]).toString(16);prompt("",c)})();
(function(){
var raw = prompt( '', 'rgb( 255, 255, 255 )' );
var matched = raw.match(/(?:rgba?\()?\s*(\d{1,3}),?\s*(\d{1,3}),?\s*(\d{1,3}),?\s*(?:\d?\.?\d+)?(?:\))?/);
(function($){
$(document).ready(function(){
$('a').click(function(e){
var el = $(this).prev('input[type="checkbox"]');
if(el.is(':checked')){
el.prop('checked',false);
}
$.ajax({
url : 'http://localhost/wordpress/wp-admin/admin-ajax.php',
type : 'POST',