[Solved] Convert Va...
 
Notifications
Clear all

[Solved] Convert Varchar to Interval

0 Posts
1 Users
0 Likes
0 Views
0
Topic starter
thesofaking Asks: Convert Varchar to Interval
I have a Postgresql column that is a varchar that is saving a string that looks like '2 years, 5 months' or '3 months' or '9 years, 0 months'. I can't convert the column to an interval because it's going to break a bunch of existing functionality so what I am trying to do is cast that varchar into an interval in the select statement. I can't figure out how to do this, I was thinking I first need to format it into a timestamp then turn that into an interval? But haven't been able to find any info about this specific case. Thanks for the help!

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Unreplied Posts

[Solved] Adding donation buttons of campaign page into homepage list product

Agustin Lohse Asks: Adding donation buttons of campaign page into homepage list product
im working whit WP crowdfunding and Woocomerce. I been trying to take the predefined amount buttons that are in this photo:
I know that these buttons are containg in “wpcrowdfunding>wpcftemplate>woocommerce>basic>include>fund-campaign-btn.php”

Code:
<?php
defined( 'ABSPATH' ) || exit;
?>
<div class="wpneo-single-sidebar ASA">
    <?php
    global $post, $product;
    $currency = '$';
    if ($product->get_type() == 'crowdfunding') {
        if (wpcf_function()->is_campaign_valid()) {
            $recomanded_price = get_post_meta($post->ID, 'wpneo_funding_recommended_price', true);
            $min_price = get_post_meta($post->ID, 'wpneo_funding_minimum_price', true);
            $max_price = get_post_meta($post->ID, 'wpneo_funding_maximum_price', true);
            $predefined_price = get_post_meta($post->ID, 'wpcf_predefined_pledge_amount', true);
            if ( ! empty($predefined_price)){
                $predefined_price = apply_filters('wpcf_predefined_pledge_amount_array_a', explode(',', $predefined_price));
            }

            if(function_exists( 'get_woocommerce_currency_symbol' )){
                $currency = get_woocommerce_currency_symbol();
            }

            if (! empty($_GET['reward_min_amount'])){
                $recomanded_price = (int) esc_html($_GET['reward_min_amount']);
            } ?>

            <span class="wpneo-tooltip">
                <span class="wpneo-tooltip-min"><?php _e('Minimum amount is ','wp-crowdfunding'); echo $currency.$min_price; ?></span>
                <span class="wpneo-tooltip-max"><?php _e('Maximum amount is ','wp-crowdfunding'); echo $currency.$max_price; ?></span>
                <span class="wpneo-tooltip-empty"><?php _e('Put a valid number','wp-crowdfunding'); ?></span>
            </span>

            <?php
            if (is_array($predefined_price) && count($predefined_price)){
                echo '<ul class="wpcf_predefined_pledge_amount">';
                foreach ($predefined_price as $price){
                    $price = trim($price);
                    $wooPrice = wc_price($price);
                    echo " <li><a href='javascript:;' data-predefined-price='{$price}'> {$wooPrice}</a> </li> ";
                }
                echo "</ul>";
            }
            ?>

            <form enctype="multipart/form-data" method="post" class="cart AA">
                <?php do_action('before_wpneo_donate_field'); ?>
                <?php echo get_woocommerce_currency_symbol(); ?>
                
                <input oninput="this.value = this.value.replace(/[^0-9.]/g, '').split(/./).slice(0, 2).join('.')" type="number" step="any" min="0" placeholder="<?php echo $recomanded_price; ?>" name="wpneo_donate_amount_field" class="input-text amount wpneo_donate_amount_field text" value="<?php echo ($recomanded_price ? $recomanded_price : $min_price); ?>" data-min-price="<?php echo $min_price; ?>" data-max-price="<?php echo $max_price ?>" >

                <?php do_action('after_wpneo_donate_field'); ?>
                <input type="hidden" value="<?php echo esc_attr($post->ID); ?>" name="add-to-cart">
                <button type="submit" class="<?php echo apply_filters('add_to_donate_button_class', 'wpneo_donate_button'); ?>"><?php _e('Back Campaign', 'wp-crowdfunding'); ?></button>
            </form>

        <?php
        } else {
            if ( ! wpcf_function()->is_campaign_started()){
                wpcf_function()->campaign_start_countdown();
            }else{
                if( wpcf_function()->is_reach_target_goal() ){
                    _e('The campaign is successful.','wp-crowdfunding');
                }else{
                    _e('This campaign has been invalid or not started yet.','wp-crowdfunding');
                }
            }
        }
    }

    ?>
</div>

and i want to take these buttons into description.php. (wpneo short-description).

Code:
<?php
defined( 'ABSPATH' ) || exit;
global $post;
if ( ! $post->post_excerpt ) {
    return;
}
?>
<div style="clear: both"></div>
<div class="wpneo-single-short-description">
    <h2><?php _e('Short Story','wp-crowdfunding'); ?></h2>
    <div itemprop="description">
        <?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
    </div>
