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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
/** | |
* Filter the ID applied to a menu item's list item element. | |
* | |
* @since 3.0.1 | |
* @since 4.1.0 The `$depth` parameter was added. | |
* | |
* @param string $menu_id The ID that is applied to the menu item's `<li>` element. | |
* @param object $item The current menu item. | |
* @param array $args An array of {@see wp_nav_menu()} arguments. | |
* @param int $depth Depth of menu item. Used for padding. |
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
// remap jQuery to $ | |
(function($){ | |
// Can also be used with $(document).ready() | |
$(window).load(function() { | |
$('#navs-menu').click(function () { | |
$('.nav-menu').slideToggle(300); |
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
#Each statements do not allow their variables to be used outside of the statement. | |
<%= friends.each{|friend| friend['children']} %> | |
#To do this use `do`. | |
<% friends.each do | |
|friend| @uno = friend['name'] | |
end %> | |
<%= "#{@uno}" %> |
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
<% | |
for item in ids | |
puts item | |
end | |
%> | |
<% | |
ids.each do |item| | |
puts item | |
end |
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
<%= hobbiestostring = '[' + (friends.map{ |friend| (friend[ 'children' ]).map{ |nino| nino[ 'name'] }}).join(", ") + ']' %> |
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
<%= 'filexyz ' + (filexyz.class).to_s %> #>filexyz String | |
<%= (['filexyz'] + [filexyz.class]).join(" ") %> #>filexyz String |
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
#Code with block | |
$myvariable= imgarray.map do |layouts| | |
layouts[ 'layouts' ].map do |layout_name| | |
layout_name['layout_name'] | |
end | |
end | |
#Code on one line | |
$myvariable= (imgarray.map{ |layouts| (layouts[ 'layouts' ]).map{ |layout_name| (layout_name[ 'layout_name' ]) }} ) |
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
#Example 1 | |
$myvariable= imgarray.map do |layouts| | |
layouts[ 'layouts' ].map do |layout_name| | |
layout_name[ 'layout_name' ] | |
end | |
end | |
#Placing the variable at the beginning of the loop returns an array within an array: | |
#[["annie", "billy", "charlie", "danny", "eddy", "fergie", "granny", "henry", "jenny", "kelsey"]] | |
#Example 2 |
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
# This works in IRB but I could not get it to output in a browser. The command | |
# 'puts' will not output to a browser but with other methods, doing something | |
# like '{ |x| x}' usually works but not here. | |
hash.each_key { |x| puts x } | |
#This works to output to a browser. The output is an array. | |
hash.key |
OlderNewer