Skip to content

Instantly share code, notes, and snippets.

jQuery(document).ready(function($) {
items = $('#menu-main-menu-1 li');
$.each(items, function() {
parent = $(this);
target = $(parent).find('.sub-menu-item-image');
image = $(parent).find('img');
src = $(image).prop('src');
$(target).html("<img class='menu-image' src='" + src + "' alt='menu image'>");
$(image).hide();
});
@wilhelser
wilhelser / gist:9426046
Created March 8, 2014 05:59
Easy Authorization
before_filter :validate_user
def validate_user
redirect_to home_path unless current_user and current_user.id == params[:id]
end

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@wilhelser
wilhelser / available_issues.rb
Created January 17, 2014 21:11
Logic for available issues
def get_current_available
property = self.property
frequency = property.frequency
@issues = []
@upcoming_issues = UpcomingIssue.where(:active => true)
@upcoming_issues.each do |i|
@issues << i.issue_month
end
case frequency
when 1
@wilhelser
wilhelser / webdev-learning-resources
Last active January 2, 2016 04:39
Web Dev Learning Resources
# Git
https://try.github.io/levels/1/challenges/1
Start with this: http://codeacademy.com
# HTML/CSS
http://tutsplus.com/course/30-days-to-learn-html-and-css/
http://learn.shayhowe.com/html-css/
http://www.codeavengers.com/
http://www.dontfeartheinternet.com/
#config/initializers/remove-this-sf_bs3_inputs.rb
#Credit: https://github.com/rafaelfranca/simple_form-bootstrap/issues/26#issuecomment-22435894
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
set :domain, "licensing.lichfield-001.vm.brightbox.net"
set :application, "licensing"
set :deploy_to, "/home/rails/#{application}"
set :user, "rails"
set :use_sudo, false
ssh_options[:forward_agent] = true
set :scm, :git
{
"use_simple_full_screen": false,
// calculates indentation automatically when pressing enter
"auto_indent": true,
// sets the colors used within the text area (default)
// see https://github.com/olivierlacan/monokaim to download
// the customized Monokai I use.
"color_scheme": "Packages/Color Scheme - Default/Monokaim.tmTheme",
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
#
# http://www.devthought.com/2009/09/19/get-ssh-copy-id-in-mac-os-x/
#
/*
* This code goes into your theme's functions.php
*/
add_filter( 'woocommerce_coupon_is_valid', 'custom_woocommerce_coupon_is_valid', 1, 2 );
function custom_woocommerce_coupon_is_valid( $valid, $coupon ) {
if ($coupon=='YOURCOUPONCODE') {
$min_quantity = 12;