</div>

Should be this area:
im not quite sure of how to insert the fund-campaign buttons into the wpneo short description. Any help?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.
 
 
 

[Solved] How do I modify the custom footer text and get theme version number to show in wordpress admin?

ShrockCo Asks: How do I modify the custom footer text and get theme version number to show in wordpress admin?
I am trying to modify the footer text inside the wordpress admin and also get my custom themes version number to show as well but my function is not working properly, I am still very green at PHP

~ Thank-you in advance!

Code:
function modify_admin_footer() {
echo '<span id="footer-thankyou">Developed by <a href="http://www.toolcart.com" target="_blank" rel="noopener noreferrer">Toolcart Theme Version:</a>.</span>'; wp_get_theme()->parent()->Version;
}
add_filter( 'admin_footer_text', 'modify_admin_footer' );

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] What is the most efficient way to reverse an array in Javascript?

luisgo Asks: What is the most efficient way to reverse an array in Javascript?
I was asked recently what was the most efficient way to reverse an array in Javascript. At the moment, I suggested using a for loop and fiddling with the array but then realized there is a native Array.reverse() method.

For curiosity’s sake, can anyone help me explore this by showing examples or pointing in the right direction so I can read into this? Any suggestions regarding how to measure performance would be awesome too.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Docker build different in Github Actions

Ben Flowers Asks: Docker build different in Github Actions
When I build my docker file locally and push my application runs correctly. However when I Build through github actions I get an error that ‘flask’ is not installed.

It seems that the pip install step does nothing in Github actions – it just shows:

Code:
Step 8/13 : RUN pip install --trusted-host pypi.python.org -r /app/requirements.txt
 ---> Running in 6b0816c1bdc8
Removing intermediate container 6b0816c1bdc8

However on my local i get the full pip install output..

Is there something I am missing with Github Actions?

DockerFile:

Code:
FROM python:3.8-alpine
WORKDIR /app
ARG DB_PASSWORD

RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev

ADD ./requirements.txt /app
ADD ./src /app


RUN cat /app/requirements.txt
RUN pip install -r /app/requirements.txt

ENV DEBUG=false
ENV FLASE_DEBUG=false
ENV TESTING=false

ENTRYPOINT [ "python" ]

CMD [ "app.py" ]

Action Step:

Code:
- name: Build docker image and push to ECR
  run: /bin/bash $GITHUB_WORKSPACE/scripts/build_and_push.sh
  env:
    AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
    AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
    AWS_DEFAULT_REGION: "eu-west-1"

Build Script:

Code:
pipenv run pip freeze > requirements.txt

aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin {{ ECR Address}}

docker build -t {{ image name }} .

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Accessing the camera in iOS Safari on an iPhone

s5b Asks: Accessing the camera in iOS Safari on an iPhone
I have Single Page Webapp (SPA) that verifies the users as part of the signup process. Part of the verification is to capture a selfie of the user. To this end, I’ve implemented a version of the following code to get the camera input into a video element on the webpage, from which I can then sample images into a canvas.

Code:
navigator.mediaDevices.getUserMedia({ video: true, audio: false })
    .then(localMediaStream => {
      if ('srcObject' in video) {
        video.srcObject = localMediaStream;
      } else {
        video.src = window.URL.createObjectURL(localMediaStream);
      }
      video.play();
    })
    .catch(err => {
      console.error(`Not available!!!!`, err);
    });

This code is based on an example by Wes Bos, from his JavaScript30 course (#19 Unreal Webcam Fun). You can try it out here.

This code appears to work fine on most browsers, with the major exception of Apple Safari on iOS on an iPhone (example: iPhone 12 Pro, iOS 14.7.1). On the iPhone I get the first frame of the camera image captured and there after, the video element displays a black square.

Oddly, it works fine on an iPad (example: iPad Pro (11-inch), iOS 14.7.1), but not on any iPhone that I’ve tried.

I’ve seen a lot of discussion here on StackOverflow and elsewhere describing similar issues, but I’m yet to find a definitive answer, or better yet, a solution.

Does anybody have any idea?

Cheers, S t u a r t .

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] parse function in date-fns returns one day previous value

Asit Prakash Asks: parse function in date-fns returns one day previous value
I am trying to parse date using date-fns library but getting one day previous as result. How can I avoid this and get the right result?

Code:
start = '2021-08-16'
const parseStart = parse(start, 'yyyy-MM-dd', new Date());

output:

Code:
2021-08-15T18:30:00.000Z

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Is there a way to change the page number in the TOC when inserting a PDF?

Austin Benny Asks: Is there a way to change the page number in the TOC when inserting a PDF?
At the beginning of my document, i insert a 3 page pdf. In the TOC, i reference the items in the aforementioned 3 page pdf. However, the page number beside the TOC is incorrect. Is there a way to change this page number. Here is a MWE

