View binary_tree_problem.js
// Question: In a binary tree, if in the path from root to the node A, there is no node with greater value than A’s, this node A is visible. | |
// We need to count the number of visible nodes in a binary tree. | |
// For example, in the following tree: | |
// | |
// 5 | |
// / \ | |
// 3 10 | |
// / \ / | |
// 20 21 1 | |
// |
View wp_functions.php
<?php | |
if (!defined('ABSPATH')) exit("Direct access not permitted."); | |
define('APP_NAME', 'Viral Startup'); | |
define('APP_SLUG', 'viral-startup'); | |
define('APP_VERSION', SCRIPT_DEBUG ? uniqid() : 1); | |
define('ASSETS_PATH', get_template_directory() . '/assets/dist'); | |
define('ASSETS_URI', get_template_directory_uri() . '/assets/dist'); |
View functions.sh
#!/bin/bash | |
function get_rand { | |
echo "$(date +%s)" | |
} | |
function is_empty { | |
if [[ -z "$1" ]]; then echo 1; else echo 0; fi | |
} |
View get-supported-css-event-name.js
// http://stackoverflow.com/a/1026087 | |
function capitalizeFirstLetter(string) { | |
return (typeof string === 'string' || string instanceof String) ? | |
string.charAt(0).toUpperCase() + string.slice(1) : | |
false; | |
} | |
/** | |
* Enum for css event group values. | |
* @readonly |
View .gitconfig
[alias] | |
l = log --pretty=format:\"%C(yellow)%h %ad%Cred%d %Creset%s%Cblue [%cn]\" --decorate --date=iso | |
la = "!git l --author=\"$(git config user.name)\"" | |
s = status --short | |
a = add | |
aa = add --all | |
ac = !git add . && git commit --all --message | |
b = branch | |
c = commit --verbose | |
cm = commit --verbose --message |
View facebook-spinner.css
.facebook-spinner { | |
@include facebook-spinner; | |
} |
View relative_date.php
# Copyright (c) 2020 Justin Bull | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# The above copyright notice and this permission notice shall be included in all |
View message.html
<div class="message orient-left theme-blue"> | |
<div class="message-inner"> | |
<div class="message-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar sodales ipsum, sit amet ultricies sem ultrices ut. Fusce lorem.</div> | |
</div> | |
</div> | |
<div class="message orient-right theme-gray"> | |
<div class="message-inner"> | |
<div class="message-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar sodales ipsum, sit amet ultricies sem ultrices ut. Fusce lorem.</div> | |
</div> | |
</div> |
View google_address_auto_complete
function getAddressComponents(address_components) { | |
var result = {}, | |
allowable_types = ['country', 'locality', 'postal_code', 'route', 'street_number', 'administrative_area_level_1'], | |
type_aliases = { | |
administrative_area_level_1: "region" | |
}; | |
$.each(address_components, function (index, value) { | |
var type = value.types[0]; | |
if (allowable_types.indexOf(type) >= 0) { | |
if (type_aliases.hasOwnProperty(type)) { |
View static_google_map
function convert_color(&$color) { | |
if (strpos($color, "0x")) return; | |
$color = ltrim($color, "#"); | |
if (ctype_xdigit($color)) $color = "0x" . $color; // is the color value a hexadecimal digit? | |
} | |
function static_google_map($mapAddress = null, $customParams = array(), $output = true) { | |
$delimiter = "&"; | |
$pipe = "%7C"; | |
$maxDimension = 640; | |
$apiPath = 'http://maps.googleapis.com/maps/api/staticmap'; |