[Solved] How to cre...
 
Notifications
Clear all

[Solved] How to create a file in github repo with content using Python CLI

0 Posts
1 Users
0 Likes
0 Views
0
Topic starter
Jeeva Asks: How to create a file in github repo with content using Python CLI
I am trying to create a github repo with a file, repo created successfully but when I try to create the file it returning, "Not Found" message.

Code:
{"message":"Not Found","documentation_url":"https://docs.github.com/rest"}

create_repo

Code:
def create_repo(repo_name, file_name, file_content):
    url = 'https://api.github.com/user/repos'
    headers = {"Accept": "application/vnd.github.v3+json"}
    data = {'name': repo_name}
    r = requests.post(url, auth=(USERNAME,TOKEN), headers=headers, data=json.dumps(data))
    print("Repo created")

    #  https://api.github.com/repos/InViN-test/test_repo1/contents/test.txt 

    data = {
        "branch": "master",
        'message': 'Initial commit', 
        "path": file_name, 
        'content': b64encode(file_content.encode('utf-8')).decode('utf-8'), 
        "committer": json.dumps({"name": USERNAME, "email": "myemail@gmail.com"}),
    }
    response = requests.put(f"{url}/{USERNAME}/{repo_name}/contents/{file_name}", auth=(USERNAME,TOKEN), headers=headers, data=json.dumps(data))
    print(response.text)

I am not sure, what am I missing 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.

 

 


 

Unreplied Posts

[Solved] No explicit songs show on my music

user135264 Asks: No explicit songs show on my music
I just purchased a bunch of new songs through the iTunes store on my computer and one by one I saw them being iClouded onto my iPhone.

I was very happy about this until I noticed that none of the songs that i bought marked “Explicit” were showing up.

Is there a way to fix this because I like these songs and honestly it’s like one word so I don’t see the big deal.

Can someone please tell me if it is possible to get these explicit songs onto music on my phone?

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] Daisy chain Dell with DisplayPort (output) to Apple Thunderbolt Display

Demiurg Asks: Daisy chain Dell with DisplayPort (output) to Apple Thunderbolt Display
I have a Dell P2720DC and Apple Thunderbolt Displays I want to daisy chain. Since the Dell has USB-C PD, I prefer connecting my MacBook to it, but then I’m not sure I can connect its DisplayPort output to Apple Thunderbolt Display.

Would it work? Which cable/adaptor to use?

If not, are there other options?

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] I uninstalled and reinstalled Uber, how does it still know who I am?

William Entriken Asks: I uninstalled and reinstalled Uber, how does it still know who I am?
I had uninstalled the Uber app on my iPhone. I do not have Uber Eats or another app install which appears to be related to Uber.

Also, I do NOT use iCloud.

Today I reinstalled Uber and found I am fully logged in.

By what mechanism specifically did Uber persist my account information while the app was uninstalled?

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] Apple Watch Series 3 refusing to charge only at night

IntelCorei9 Asks: Apple Watch Series 3 refusing to charge only at night
I unplugged my watch (watchOS 8, Series 3, 38mm, Bought in 2020) yesterday and put it on. It was on nightstand mode with the clock & green lightning bolt indicating it was charging (the screen was on all night though, I don’t know why). I got a 10% low power alert at 8am, an hour after I put it on.

I threw it back on its charger (the one it came with), and I got really ticked off. I checked it this morning & put it on, and it was already down to 95%, indicating it charged, but stopped at night.

The battery graph in Settings doesn’t even show it was charging at all.

How can I fix this?! It’s really frustrating.

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] Add custom column to post list table

Pagna Kong Asks: Add custom column to post list table
I have a custom post type called Book and I want to add the publisher and book author custom columns in the edit page.

I also want to fetch a specific value from each fields (I created two fields for the above columns) to display in those two additional columns. I actually can display with this code below but the point is I have to declare variable (for example: the $value variable) for each data.

So could you please share me some ideas to display that with loop or somethings.

Code:
add_filter( 'manage_book_posts_columns', 'set_custom_edit_book_columns' );
add_action( 'manage_book_posts_custom_column' , 'custom_book_column', 10, 2 );

function set_custom_edit_book_columns($columns) {
    $value = get_field( "contact_person" );
    unset( $columns['author'] );
    $columns['book_author'] = __( 'Author', 'your_text_domain' );
    $columns['publisher'] = __( 'Publisher', 'your_text_domain' );

    return $columns;
}

function custom_book_column( $column, $post_id ) {
    switch ( $column ) {

        case 'book_author' :
            $value = get_field( "contact_person" );
            $terms = get_the_term_list( $post_id , '$value' , '' , ',' , '' );
            if ( is_string( $value ) )
                echo $value;
            else
                _e( 'Unable to get author(s)', 'your_text_domain' );
            break;

        case 'publisher' :
            echo get_post_meta( $post_id , 'publisher' , true ); 
            break;

    }
}

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] Issue with user meta_query

Travis Kline Asks: Issue with user meta_query
I am creating a zip code radius search. I am pulling the all the zip codes within a radius depending on the search term through an API, then doing a user query to compare a custom meta field that has their zip and display those users if there is a match within the array of zip codes. I am doing this for both US/Canada. This is working except when I increase the radius and if that location happens to have a large amount of zip codes it breaks and no users are found. Especially in Canada there are literally thousands of zip code variations within just a 10km radius. For example if you look here Find Canadian Postcodes Inside a Radius and search T5T 3E9 there are over 10k zip code results.

This only seems to be related to having a very large array. Any thoughts?

Code:
curl_setopt($ch, CURLOPT_URL, "https://app.zipcodebase.com/api/v1/radius?" . 
http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"apikey: ", ));

$zipresponse = curl_exec($ch);
curl_close($ch);

$json = json_decode($zipresponse);


$resultArray = json_decode($zipresponse, true);
$zipCodd = $resultArray['results'];


$newzipArray = array();
if ( !empty( $zipCodd ) ) {
    $i = 0;
    foreach($zipCodd as $data){
        $i++;
            $newzipArray[$i] = str_replace(' ', '', $data['code']);
    }
}

$user_search_args = array (
  'number'          => 50, // How many per users
  'role'            => 'subscriber',
  's'               => '*' . esc_attr( $search_term ) . '*',
  'meta_query'      => array(
     'relation'    => 'OR',
          array(
              'key'     => array('mepr-address-zip', 'mepr_second_location_zip_2','mepr_third_location_zip_3'),
              'value'   => $newzipArray,
              'compare' => 'IN'
          ),

      )
  );

$user_search_query = new WP_User_Query( $user_search_args );

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] 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.

 

 


 

Share: