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
| FROM php:7.3-fpm as BASE_PHP | |
| ENV V8_VERSION=9.9.115.9 | |
| RUN apt-get update -y --fix-missing && apt-get upgrade -y; | |
| # Install v8js (see https://github.com/phpv8/v8js/blob/php7/README.Linux.md) | |
| RUN apt-get install -y --no-install-recommends \ | |
| libtinfo5 libtinfo-dev \ | |
| build-essential \ | |
| curl \ |
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
| FROM php:7.3-fpm as BASE_PHP | |
| ENV V8_VERSION=9.9.115.9 | |
| RUN apt-get update -y --fix-missing && apt-get upgrade -y; | |
| # Install v8js (see https://github.com/phpv8/v8js/blob/php7/README.Linux.md) | |
| RUN apt-get install -y --no-install-recommends \ | |
| libtinfo5 libtinfo-dev \ | |
| build-essential \ | |
| curl \ |
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
| def counting_sort(A, length): | |
| # First fint the maximum value | |
| k = max(A) | |
| Aux = list() | |
| for i in range(0, k+1): | |
| Aux.insert(i, 0) | |
| for i in range(0, length): | |
| Aux[A[i]] += 1 |
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
| # Prints out the time it takes for a function to run | |
| def time_runtime(function): | |
| @wraps(function) | |
| def wrapper(*args, **kwargs): | |
| start = time.time() | |
| result = function(*args, **kwargs) | |
| end = time.time() | |
| print("Time to run in seconds: {}".format(end-start)) | |
| return result | |
| return wrapper |
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
| # Big Theta (n^2) | |
| def insertion_sort(A: list): | |
| # Start loop from 1, as 0 wont be compared to it self | |
| for j in range(1, len(A)): | |
| #block 1 | |
| key = A[j] | |
| # Block 2 | |
| i = j - 1 | |
| while i > -1 and A[i] > key: |
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
| /* Set default close message */ | |
| function default_give_form_closed_message($post_id, $post, $update){ | |
| if (! $update ) { | |
| $meta_key = '_give_form_goal_achieved_message'; | |
| $meta_value = "Mange tak, vi har nået målet for indsamlingen!"; | |
| $current_close_message = get_post_meta( $post_id, '_give_form_goal_achieved_message', true ); | |
| if (empty($current_close_message)) | |
| update_post_meta($post_id, $meta_key, $meta_value, $prev_value=$current_close_message); | |
| } |
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
| function add_donation_names_to_give_forms(){ | |
| global $post; | |
| $content = ""; | |
| if (get_post_type( $post->ID) == "give_forms") { | |
| ob_start(); | |
| ?> <h2>Andre donation</h2> <?php | |
| echo do_shortcode('[give_donor_wall form_id="'.$post->ID.'"]'); | |
| $content = ob_get_clean(); | |
| } | |
| echo $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
| /* Get total earnings with currency */ | |
| function get_total_earnings($atts = []) { | |
| /* | |
| * Posible parameters for atts start_date and end_date: | |
| * today | |
| * yesterday | |
| * this_week | |
| * last_week | |
| * this_month | |
| * last_month |
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
| function set_default_featured_image($post_id, $post, $update){ | |
| if ( ! $update && ! ((bool) get_post_thumbnail_id($post_id))){ | |
| $img_id = 2675; | |
| //$post_id = 2784; | |
| set_post_thumbnail( $post_id, $img_id ); | |
| add_post_meta($post_id, '_thumbnail_id', $img_id); | |
| } | |
| } |
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
| /* Register user at checkout */ | |
| function wc_register_guests( $order_id ) { | |
| // get all the order data | |
| $order = new WC_Order($order_id); | |
| //get the user email from the order | |
| $order_email = $order->billing_email; | |
| // check if there are any users with the billing email as user or email | |
| $email = email_exists( $order_email ); |
NewerOlder