Skip to content

Instantly share code, notes, and snippets.

View juliaamosova's full-sized avatar
🏠
Working from home

Julia Amosova juliaamosova

🏠
Working from home
View GitHub Profile
@juliaamosova
juliaamosova / Display a short description of Mix & Match Product contents
Created May 25, 2017 02:59
Display a short description of Mix & Match Product contents
/** Add the following line to the 'wc-mnm-template-hooks.php' file */
add_action( 'woocommerce_mnm_row_item_description', 'woocommerce_template_mnm_product_description' );
***********************************
/** Add the following function to the 'wc-mnm-template-functions.php' file */
if ( ! function_exists( 'woocommerce_template_mnm_product_description' ) ) {
@juliaamosova
juliaamosova / Display shipping cost next to the Flat Rate which is set to be Free
Created May 26, 2017 02:35
Display shipping cost next to the Flat Rate which is set to be Free
/**
* Open `\wp-content\plugins\woocommerce\includes\wc-cart-functions.php`
* Search for `wc_cart_totals_shipping_method_label function`
* Replace it with the following function
**/
function wc_cart_totals_shipping_method_label( $method ) {
$label = $method->get_label();
if ( $method->cost >= 0 ) {
@juliaamosova
juliaamosova / julia-feedr-app.js
Created August 19, 2017 04:52
Feedr Project App
$(document).ready(function(){
// Array to store all feed sources
var SOURCES = [
{
displayName: "Reddit",
url: "https://www.reddit.com/r/worldnews/top/.json",
proxyRequired: false,
defaultSource: false, // You can have only one default source
formatResponse: function(response) {
@juliaamosova
juliaamosova / reverse-order-array.js
Created September 25, 2017 03:06
Hackerrank: Print each array element in reverse order
function main() {
var n = parseInt(readLine());
arr = readLine().split(' ');
arr = arr.map(Number);
console.log(arr.reverse().join(' '));
}
@juliaamosova
juliaamosova / hourglass-sum.js
Created September 25, 2017 03:38
Calculate the hourglass sum for every hourglass in array
// i - row
// j - column
function main() {
var arr = [];
var sum = 0;
var maxSum = -63;
for(arr_i = 0; arr_i < 6; arr_i++){
arr[arr_i] = readLine().split(' ');
arr[arr_i] = arr[arr_i].map(Number);
@juliaamosova
juliaamosova / stdin-stream.js
Created September 26, 2017 02:39
Hackerrank: Using readLine() to read a stream from STDIN
// Declare second integer, double, and String variables.
var i2;
var d2;
var s2;
// Read and save an integer, double, and String to your variables.
/* The parseInt() function parses a string argument and returns an integer of the specified radix
(the base in mathematical numeral systems).*/
i2 = parseInt(readLine());
@juliaamosova
juliaamosova / total-meal-cost.js
Created September 26, 2017 23:47
Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost.
var tip = mealCost * tipPercent/100;
var tax = mealCost * taxPercent/100;
var totalCost = Math.round(mealCost + tip + tax);
console.log("The total meal cost is " + totalCost + " dollars.");
@juliaamosova
juliaamosova / left-rotation.js
Created September 27, 2017 01:49
Given an array of n integers and a number , d, perform d left rotations on the array. Then print the updated array as a single line of space-separated integers.
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
@juliaamosova
juliaamosova / conditional-statement.js
Created September 28, 2017 02:51
Given an integer n, perform several conditional actions.
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
@juliaamosova
juliaamosova / array-elements-sum.js
Created September 28, 2017 03:34
Given an array of integers N, find the sum of its elements.
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});