This file contains 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
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) | |
VALUES ('newadmin', MD5('pass123'), 'firstname lastname', '[email protected]', '0'); | |
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) | |
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); | |
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) | |
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10'); |
This file contains 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
function drawCircle(text, size, color) { | |
var textSize = Math.ceil(size / 2.5); | |
var font = 'Proxima Nova, proxima-nova, HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif'; | |
var colors = ["#1abc9c", "#16a085", "#f1c40f", "#f39c12", "#2ecc71", "#27ae60", "#e67e22", "#d35400", "#3498db", "#2980b9", "#e74c3c", "#c0392b", "#9b59b6", "#8e44ad", "#bdc3c7", "#34495e", "#2c3e50", "#95a5a6", "#7f8c8d", "#ec87bf", "#d870ad", "#f69785", "#9ba37e", "#b49255", "#b49255", "#a94136"]; | |
var colorIndex = Math.floor((text.charCodeAt(0) - 65) % colors.length); | |
var finalColor = color || colors[colorIndex]; | |
var template = [ | |
'<svg height="' + size + '" width="' + size + '" style="background: ' + finalColor + '">', | |
'<text text-anchor="middle" x="50%" y="50%" dy="0.35em" fill="white" font-size="' + textSize + '" font-family="' + font + '">' + text.toUpperCase() + '</text>', |
This file contains 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
#Model | |
expect(@user).to have(1).error_on(:username) # Checks whether there is an error in username | |
expect(@user.errors[:username]).to include("can't be blank") # check for the error message | |
#Rendering | |
expect(response).to render_template(:index) | |
#Redirecting |
This file contains 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
// Add to functions.php in the theme to exclude categories from the built-in categories widget | |
function exclude_widget_categories($args){ | |
$exclude = "105,102,108,112"; // The IDs of the excluding categories | |
$args["exclude"] = $exclude; | |
return $args; | |
} | |
add_filter("widget_categories_args","exclude_widget_categories"); |
This file contains 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
module ArrFlatten | |
# Public: Returns a flat array | |
# | |
# nested_array - A nested array | |
# | |
# Examples | |
# nested_array = [ [1,2,3], [4,5,6], [7,8,9] ] | |
# ArrFlatten.arr_flatten(nested_array) | |
# => [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
# |
This file contains 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
$('<element>').on('blur',function () { var blurEl = $(this); setTimeout(function() {blurEl.focus()},10) }); |
This file contains 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
"Hello, world!".split(//) | |
#=> ["H", "e", "l", "l", "o", ",", " ", "w", "o", "r", "l", "d", "!"] |
This file contains 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
/^(\d++(?! *\/))? *-? *((?:(\d+) *\/ *(\d+)))?(.*)$/ | |
# "1 1/2 parts".scan(/^(\d++(?! *\/))? *-? *((?:(\d+) *\/ *(\d+)))?(.*)$/) => [["1", "1/2", "1", "2", " parts"]] | |
# "25ml".scan(/^(\d++(?! *\/))? *-? *((?:(\d+) *\/ *(\d+)))?(.*)$/) => [["25", nil, nil, nil, "ml"]] | |
# "1 ounce".scan(/^(\d++(?! *\/))? *-? *((?:(\d+) *\/ *(\d+)))?(.*)$/) => => [["1", nil, nil, nil, "ounce"]] |
This file contains 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
$("a[href*=#]:not([href=#])").click -> | |
if location.pathname.replace(/^\//, "") is @pathname.replace(/^\//, "") or location.hostname is @hostname | |
target = $(@hash) | |
target = (if target.length then target else $("[name=" + @hash.slice(1) + "]")) | |
if target.length | |
$("html,body").animate | |
scrollTop: target.offset().top | |
, 1000 | |
false |
This file contains 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
#Make a quick backup of a file before changing it: | |
cp /path/to/your-file{,.bak} | |
#Make some changes, then compare the newly-edited file and its backup: | |
diff /path/to/your-file{.bak,} | |
#Undo changes: |
NewerOlder