Skip to content

Instantly share code, notes, and snippets.

@levymetal
levymetal / style.css
Created October 4, 2013 02:53
Show a wordpress submenu using only CSS
#sub-menu ul li {
display: none;
}
#sub-menu .menu > li > a {
display: none;
}
#sub-menu ul .current-menu-item,
#sub-menu ul .current-menu-item li,
@levymetal
levymetal / functions.php
Created March 29, 2018 00:30
Show a warning on the WordPress admin screen when a user uploads a PNG image to an ACF gallery, content area, or featured image.
<?php
/**
* Add a big fucking warning when the client uploads a PNG when they should
* be using a JPG
*/
function varga_62341_admin_png_warning() {
global $post_type;
echo '<script>var varga_62341_post_type="'.$post_type.'";</script>';
?>
@levymetal
levymetal / scss-syntax-test.scss
Created May 4, 2018 07:35
scss-syntax-test.scss
div,
%test,
.test,
#test-#{$test},
.test:not(.test),
.test:not(div),
.test[test] {}
&-test,
&.test {
@extend %test, .test;
@levymetal
levymetal / direct.js
Last active November 1, 2022 01:22
Tutorial on how to use jQuery resize to parent plugin, full post available @ http://christianvarga.com/jquery-resize-image-to-parent-container-plugin/
$('#myImage').resizeToParent();

Keybase proof

I hereby claim:

  • I am levymetal on github.
  • I am levymetal (https://keybase.io/levymetal) on keybase.
  • I have a public key whose fingerprint is 9B4B CA67 E4CB 4791 1894 BA66 A223 AEAA B714 64F3

To claim this, I am signing this object:

@levymetal
levymetal / functions.php
Last active November 1, 2022 02:34
Custom Wordpress function which displays a list of child pages from a common parent, which can be called from either the parent page (displays children) or any of the child pages (displays siblings).
<?php
function my_custom_submenu() {
global $post;
$menu_items = wp_get_nav_menu_items('Menu');
$current_menu_id = null;
// get current top level menu item id
foreach ( $menu_items as $item ) {
@levymetal
levymetal / gist:5083696
Last active November 1, 2022 02:35
Example of how to call use the php twitter cache available @ https://github.com/levymetal/php-twitter-cache
$.getJSON('/resources/twitter_cache.php', function(data) {
$.each(data, function(i) {
console.log( data[i] );
// do something with tweet
});
});
@levymetal
levymetal / twitterCache.php
Last active November 1, 2022 02:36
Stand-alone version of the php twitter cache found @ https://github.com/levymetal/php-twitter-cache
<?php
error_reporting( 0 ); // don't let any php errors ruin the feed
$username = 'username';
$number_tweets = 4;
$feed = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name={$username}&count={$number_tweets}&include_rts=1&callback=?";
$cache_file = dirname(__FILE__).'/cache/'.'twitter-cache';
$modified = filemtime( $cache_file );
$now = time();
@levymetal
levymetal / Gemfile
Last active November 1, 2022 02:36
Tutorial on how to create infinite scroll with Rails @ jQuery, full post @ http://christianvarga.com/blog/2013/02/simple-infinite-scroll-with-rails-and-jquery/
gem 'will_paginate', '~> 3.1.0'
@levymetal
levymetal / hosts
Last active November 1, 2022 02:36
Tutorial on how to use vhosts & MAMP, full post available at @ https://christianvarga.com/vhosts-and-mamp/
127.0.0.1 project1.localhost
127.0.0.1 project2.localhost