This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function filter_video_links( $content ){ | |
// Regular Expressions | |
$youtube_link = '@^\s*https?://(?:www\.)?(?:youtube.com/watch\?|youtu.be/)([^\s"]+)\s*$@im'; | |
$vimeo_link = '@^\s*https?://(?:www\.)?(?:vimeo.com/)@im'; | |
if( preg_match( $vimeo_link, $content ) ) { | |
// vimeo | |
$content = preg_replace( $vimeo_link, 'http://player.vimeo.com/video/', $content ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$events = new WP_Query( | |
array( | |
'post_type'=>'guru_events', | |
'orderby' => 'meta_value', | |
'meta_key' => 'the_event_date', | |
'order' => 'ASC' | |
) | |
); | |
while ( $events->have_posts() ) : $events->the_post(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
$('input[type=text]').each(function(){ | |
$(this).val( $(this).attr('placeholder') ); | |
}); | |
$('input[type=text]').keyup(function(){ | |
var placeholder = $(this).attr('placeholder'); | |
var regex = new RegExp(placeholder); | |
$(this).val( $(this).val().replace(regex, '')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extract urls from a website | |
require "open-uri" | |
if ARGV.size > 0 | |
url = ARGV[0] | |
open(url) do |data| | |
data.each_line do |line| | |
if result = line.match(/href="(.*?)"/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var forms = document.forms; | |
for(var i=0; i< forms.length;i++){ | |
for( var t=0; t <forms[i].elements.length; t++ ){ | |
//console.log( forms[i].elements[t].attributes ) | |
var placeholder = forms[i].elements[t].attributes.placeholder.value; | |
forms[i].elements[t].attributes.value.value = placeholder; | |
forms[i].elements[t].addEventListener('focus',function(){ | |
this.value = ''; | |
}) | |
forms[i].elements[t].addEventListener('blur',function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// modify post columns | |
add_filter('manage_guru_employees_posts_columns', 'employees_posts_columns', 5); | |
add_action('manage_guru_employees_posts_custom_column', 'employee_custom_columns', 5, 2); | |
function employees_posts_columns($columns){ | |
unset( $columns['riv_post_thumbs'] ); | |
unset( $columns['date'] ); | |
$columns['phone_number'] = __('Phone'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# distance class | |
class Distance | |
attr_accessor :value, :unit | |
@@var # class variable | |
@var # object variable | |
# @km = "miles / 0.62136" | |
# @miles = "km * 0.6214" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tut.to_tut( "Wow! Look at this get converted to Tut!" ) { |c| puts c } | |
# should outout : Wutowut! Lutookut atut tuthutisut gutetut cutonutvuteruttutedut tuto Tututut! | |
tut_string = "" | |
Tut.to_tut( "I'm in tut but I want to be in english." ) { |c| tut_string += c } | |
puts tut_string | |
# should output : I'mut inut tututut bututut I wutanuttut tuto bute inut enutgutlutisuthut. | |
Tut.to_english( tut_string ) { |c| print c } | |
# should output : I'm in tut but I want to be in english. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'class_tut_file' | |
require 'test/unit' | |
class TestTut < Test::Unit::TestCase | |
def setup | |
@tut = "I'mut inut tututut bututut I wutanuttut tuto bute inut enutgutlutisuthut." | |
@english = "I'm in tut but I want to be in english." | |
end | |
def test_is_tut | |
assert_equal true, Tut.is_tut?( @tut ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$(window).bind("scroll",function(e){ | |
if($(document).width() > 551) { | |
if($(document).height() > 1000) { | |
if($(document).scrollTop() > 100) { | |
$( ".site-branding" ).addClass( "site-branding-response" ); | |
$( ".site-title" ).addClass( "site-title-response" ); | |
$( ".menu-item" ).addClass( "menu-item-response" ); | |
$( ".company_contact_info" ).addClass( "company_contact_info_response" ); | |
} else { |
OlderNewer