I import to LaTeX like this:

Code:
includepdf[pages=-]{resources/frontmatter.pdf}

Right now I am putting this after begin{document}

Code:
% add signature block stuff
addcontentsline{toc}{section}{Signature Block}
addcontentsline{toc}{section}{Record of Revision}
setcounter{page}{4}

then this is what my TOC shows:


TOC

I want the page number beside signature block and record of revision to be 2 and 3 respectively. I don’t care about whether the TOC hyperlinks to the Signature block or Record of revisions; just want to change the page numver.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] How to use labels to group blocks in smartdiagram

Gee Asks: How to use labels to group blocks in smartdiagram
I have the below diagram and I want to group the different bars using arrows. My expected output is as shown here! [enter image description here]1. How can I group the different parts using arrow labels e.g. label blocks One, Two, and Three as Early; block Four as Middle, block Five and Six as Late, and block Seven as Very late.

Below is what I have for now.

Code:
documentclass[12pt]{article} 
usepackage{smartdiagram}
usetikzlibrary{shapes.symbols}

definecolor{blue(pigment)}{rgb}{0.2, 0.2, 0.6}
definecolor{yaleblue}{rgb}{0.06, 0.3, 0.57}
definecolor{warmblack}{rgb}{0.0, 0.26, 0.26}
definecolor{airforceblue}{rgb}{0.36, 0.54, 0.66}
definecolor{cerulean}{rgb}{0.0, 0.48, 0.65}
definecolor{charcoal}{rgb}{0.21, 0.27, 0.31}
definecolor{coolblack}{rgb}{0.0, 0.18, 0.39}
definecolor{darkslategray}{rgb}{0.18, 0.31, 0.31}
definecolor{frenchblue}{rgb}{0.0, 0.45, 0.73}
definecolor{indigo(dye)}{rgb}{0.0, 0.25, 0.42}
definecolor{bostonuniversityred}{rgb}{0.8, 0.0, 0.0}
definecolor{burgundy}{rgb}{0.5, 0.0, 0.13}

tikzset{description title/.append style={
    signal, 
    signal to=south, 
    signal from=north,
    yshift=-0.65cm, %0.65
  }
}

begin{document} 

begin{center}
smartdiagramset{description title width=2cm, 
description title text width=1.75cm, %1.75cm
descriptive items y sep=1.7, %2
description text width=8.75cm, %5.75
module minimum height=1.5cm} %1.25
smartdiagram[descriptive diagram]{%
{textbf{One},{Some text here}},          
{textbf{Two},{Some text here}},            
{textbf{Three},{Some text here}},         
{textbf{Four},{Some text here}},
{textbf{Five},{Some text here}},
{textbf{Six},{Some text here}},
{textbf{Seven},{Some text here}}}
end{center}
end{document}

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] How to give tabs or indent to symbol representation

Vedang Asks: How to give tabs or indent to symbol representation
I need to give indent or tab to each symbol I tried quad, tab, indent but doesn’t work.

Code:
begin{equation}
begin{split}
Where,\
&$u_{i}=$ Horizontal displacement
&$v_{mathrm{i}}=$ Vertical displacement\
&$varphi_{i}=$ Rotation Angle\
end{split}
end{equation}


enter image description here

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Best approach for web app that handles events and is stateful with websockets

diegosasw Asks: Best approach for web app that handles events and is stateful with websockets
I’ve got a web app in AsNetCore (.NET 5)

This app subscribes to a message bus, (with MassTransit over AWS SQS transport layer), so when it receives a new event/message it reacts to it and dequeues from the bus.

At the same time it exposes some functionality over http web API.

Now I have to integrate it with a third party (Zendesk API) which requires opening a websocket with their API and getting data from it or sending graphql requests.

So, as a summary, the flow would go like this

  1. the app receives a user subscribed event (it can persist then data in a DB)
  2. for each user subscribed event it receives it needs to open a websocket to Zendesk AND keep that channel open (here’s the problem) in order to send and receive messages to the third party. A thread per user?
  3. when a message from the bus is received such as user unsubscribed event or when a message is received from websocket indicating that connection has ended, then it releases that websocket

This mix between event driven and stateful websocket is what creates dilemma.

I guess I need a background task. (Hosted service, for example) capable of managing and keeping the different websockets with Zendesk API). Maybe spanning some threads or Tasks for each user subscribed? And then how does this background task knows about the users just subscribed or unsubscribed? How to communicate those events? Do I make some single instance that has the websockets connections and inject it in the message bus event handlers? Do I persist changes in a database and keep reading that database in a loop to know what has happened?

I’d appreciate any guidance on the best approach to tackle this in the most scalable way. I expect to have around 50 websockets opened at all times, it could be many more. I guess the app (and underlying server/OS could easily handle tens of thousands of them?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Share: