text:
Q: How covert upload functionality to S3 bucket in AWS Currently we are connecting with one file share path for uploading files.Now I need to changes this file share path to s3 bucket.I need to connect with S3 bucket for uploading file.
Here is the sample code is
import java.util.Vector;
import com.jcraft.jsch.*;

public class JSCH_FTP_Connection {

    public static void main(String[] args) throws JSchException, SftpException {

        Session session = null;
        JSch jsch = new JSch();
        ChannelSftp channelSftp = null;
         Channel     channel = null;
        String remoteDirectory = "/test";
        String getFtpHost="http://localhost:";
        String getFtpUser="test";
        String getFtpPasswd="test";
        session = jsch.getSession(getFtpUser,getFtpHost);
        java.util.Properties config = new java.util.Properties();

        config.put("StrictHostKeyChecking", "no");
        session.setPassword(getFtpPasswd);
        session.setConfig("cipher.s2c", "aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,aes256-ctr");
        session.setConfig(config);

        session.connect();
        channel = session.openChannel("sftp");
        channel.connect();
        channelSftp = (ChannelSftp)channel;
        channelSftp.cd(remoteDirectory);
        Vector filelist = channelSftp.ls(remoteDirectory);
        for(int i=0; i<filelist.size();i++){
            LsEntry entry = (LsEntry) filelist.get(i);
            System.out.println(entry.getFilename());
        }

    }

}

I am using jcsh.jar for uploading the files.

A: AWS sdk are available for JAVA or Scala to interact with s3.
Refer to below links for more details:
https://aws.amazon.com/sdk-for-java/
https://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpJava.html
For python you can use boto3 library for the same.


text:
Q: XMLHttpRequest pending in Chrome but is fine on IE The data that I want to get is from API that is only return XML format.
When using IE the request is send and I get beck a response and all is fine. But when I try to use Chrome same request is in pending.
Also I have try the same code to call some open API on internet for testing that return .JSON and the same code is working on Chrome. So what am I doing wrong ?
var req = null;
    req = new XMLHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4 && req.status == 200) {
            alert("Hi")
        }
    };
    req.open("GET", "LINK" ,false);
    req.send(null);

redpajama_set_name: RedPajamaStackExchange


text:
Q: Are custom component configuration variables not supported in the new release templates? Release Management always had the concept of "components", which are units of deployment that can be independently configured in the pipeline. Each component could have a number of stage-specific configuration variables, that could be configured in the component itself, like this:

Then, in the template instance, these could be set to different values depending on the stage:

But on the vNext components, required for the new vNext templates that use PowerShell DSC or Chef, these configuration variables don't exist anymore:

Are stage-specific configuration variables not supported anymore in RM? Am I responsible for setting these variables myself using PowerShell inside the configuration script now?

A: vNext components don't support tokenized configuration files. I think the idea is that setting the application's configurations are going to be handled via DSC, instead of via RM. I noticed the same thing when I was playing with DSC deployments.
Old-style components still support tokenized configuration files.


text:
Q: Parse Facebook Login Swift 3.0 I am trying to login to Facebook using Parse and create a new Parse user as result. There is no proper Facebook login Documentation for Parse. Some of them are really outdated I have browsed every Parse + Facebook login post on Stack Overflow and Could not get any answer.
PS I cannot comment on existing posts as I am just starting out on Stack overflow and my reputation is on the lower side.
I have the following code in a button. When I click on the button I am redirected to Facebook where I give permission and then it just stays there. Meanwhile in the console "Uh oh. The user cancelled the Facebook login." is printed When I print out the user and error(both are nill inside the PFFacebookUtils.logInInBackground).
I have tried a lot of things like changing methods in App Delegate to find a work around for this. I have not succeeded until now.
The following is the code in my Button
         @IBAction func FacebookLogin(_ sender: Any) {

    //var permissions = [ "public_profile" ]

    PFFacebookUtils.logInInBackground(withReadPermissions: permissions) { (user, error) in            if let user = user {
        if user.isNew {
            print("User signed up and logged in through Facebook!")
        } else {
            print("User logged in through Facebook!")
        }
    } else {
        print("Uh oh. The user cancelled the Facebook login.")
        }
    }

}

Here is my app delegate relevant FB functions I added. It would be great if you could have a look at it
func application(application:UIApplication,openURL url: NSURL,sourceApplication:String?,
        annotation:AnyObject) ->Bool{

        return FBSDKApplicationDelegate.sharedInstance().application(application,open: url as URL!, sourceApplication: sourceApplication,annotation: annotation)

    }

  func applicationDidBecomeActive(_ application: UIApplication) {
        FBSDKAppEvents.activateApp()
    }

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Enable storing and querying data from Local Datastore.
        // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy.
        Parse.enableLocalDatastore()

        let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
            ParseMutableClientConfiguration.applicationId = "xxxxxx"
            ParseMutableClientConfiguration.clientKey = "xxxxxx"
            ParseMutableClientConfiguration.server = "xxxxxx"
        })

        Parse.initialize(with: parseConfiguration)

        //PFUser.enableAutomaticUser()

        PFFacebookUtils.initializeFacebook(applicationLaunchOptions: launchOptions)

        let defaultACL = PFACL();

        // If you would like all objects to be private by default, remove this line.
        defaultACL.getPublicReadAccess = true

        PFACL.setDefault(defaultACL, withAccessForCurrentUser: true)

        if application.applicationState != UIApplicationState.background {
        return FBSDKApplicationDelegate.sharedInstance().application(application,didFinishLaunchingWithOptions:launchOptions)
    }

Finally in my Bridging header
#ifndef ParseStarterProject_Bridging_Header_h
#define ParseStarterProject_Bridging_Header_h
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <FBSDKCoreKit/FBSDKcoreKit.h>
#endif /* ParseStarterProject_Bridging_Header_h */

A: Replace your method:
func application(application:UIApplication,openURL url: NSURL,sourceApplication:String?,
        annotation:AnyObject) ->Bool

by this:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}

Otherwise the SDK does not call your method
I hope my answer was helpful


text:
Q: mysql sort string number I have a column of type varchar that stores many different numbers. Say for example there are 3 rows: 17.95, 199.95 and 139.95.How can i sort that field as numbers in mysql

A: This approach is helpful when sorting text as numbers:
SELECT `my_field`
FROM `my_table`
ORDER BY `my_field` + 0;

Found the solution on http://crodrigues.com/trick-mysql-order-string-as-number/.

A: Pad the string with leading zeroes:
ORDER BY LPAD(`column`,<max length of string>,"0")

A: If you really have to you can do this if your source data is compatible:
SELECT column FROM table ORDER BY CAST(column AS DECIMAL(10,2))

It's not going to be very fast for large data sets though. If you can you should change the schema to use DECIMAL in the first place though. Then it can be properly indexed for better performance.

A: If you need to sort a char column containing text AND numbers then you can do this.

tbl contains: 2,10,a,c,d,b,4,3

select * from tbl order by number_as_char * 1 asc, number_as_char asc

expected output: 2,3,4,10,a,b,c,d

If you don't add the second order by argument only numbers will be sorted - text actually gets ignored.

A: Quickest, simplest? use * 1
select *
from tbl
order by number_as_char * 1

The other reasons for using * 1 are that it can

*

*survive some horrendous mishaps with underflow (reduced decimal precision when choosing what to cast to)

*works (and ignores) columns of purely non-numeric data

*strips numeric portions of alphanumeric data, such as 123A, 124A, 125A

A: Use a CAST or a CONVERT function.


text:
Q: Exceptions when invoking email composer in WP8 and the App crashes Iam developing an App for WP8 in which the application is getting crashed while invoking email composer.
The thread 0x40 has exited with code 259 (0x103).
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in Microsoft.Phone.ni.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll
Am using de.appplant.cordova.plugin.email-composer plugin to invoke email composer. Please help me out.

A: I found the reason for this issue. When sending email am giving some data as inline html which exceeds the limit of gmail composer. Due to this the app was crashing.


text:
Q: How can I format date using json.SerializerSettings.Converters to look like 1288323623006 I am currently using the following date filter in my WebAPI application:
json.SerializerSettings.Converters.Add(
   new IsoDateTimeConverter { DateTimeFormat = "dd-MM-yyyy hh:mm" });

I started to use this as my front end could not understand the dates. If I remember correctly it was due to the way milliseconds were formatted with too many digits.
What I need is to get the date into a format like this:
1288323623006

Can someone suggest how I can do this using the serializer. Is this different from the default?

A: You don't want to use IsoDateTimeConverter at all - you possibly want to use JavaScriptDateTimeConverter. That will convert it into new Date(...) with the right value - but I believe it really will include the new Date(...) part. If you don't want that, you'll probably need to write your own converter.
It shouldn't be too hard to write a converter - although you need to decide how to handle the different kinds of DateTime. For example, if you're asked to convert a DateTime with a Kind of Unspecified, do you want to assume it's actually already in UTC, or already in the system local time zone, or something else?
Once you've got an appropriate "instant" in time, you just need to find the number of milliseconds between that and the Unix epoch (1st January 1970 00:00:00, UTC) and convert that number of milliseconds into a string.

A: I think that's what you want
 private static readonly long DatetimeMinTimeTicks = (new DateTime(1970, 1, 1, 0, 0, 0,     DateTimeKind.Utc)).Ticks;
 long b = (long)((Calendar1.SelectedDate).ToUniversalTime().Ticks - DatetimeMinTimeTicks) / 10000;


text:
Q: how to set a ruby application to run on multiple environments I have developed a simple ruby application without any MVC, and runs on command prompt using ruby 1.9.2 . It also has a Gemfile. I want this application to run on machines running ruby 1.8.7 and 1.9.3 as well. So how can I set it right for multiple environments.
Please Guide.
Thanks

A: At first you have to make sure that your code is compatible with the syntax of ruby 1.8 and 1.9 https://stackoverflow.com/a/21621/335523
Then make sure that the gems you used support both versions of ruby. (Read through their github page or documentation)
If you are using gems that do not suport both versions of ruby you have to find alternative gems that provide the same functionality in each environment and specify them in your gem file like this:
gem 'rcov', :platforms => :ruby_18
gem 'simplecov', :platforms => :ruby_19


text:
Q: Font awesome icon not working I'm building a website but for some reason my fa-home is not working.
HTML Code:
<!DOCTYPE html>

        <title>Chezzles</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="css/normalize.css" type="text/css" />
        <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="css/style.css" type="text/css" />

Chezzles

Home

Blog

About

Contact

Summer

RSS

Twitter

Facebook

Instagram

CSS Code:
@import url(https://fonts.googleapis.com/css?family=Raleway:400,300italic,300,200italic,200,100italic,100,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic&subset=latin,latin-ext);

p {
    font-family: sans-serif;
}

.header {
    width: 17.3%;
    background-color: #191818;
    position: fixed;
    height: 100%;
}

.main-heading {
    color: #fff;
    margin-left: 30px;
    font-family: Raleway;
}

.hr {
    border-bottom: 1px solid #7B68EE;
}

.main-navbar li, .sub-navbar li {
    list-style-type: none;
}

.main-navbar li a, .sub-navbar li a {
    font-family: sans-serif;
    text-decoration: none;
    font-size: 0.9em;
    line-height: 3em;
    color: #999;
}

A: I created working JSFiddle with your code, all work fine! I think you have unworking link to Font Awesome library. Change it to working link, for example:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

Check it!


text:
Q: Split Screen into Two View Controllers SpritKit + Swift I am making a simple Pong game using SpriteKit + Swift. I am trying to move the two paddles even if a finger is already touching the display. I got a suggestion to split the screen into two View Controller. Would this help? If so, how would this be done?
Link to previous question.
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    let touch = touches.first as UITouch?
    let touchLocation = touch?.locationInNode(self)
    let body: SKPhysicsBody? = self.physicsWorld.bodyAtPoint(touchLocation!)

    if body?.node!.name == PaddleCategoryName {
        print("Paddle Touched!")
        fingerIsOnPaddle = true
    }

    if body?.node!.name == PaddleCategoryName2 {
        print("Paddle2 Touched!")
        fingerIsOnPaddle2 = true
    }

}

override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
    if fingerIsOnPaddle {
        let touch = touches.first as UITouch?
        let touchLocation = touch?.locationInNode(self)
        let previousTouchLocation = touch?.previousLocationInNode(self)

        let paddle = self.childNodeWithName(PaddleCategoryName) as! SKSpriteNode

        var newYPosition = paddle.position.y + (touchLocation!.y - previousTouchLocation!.y)

        newYPosition = max(paddle.size.height / 2, newYPosition)
        newYPosition = min(self.size.height - paddle.size.height / 2, newYPosition)

        paddle.position = CGPointMake(paddle.position.x, newYPosition)

    }

    if fingerIsOnPaddle2 {
        let touch = touches.first as UITouch?
        let touchLocation = touch?.locationInNode(self)
        let previousTouchLocation = touch?.previousLocationInNode(self)

        let paddle2 = self.childNodeWithName(PaddleCategoryName2) as! SKSpriteNode

        var newYPosition = paddle2.position.y + (touchLocation!.y - previousTouchLocation!.y)

        newYPosition = max(paddle2.size.height / 2, newYPosition)
        newYPosition = min(self.size.height - paddle2.size.height / 2, newYPosition)

        paddle2.position = CGPointMake(paddle2.position.x, newYPosition)
    }
}

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
    fingerIsOnPaddle = false
    fingerIsOnPaddle2 = false
}

A: The primary problem with the code you have provided is that you are only using the first touch, which is not good when you have two people moving the paddles around.  I would in fact not use touchesBegan or touchesEnded.  I'm going to assume that the game field will have x along the horizontal, so 512 (the default scene width divided by 2) will be the middle line, with the paddles positioned at x = 0 and x = 1024.
The code below is in touchesMoved, and handles each touch that moved.  If the touch location is on one side of the screen, it gets the paddle for that side and moves it.  You may wish to put this code in the touchesBegan method as well, so that the user can touch where they want the paddle to go.  You could go back to your paddle detection method (I didn't see anything wrong with it aside from not using every touch), but I would recommend using paddle.containsPoint to test if the touch is inside.
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
    for touch: UITouch in touches {
        let location = touch.locationInNode(self)
        if location.x < 512 {
            let paddle = self.childNodeWithName(PaddleCategoryName) as! SKSpriteNode
            paddle.position.y = location.y
        } else {
            let paddle2 = self.childNodeWithName(PaddleCategoryName2) as! SKSpriteNode
            paddle2.position.y = location.y
        }
    }
}

I am currently downloading Xcode 7 to get Swift 2, and I will edit this with proper syntax.  But for now, with a few changes (like to the method call), it should work.


text:
Q: Cron expression at 8:00 and 16:30 from monday to friday How can I write a CRON expression that will invoke Azure WebJob Monday through Friday at 8:00 AM and 4:30 PM?

A: You can have a job triggering at 8AM and 16PM Monday through Friday using
0 0 8,16 ? * MON,TUE,WED,THU,FRI *

If you definitely need 16:30, you will need 2 CRON triggers.
0 0 8 ? * MON,TUE,WED,THU,FRI *
0 0 16 ? * MON,TUE,WED,THU,FRI *

You can check your CRONs HERE.
As mentioned in this existing question, Single CRON is possible if the minute triggering is the same.

A: Recently I have used this and it worked for me:
0 3 * * 1-5
The above format is basically-
(min) (hr) (day in month) (month) (day in week)


text:
Q: Django REST asks for CSRF token even with TokenAuthentication I am building a server for both mobile and web environments and I want to have session auth alongside with token auth. However, these seem to be at odds with each other.
I have a different view for logins in both schemes.
If I log in as a user inside the browsable API and then send a request for token login for a different user, the server complains that there is no CSRF token. However if I log out, suddenly there's no problem.
I am not sure how severe it will be after frontend is implemented and the logins come from different devices, but so far it doesn't look good.
Any idea how to stop requiring CSRF token if the correct Authorization: Token <token> header is passed? Or different solution to my problem?

A: Default SessionAuthentication backend from DRF is built in a way that if you provide valid session in request, it will turn on CSRF validation. There are 2 possible solutions for that: either don't use two authentications method together (don't use token when you are sending valid session cookie in request) or prioritize token authentication by putting TokenAuthentication backend above SessionAuthentication in DEFAULT_AUTHENTICATION_CLASSES setting.


text:
Q: AngularJS: Register Controller from separate .js file I am new to AngularJS and using plnkr.co to learn how to use angular. I have having some difficulty registering a Controller this is stored in a separate .js from where the module is initialized. Can anybody tell me why the below does not work?
index.html file

<!DOCTYPE html>

  <meta charset="utf-8" />
  <title>AngularJS Plunker</title>

  <link rel="stylesheet" href="style.css" />

Hello {{name}}!

app.js File

angular.module('plunker', []);

mainCtrl.js File

angular.module('plunker')
  .controller('MainCtrl', ['$scope', function($scope) {
    $scope.name = 'GitHub';
  }]);

For me, this produces an Argument 'MainCtrl' is not a function, got undefined.

A: Replace

with

Because of the typo (scr instead of src), the source file holding MainCtrl is not loaded, therefore MainCtrl is undefined.


text:
Q: Python script does not restart properly with systemd I am learning how to restart a Python script in case of error (following this tutorial, however with some small tweaks regarding filenames and alike). First things first, the needed files:

*

*/home/myuser/Desktop/test/test.py:

from datetime import datetime
from time import sleep

path = "/home/dec13666/Desktop/test/log.txt"

while True:
    with open(path, "a") as f:
        now = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
        f.write(now+"\n")
        f.close()
    sleep(1)
    raise Exception("Error Simulation!!!")

*

*davidcustom.service:

[Unit]
Description=Python Script Made By Me
After=multi-user.target

[Service]
RestartSec=10
Restart=always
ExecStart=python3 /home/myuser/Desktop/test/test.py

[Install]
WantedBy=multi-user.target

Finally, the commands run:
sudo nano /etc/systemd/system/davidcustom.service
sudo systemctl daemon-reload
sudo systemctl enable davidcustom.service
sudo systemctl start davidcustom.service
sudo systemctl status davidcustom.service

The message I am getting:
● davidcustom.service - Python Script Made By Me
     Loaded: loaded (/etc/systemd/system/davidcustom.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sun 2022-09-04 14:12:12 EDT; 8s ago
    Process: 3341 ExecStart=python3 /home/myuser/Desktop/test/test.py (code=exited, status=1/FAILURE)
   Main PID: 3341 (code=exited, status=1/FAILURE)
        CPU: 100ms

Notes:

*

*When I run test.py manually, it works OK, but then that python script is run from a service (as seen here), it generates that error.

*I have tried to set User=myusername and Type=simple, in davidcustom.service ([Service]), with no difference in the results.

What am I doing wrong?

A: ExecStart requires an absolute path to the executable, it doesn't search $PATH. So use
ExecStart=/usr/bin/python3 /home/myuser/Desktop/test/test.py

(assuming that's where python3 is installed -- you can use type python3 to get the actual location).

A: I inadvertently added some wrong indentation in the original code (corrected by now in the original post). That solved my issue; when running sudo systemctl status davidcustom.service, now the service is active:
● davidcustom.service - Python Script Made By Dave
     Loaded: loaded (/etc/systemd/system/davidcustom.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-09-04 16:16:02 EDT; 23ms ago
   Main PID: 4287 (python3)
      Tasks: 1 (limit: 14215)
     Memory: 3.0M
        CPU: 16ms
     CGroup: /system.slice/davidcustom.service
             └─4287 python3 /home/dec13666/Desktop/test/test.py

Other suggestions which would worth keeping in mind, but were NOT necessary for my case (thanks @Barmar & @tdelaney):

*

*Use an absolute path at ExecStart (easily obtainable by running which python command)

*If you only want to use your User and/or Group, then explicitely write those parameters.

*The 2 previous suggestions should be added in [Service], in your service script:

[Service]
RestartSec=10
Restart=always
ExecStart=/usr/bin/python3 /home/myuser/Desktop/test/test.py
User=youruser
Group=yourgroup

*

*Read the comments in the original post, for other options.

Thanks.


text:
Q: How can I find what is causing my memory allocation error when Valgrind gives me "the impossible happened" I am somewhat of a newbie programmer, doing a brief senior project for the last few weeks of high school. My program is essentially a bot designed to solve wordle. The last few days, I have been struggling with an elusive memory allocation error. I have only been coding in c++ for a couple of weeks, so I am not very used to errors of this nature. I have tried a myriad of printf statements, commenting out code, and gdb and valgrind, but am not sure how to interpret the error message the latter gave me. Here is my code (sorry if this is too long for a post, I am new to stackoverflow).
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

struct Guessdata{
        int average;
        char guess[5];
    };

struct {
        bool operator()(const Guessdata& a, const Guessdata& b) const { return a.average < b.average; }
    } customLess;

bool guessInList(string guess, string arr[], int num_words)
{
    int i;
    for(i = 0; i < num_words; i++)
    {
        if(arr[i] == guess)
        {
            cout << "The word '" << arr[i] << "' exists!" << endl;
            return true;
        }
    }
    return false;
}
void compareWords(char guess_arr[], char answer_arr[], int score[])
{
    for(int i = 0; i < 5; i++)
    {
        bool isScored = false;
        for(int j = 0; j <5; j++)
            if(guess_arr[i] == answer_arr[j])
            {
                if(i == j)
                {
                    score[i] = 2;
                    isScored = true;
                }
                else
                {
                    if(!isScored)
                    {
                        score[i] = 1;
                        isScored = true;
                    }
                }
            }
        if(isScored == false)
        {
            score[i] = 0;
        }
    }
}
void cleanChArray(char guess_array[], int score[], char remainingChArray[], char newChArray[], int remaining_count, int& added_counter)
{
    added_counter = 0;
    for(int i = 0; i < remaining_count; i+=5)
    {
        bool keep_word = true;
        for(int j = 0; j < 5; j++)
        {
            char guess_ch = guess_array[j];
            int score_j = score[j];
            if(score_j == 0)
            {
                for(int k = 0; k < 5; k++)
                {
                    if(guess_ch == remainingChArray[i+k])
                    {
                        for(int e = 0; e < 5; e++)
                        {
                            if(guess_array[e] == remainingChArray[i+k] && e != k && score[e] != 0)
                            {
                                keep_word = true;
                                break;
                            }
                            else
                            {
                                keep_word = false;
                                break;
                            }
                        }
                    }
                }
            }
            else if(score_j == 2)
            {
                if(!(guess_ch == remainingChArray[i+j]))
                {
                    keep_word = false;
                    break;
                }
            }
            else if(score_j == 1)
            {
                int found = 0;
                for(int l = 0; l < 5; l++)
                {
                    if(guess_ch == remainingChArray[i+l] && j == l)
                    {
                        keep_word = false;
                        break;
                    }
                    else if(guess_ch == remainingChArray[i+l] && j!=l)
                    {
                        found += 1;
                    }
                }
                if(found != 1)
                {
                    keep_word = false;
                }
            }
            if(!keep_word)
            {
                break;
            }
        }
        if(keep_word)
        {
            for(int k = i; k < i+5; k++)
            {

                newChArray[added_counter] = remainingChArray[k];
                added_counter++;
            }
        }
    }
}
int numberEliminated(char guess_arr[], char keyword_arr[], int score[], char remainingChArray[], char newChArray[], int remainingCount, int& added_counter)
{
    compareWords(guess_arr, keyword_arr, score);
    cleanChArray(guess_arr, score, remainingChArray, newChArray, remainingCount, added_counter);
    return(2309 - (added_counter)/5);
}
int averageEliminated(char guess_arr[], char remainingChArray[], int score[], char newChArray[], int remainingCount, int& added_counter)
{
    int num_elim = 0;
    int current_length = added_counter;
    for(int i = 0; i < remainingCount; i += 5)
    {
        char * keyword_array = new char[5];
        for(int j = 0; j < 5; j++)
        {
            keyword_array[j] = remainingChArray[i+j];
        }
        num_elim += numberEliminated(guess_arr, keyword_array, score, remainingChArray, newChArray, remainingCount, added_counter);
    }
    return num_elim/2309;
}

void makeGuess(char remainingChArray[], int score[], char newChArray[], int& remainingCount, int& added_counter, char final_guess[], int& num_attempts, Guessdata guess_dict[])
{
    printf("%i, %i, %i\n", remainingCount, added_counter, num_attempts);
    printf("coool\n");
    for(int i = 0; i < remainingCount/5; i ++)
    {
        printf("\n");
        for(int j = 0; j < 5; j++)
        {
            guess_dict[i].guess[j] = remainingChArray[(5*i)+j];
            printf("%c", guess_dict[i].guess[j]);
        }
        guess_dict[i].average = averageEliminated(guess_dict[i].guess, remainingChArray, score, newChArray, remainingCount, added_counter);
        printf("%i  ", guess_dict[i].average);
    }
    /*if(num_attempts > 0)
    {
        for(int i = 0; i < remainingCount; i += 5)
        {
            printf("%i: ", guess_dict[i/5].average);
            for(int j = 0; j < 5; j++)
            {
                printf("%c", guess_dict[i/5].guess[j]);
            }
            printf("\n");
        }
    }*/
    printf("yee\n");
    if(remainingCount>5){

        std::sort(&guess_dict[0], &guess_dict[remainingCount/5], customLess);
    }

    for(int i = 0; i < 5; i++)
    {
        final_guess[i] = guess_dict[(remainingCount/5)-1].guess[i];
        printf("%c", final_guess[i]);
    }
    printf("\n");
    num_attempts += 1;
}

int main()
{
    const int num_words = 2309;
    string * ANSWERLIST = new string[num_words];
    char * chArray = new char[11545];
    char * officialGuess = new char[5];
    char * officialAnswer = new char[5];
    int count = 0;
    int attempts = 0;
    int * score_template = new int[5];
    int numberOfWords;
    int addCount = 0;
    ifstream inputFile;
    inputFile.open("ANSWERS.txt");
    if(!inputFile)
    {
        cout << "Error finding input file" << endl;
        exit(-1);
    }
    while(!inputFile.eof())
    {
        inputFile >> ANSWERLIST[count];
        count++;
    }
    numberOfWords = count;
    int ch_count = 11545;
    int smaller_count = 5750;
    char * chAnswerList = new char[ch_count];
    char * smallerList = new char[smaller_count];
    for(int i = 0; i < 2309; i++)
    {
        for(int j = 0; j < 5; j++)
        {
            chAnswerList[(5*i)+j] = ANSWERLIST[i][j];
        }
    }

    for(int i = 0; i < 1150; i++)
    {
        for(int j = 0; j < 5; j++)
        {
            smallerList[(i*5)+j] = ANSWERLIST[i][j];
        }
    }

    officialAnswer[0] = 'b';
    officialAnswer[1] = 'r';
    officialAnswer[2] = 'o';
    officialAnswer[3] = 'o';
    officialAnswer[4] = 'k';

    //REAL GAME LOGIC
    //FIRST GUESS
    printf("first guess: ");
    Guessdata * guess_dict = new Guessdata[ch_count/5];
    makeGuess(smallerList, score_template, chArray, smaller_count, addCount, officialGuess, attempts, guess_dict);
    compareWords(officialGuess, officialAnswer, score_template);
    bool match = true;
    for(int i = 0; i < 5; i++)
    {

        if(score_template[i] != 2)
        {
            match = false;
            break;
        }
    }
    if(match)
    {
        printf("%i\n", attempts);
        return attempts;
    }
    cleanChArray(officialGuess, score_template, smallerList, chArray, ch_count, addCount);
    if(addCount == 0)
    {
        printf("fail");
        return 0;
    }
    char * secondList = new char[addCount/5];
    for(int i = 0; i < addCount; i++)
    {
        secondList[i] = chArray[i];
        printf("%c", secondList[i]);
    }
    printf("\n");
    ch_count = addCount;
    delete[] guess_dict;
    delete[] chAnswerList;
    printf("second guess: ");
    Guessdata * guess_dict2 = new Guessdata[ch_count/5];
    //SECOND GUESS
    makeGuess(secondList, score_template, chArray, ch_count, addCount, officialGuess, attempts, guess_dict2);
    compareWords(officialGuess, officialAnswer, score_template);
    match = true;
    for(int i = 0; i < 5; i++)
    {
        printf("%i", score_template[i]);

        if(score_template[i] != 2)
        {
            match = false;
            break;
        }
    }
    if(match)
    {
        printf("%i\n", attempts);
        return attempts;
    }

    cleanChArray(officialGuess, score_template, secondList, chArray, ch_count, addCount);
    if(addCount == 0)
    {
        printf("fail");
        return 0;
    }
    char * thirdList = new char[addCount/5];
    for(int i = 0; i < addCount; i++)
    {
        thirdList[i] = chArray[i];
    }
    ch_count = addCount;

    delete[] secondList;
    delete[] guess_dict2;
    Guessdata * guess_dict3 = new Guessdata[ch_count/5];
    printf("third guess: ");
    //THIRD GUESS
    makeGuess(thirdList, score_template, chArray, ch_count, addCount, officialGuess, attempts, guess_dict3);
    compareWords(officialGuess, officialAnswer, score_template);
    match = true;
    for(int i = 0; i < 5; i++)
    {

        if(score_template[i] != 2)
        {
            match = false;
            break;
        }
    }
    if(match)
    {
        printf("%i\n", attempts);
        return attempts;
    }

    cleanChArray(officialGuess, score_template, thirdList, chArray, ch_count, addCount);
    if(addCount == 0)
    {
        printf("fail");
        return 0;
    }
    char * fourthList = new char[addCount/5];
    for(int i = 0; i < addCount; i++)
    {
        fourthList[i] = chArray[i];
    }
    ch_count = addCount;

    delete[] thirdList;
    delete[] guess_dict3;
    Guessdata * guess_dict4 = new Guessdata[ch_count/5];

    //FOURTH GUESS
    makeGuess(fourthList, score_template, chArray, ch_count, addCount, officialGuess, attempts, guess_dict4);
    compareWords(officialGuess, officialAnswer, score_template);
    match = true;
    for(int i = 0; i < 5; i++)
    {
        if(score_template[i] != 2)
        {
            match = false;
            break;
        }
    }
    if(match)
    {
        printf("%i\n", attempts);
        return attempts;
    }

    cleanChArray(officialGuess, score_template, fourthList, chArray, ch_count, addCount);
    if(addCount == 0)
    {
        printf("fail");
        return 0;
    }
    char * fifthList = new char[addCount/5];
    for(int i = 0; i < addCount; i++)
    {
        fifthList[i] = chArray[i];
    }
    ch_count = addCount;

    delete[] fourthList;
    delete[] guess_dict4;
    Guessdata * guess_dict5 = new Guessdata[ch_count/5];

    //FIFTH GUESS
    makeGuess(fifthList, score_template, chArray, ch_count, addCount, officialGuess, attempts, guess_dict5);
    compareWords(officialGuess, officialAnswer, score_template);
    match = true;
    for(int i = 0; i < 5; i++)
    {

        if(score_template[i] != 2)
        {
            match = false;
            break;
        }
    }
    if(match)
    {
        printf("%i\n", attempts);
        return attempts;
    }

    cleanChArray(officialGuess, score_template, fifthList, chArray, ch_count, addCount);
    if(addCount == 0)
    {
        printf("fail");
        return 0;
    }
    char * sixthList = new char[addCount/5];
    for(int i = 0; i < addCount; i++)
    {
        sixthList[i] = chArray[i];
    }
    ch_count = addCount;

    delete[] fifthList;
    delete[] guess_dict5;
    Guessdata * guess_dict6 = new Guessdata[ch_count/5];

    //SIXTH GUESS
    makeGuess(fifthList, score_template, chArray, ch_count, addCount, officialGuess, attempts, guess_dict6);
    compareWords(officialGuess, officialAnswer, score_template);
    match = true;
    for(int i = 0; i < 5; i++)
    {
        if(score_template[i] != 2)
        {
            match = false;
            break;
        }
    }
    if(match)
    {
        printf("%i\n", attempts);
        return attempts;
    }
    else
    {
        printf("FAIL\n");
        return 0;
    }
}

I am fairly certain somewhere along the way I am writing beyond the memory allocated to a certain array or something, but cannot for the life of me figure out where. I have run Valgrind on this script and gotten the following output:
==386== Invalid read of size 1
==386==    at 0x109CEA: cleanChArray(char*, int*, char*, char*, int, int&) (methods.cpp:75)
==386==    by 0x10A3FC: main (methods.cpp:277)
==386==  Address 0x4dc5206 is 0 bytes after a block of size 5,750 alloc'd
==386==    at 0x483C583: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==386==    by 0x10A261: main (methods.cpp:229)
==386==
==386== Invalid read of size 1
==386==    at 0x109D0F: cleanChArray(char*, int*, char*, char*, int, int&) (methods.cpp:95)
==386==    by 0x10A3FC: main (methods.cpp:277)
==386==  Address 0x4dc5208 is 2 bytes after a block of size 5,750 alloc'd
==386==    at 0x483C583: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==386==    by 0x10A261: main (methods.cpp:229)
==386==
==386== Conditional jump or move depends on uninitialised value(s)
==386==    at 0x109CF2: cleanChArray(char*, int*, char*, char*, int, int&) (methods.cpp:75)
==386==    by 0x10A3FC: main (methods.cpp:277)
==386==  Uninitialised value was created by a heap allocation
==386==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==386==    by 0x4AD6E83: _IO_file_doallocate (filedoalloc.c:101)
==386==    by 0x4AE704F: _IO_doallocbuf (genops.c:347)
==386==    by 0x4AE60AF: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:745)
==386==    by 0x4AE4834: _IO_new_file_xsputn (fileops.c:1244)
==386==    by 0x4AE4834: _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1197)
==386==    by 0x4ACBAF1: __vfprintf_internal (vfprintf-internal.c:1373)
==386==    by 0x4B830EA: __printf_chk (printf_chk.c:33)
==386==    by 0x10A30C: printf (stdio2.h:107)
==386==    by 0x10A30C: main (methods.cpp:258)
==386==
==386== Conditional jump or move depends on uninitialised value(s)
==386==    at 0x109D12: cleanChArray(char*, int*, char*, char*, int, int&) (methods.cpp:95)
==386==    by 0x10A3FC: main (methods.cpp:277)
==386==  Uninitialised value was created by a heap allocation
==386==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==386==    by 0x4AD6E83: _IO_file_doallocate (filedoalloc.c:101)
==386==    by 0x4AE704F: _IO_doallocbuf (genops.c:347)
==386==    by 0x4AE60AF: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:745)
==386==    by 0x4AE4834: _IO_new_file_xsputn (fileops.c:1244)
==386==    by 0x4AE4834: _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1197)
==386==    by 0x4ACBAF1: __vfprintf_internal (vfprintf-internal.c:1373)
==386==    by 0x4B830EA: __printf_chk (printf_chk.c:33)
==386==    by 0x10A30C: printf (stdio2.h:107)
==386==    by 0x10A30C: main (methods.cpp:258)
==386==
==386== Invalid write of size 1
==386==    at 0x10A4A9: main (methods.cpp:286)
==386==  Address 0xb2b2a9c is 0 bytes after a block of size 44 alloc'd
==386==    at 0x483C583: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==386==    by 0x10A418: main (methods.cpp:283)
==386==
==386== Conditional jump or move depends on uninitialised value(s)
==386==    at 0x4AE5F5D: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:783)
==386==    by 0x4ADB481: putchar (putchar.c:28)
==386==    by 0x10A4B4: printf (stdio2.h:107)
==386==    by 0x10A4B4: main (methods.cpp:287)
==386==  Uninitialised value was created by a heap allocation
==386==    at 0x483C583: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==386==    by 0x10A343: main (methods.cpp:259)
==386==
==386== Syscall param write(buf) points to uninitialised byte(s)
==386==    at 0x4B631E7: write (write.c:26)
==386==    by 0x4AE400C: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1181)
==386==    by 0x4AE5AD0: new_do_write (fileops.c:449)
==386==    by 0x4AE5AD0: _IO_new_do_write (fileops.c:426)
==386==    by 0x4AE5AD0: _IO_do_write@@GLIBC_2.2.5 (fileops.c:423)
==386==    by 0x4AE6012: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:784)
==386==    by 0x4ADB481: putchar (putchar.c:28)
==386==    by 0x10A4C0: printf (stdio2.h:107)
==386==    by 0x10A4C0: main (methods.cpp:289)
==386==  Address 0x4dc530d is 189 bytes inside a block of size 1,024 alloc'd
==386==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==386==    by 0x4AD6E83: _IO_file_doallocate (filedoalloc.c:101)
==386==    by 0x4AE704F: _IO_doallocbuf (genops.c:347)
==386==    by 0x4AE60AF: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:745)
==386==    by 0x4AE4834: _IO_new_file_xsputn (fileops.c:1244)
==386==    by 0x4AE4834: _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1197)
==386==    by 0x4ACBAF1: __vfprintf_internal (vfprintf-internal.c:1373)
==386==    by 0x4B830EA: __printf_chk (printf_chk.c:33)
==386==    by 0x10A30C: printf (stdio2.h:107)
==386==    by 0x10A30C: main (methods.cpp:258)
==386==  Uninitialised value was created by a heap allocation
==386==    at 0x483C583: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==386==    by 0x10A343: main (methods.cpp:259)
==386==
boobyboostboothbootyboozybroodbrookbroombrothchockchoirchordcrockcrookcrosscroupcrowddroitdroopdrossfjordfrockfrostfrothghostgoodygoofygroomgrossgroupgroutivorykioskkioskhobbhowddrooproomrgourorcommhoisgoosfoot
--386-- VALGRIND INTERNAL ERROR: Valgrind received a signal 7 (SIGBUS) - exiting
--386-- si_code=128;  Faulting address: 0x0;  sp: 0x1008ca9e40

valgrind: the 'impossible' happened:
   Killed by fatal signal

host stacktrace:
==386==    at 0x5805160F: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/memcheck-amd64-linux)
==386==    by 0x58005EB7: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/memcheck-amd64-linux)
==386==    by 0x580A7204: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/memcheck-amd64-linux)
==386==    by 0x580F5FD4: ??? (in /usr/lib/x86_64-linux-gnu/valgrind/memcheck-amd64-linux)

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable (lwpid 386)
==386==    at 0x483C583: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==386==    by 0x10A532: main (methods.cpp:294)
client stack range: [0x1FFEFFC000 0x1FFF000FFF] client SP: 0x1FFEFFDE70
valgrind stack range: [0x1008BAA000 0x1008CA9FFF] top usage: 9480 of 1048576

Note: see also the FAQ in the source distribution.
It contains workarounds to several common problems.
In particular, if Valgrind aborted or crashed after
identifying problems in your program, there's a good chance
that fixing those problems will prevent Valgrind aborting or
crashing, especially if it happened in m_mallocfree.c.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what OS and version you are using.  Thanks.

Note: There are various little printf statements and the like that I have tried to use as diagnostic tools. I apologize for the likely illegible appearance of my code. Any and all feedback is greatly appreciated.


text:
Q: Designing REST API with Actions I have this rest API that I am building with this resource
POST /backend/entities/Donut

Creates a new entity given a JSON payload.
My backend features an entity linking mechanism thus I am planning to create this resource as a shorthand to create a new Entity and also create another Entity linked to it like this:
POST /backend/entities/Donut?entityType=Box&linkName=donut

What this does is to create a Donut entity (given a JSON payload, not shown here) and then create another entity called Box and then link the Donut to the new Box with the link name donut, to me this is kind of an action, and HTTP query parameters to me, in the same way, are just for query (or query filter) not for actions.
The motivation for this approach is to keep the JSON payload in-tact using the same Entity fields without adding additional Entity-inside-Entity JSON which is confusing. Another reason is to have a single request that would "Create a new Entity then create a new Entity linked to it" in one HTTP request.
Is this approach still RESTful? Or adding query parameters like that just makes it look like a query filter?

A: There is no rule in REST that restricts how you use query parameters in your identifiers.
/a/b/c
/a/b?c

Both of these spellings are fine.
RFC 3986 specifies URI structure, but it is very forgiving of URI semantics

The path component contains data, usually organized in hierarchical form, that, along with data in the non-hierarchical query component...
The query component contains non-hierarchical data that, along with data in the path component...

From the perspective of a client, it doesn't matter whether the server encodes information into the path, into the query, or both.  The whole thing is one opaque parameter.
(Twenty years ago, this was less true -- there were a number of implementations that tried to use the query part as a caching hint, so you might choose spellings that would continue to work with broken clients.  I don't believe that's an issue in 2019.)
The machines don't care; but human beings might.  Having an API that is consistent about where it encodes information will be easier to understand, in much the same way that having consistent variable naming conventions makes code easier to understand.  But which convention you use in an API isn't particularly important.


text:
Q: How to find incomplete downloaded files of updated OS? My internet connection was lost while I was updating my OS from 16.04 to 17.04 and the process stopped.There were 10-15 files remaining to be downloaded.
Now after realising that 17.04 is not a LTS version I don't wanna update my OS. But what about the downloaded files? Will they occupy any space in hard drive? Will they affect my current OS 16.04? Should I delete them? If yes than how can I find them and delete them?

A:
Now after realising that 17.04 is not a LTS version I don't wanna update my OS...

LTS or not, you should ALWAYS update your OS! If you don't like non-LTS versions, don't install them. Updates are delivered to fix errors, so you should install them.
Just do
sudo apt update
sudo apt upgrade

and if mentioned in the output of above:
sudo apt autoremove

Downloaded packages are kept in /var/cache/apt and partial downloaded packages in partial in that directory. You can delete the files in /var/cache/apt, but it will be downloaded again next time you update, and the content of partial will normally be deleted when packages are fully downloaded. To delete the contents of /var/cache/apt/partial, you can run
sudo apt clean

A: apt-get stores all downloaded packages in /var/cache/apt/archives. the partially downloaded packages are in /var/cache/apt/archives/partial. to remove these packages and free up the space they are holding, you can sudo rm -r /var/cache/apt/archive
or simply apt-get clean will remove all downloaded PPA archives from the aforementioned directory - thus freeing up the space


text:
Q: Code to hide unhide sheets crashing Excel workbook I have code meant to list hidden worksheets, unhide them, remove a password, list workbooks that the file is linked to, refresh a power query data connection, re-apply the password, and hide previously hidden sheets as well as any sheets that are colored green on workbook open.
It causes Excel to crash. I tried modifying the code numerous times, removing the code from the workbook, saving the workbook as .XLS then re-opening, adding the code back in and re-saving as .XLSM.
Any suggestions why this may be happening or how I can improve the code to prevent Excel from crashing?
Private Sub Workbook_Open()
'Place in ThisWorkbook to run code on Workbook_Open
'Ensure that Consolidated - Query does NOT have Background Refresh Enabled in Query Properties
    Dim x As Long
    Dim shtCnt As Integer
    shtCnt = ThisWorkbook.Sheets.Count

    Application.StatusBar = "Setting up for volume refresh..."
    Application.Calculation = xlCalculationManual
    Sheets("Control").Visible = True
    Sheets("Control").Activate
    ActiveSheet.Unprotect Password:="passwordhere"
    Sheets("Control").Select

    'clear out old list
    Sheets("Control").Range("T7").Value = "Hidden Worksheets:"
    Range("T7").Select
    Selection.Font.Bold = True
    Selection.Font.Underline = True
    Range("T8:T5000").Select
    Selection.Clear

    'list hidden sheets
    On Error Resume Next
    x = 8
    For i = 1 To shtCnt
        If Sheets(i).Visible = xlSheetHidden Then
            Cells(x, 20) = Sheets(i).Name
            x = x + 1
        End If
    Next i

    'unhide hidden sheets
    stp = Worksheets("Control").Range("T8:T5000").Cells.SpecialCells(xlCellTypeConstants).Count
    y = 8
    For j = 1 To stp
        Sheets(Cells(y, 20).Value).Visible = True
        y = y + 1
    Next j

        For i = 1 To Sheets.Count
          With Sheets(i)
            .Unprotect Password:="password"
            .Outline.ShowLevels RowLevels:=1
          End With
        Next i

    'list linked workbooks path
    Application.StatusBar = "Refreshing volume..."
    Dim wb As Workbook
    Set wb = Application.ThisWorkbook
    Sheets("Control").Range("T4").Activate
    If Not IsEmpty(wb.LinkSources(xlExcelLinks)) Then
      xIndex = 4
      For Each link In wb.LinkSources(xlExcelLinks)
        If Not link Like "*Corporate Guidelines Master.xlsm" Then
            Application.ActiveSheet.Cells(xIndex, 20).Value = link
            xIndex = xIndex + 1
        End If
      Next link
    End If

    'refresh volume query
    Application.Calculation = xlCalculationAutomatic
    ThisWorkbook.Connections("Query - Consolidated").Refresh
    Application.Wait (Now + TimeValue("0:00:02"))
    DoEvents
    Application.StatusBar = "Please wait..."

    For i = 1 To Sheets.Count
        With Sheets(i)
        .Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFormattingColumns:=True, AllowFormattingRows:=True _
        , Password:="passwordhere"
        .Select
        Cells(ThisWindow.SplitRow + 1, ThisWindow.SplitColumn + 1).Select
        End With
    Next i

    'hide originally hidden sheets
    Dim tc As Object
    For Each tc In ThisWorkbook.Sheets
        If tc.Tab.Color = 4697456 Then
            tc.Visible = xlSheetHidden
        End If
    Next tc

    stpend = Worksheets("Control").Range("T8:T5000").Cells.SpecialCells(xlCellTypeConstants).Count
    Z = 8
    Sheets("Control").Range("T8").Select
    For k = 1 To stpend
        Sheets(Cells(Z, 20).Value).Visible = False
        Z = Z + 1
    Next k

    'close out
    Sheets("Control").Visible = False
    Sheets("Plant Summary Graphs").Select
    Range("A1").Activate
    Application.StatusBar = False
End
End Sub

A: Thank you, everyone, for the advice!
An issue was in the case that no worksheets were hidden when the workbook was last closed and then re-opened. So, I modified the hide/unhide sheets code:
'unhide hidden sheets
    On Error Resume Next
    stp = Worksheets("Control").Range("T8:T5000").Cells.SpecialCells(xlCellTypeConstants).Count
    On Error GoTo 0

    If stp <> "" Then
        y = 8
        For j = 1 To stp
            Sheets(Cells(y, 20).Value).Visible = True
            y = y + 1
        Next j
    End If

Hopefully this won't bug out on me going forward.
Thank you, all!
EDIT
I had to modify the following when hiding the originally hidden sheets:
On Error Resume Next
stpend = Application.WorksheetFunction.CountA(Worksheets("Control").Range("T8:T5000"))
On Error GoTo 0

If stpend <> "" Then
    Z = 8
    Sheets("Control").Select
    Range("T8").Select
    For k = 1 To stpend
        Sheets(Cells(Z, 20).Value).Visible = False
        Z = Z + 1
    Next k
End If


text:
Q: Push VS Upgrade packages I was setting up postInstall scripts and noticed that there is a condition that checks for if it is an upgrade or push. My understanding was that the method of installation should be irrelevant but obviously I'm missing something here. Can someone please advise what the potential differences between the two would be?
public void onInstall(InstallContext context) {
            if(context.previousVersion() == null) {
    [...]
            }else{
                if(context.isUpgrade()) {
                }
                if(context.isPush()) {

                }

A: In case of push upgrades there is no way to choose for which users package would be installed, it would trigger 'Admin Only' mode and that's it.
But when upgrading package by directly typing url on subscriber org, you are prompted with a dialog to chose among 'Admin Only', 'All Users' and 'Specific Profiles'.
So in push upgrade mode ordinary users wouldn't get permissions to access some maybe required objects, and you could bypass this by assigning permission sets to them as a part of post installation script in that context.isPush() branch.


text:
Q: How to call the controller variable in view file using joomla? I am new in joomla, My code is like this
//on controller
function listing()
    {
            JRequest::setVar( 'view', 'hello' );
            JRequest::setVar('hidemainmenu', 0);
            parent::display();
    }
//on view.html.php

i want to fetch this 'hidemainmenu'
How can i fetch can anyone help??

A: If the code above is that of your view.html.php file then you can pass the variable through to your template file by using a line like so:
$this->assignRef( 'hidemainmenu', $hidemainmenu);

Then in your tmpl/default.php file for example you can access this variable like so:
$this->hidemainmenu

A: If the code is in the Controller :
get the Variable in the view.html.php
as
$hidemainmenu = JRequest::getVar('hidemainmenu');

Try this in the view.html.php or default.php


text:
Q: How To Delete One More Primary Keys in SQL? i trying delete all primary keys one table on SQL.
If i had one primary key, i can deleted this code line:
ALTER TABLE dbo.TblName DROP CONSTRAINT PK_TblName;

But, if i have one more primary keys, i take this error:

Msg 3728, Level 16, State 1, Line 18
  'PK_TblBooks' is not a constraint.
  Msg 3727, Level 16, State 0, Line 18
  Could not drop constraint. See previous errors.

And i try this on C# but they arent deleted:
String sql= "SELECT COL_NAME(ic.object_id,ic.column_id) AS ColumnName FROM sys.indexes AS i INNER JOIN sys.index_columns AS ic ON i.object_id = ic.object_id WHERE i.is_primary_key = 1 AND ic.object_id = i.object_id";
SqlCommand cmd= new SqlCommand(sql, con);
SqlDataAdapter adp= new SqlDataAdapter(cmd);
DataTable dtsk = new DataTable();
adp.Fill(dtsk);

for (int i = 0; i < dtsk.Rows.Count; i++)
{
String remove= "ALTER TABLE " + Table + " DROP CONSTRAINT PK_" + Table + "";
SqlCommand cmd1= new SqlCommand(remove, con);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
}

How can watchin way for solve this problem?

A: Try using dynamic sql to delete some table's pk.
declare @sql nvarchar(max) = '';
with CTE as (
  select T1.*,T2.name tableName from sys.key_constraints T1
  left join sys.objects T2 on T1.parent_object_id = T2.object_id
  where T2.name = 'T' --your table name
)
select @sql = concat(@sql,'ALTER table ',tableName,' DROP CONSTRAINT ',name,';')
from CTE;

exec(@sql); --delete T table all pk

select * from sys.key_constraints; --result:null

TEST DDL:
CREATE TABLE T
    ([col1] varchar(2), [col2] varchar(2)
       ,constraint PK_TblName unique (col1)
       ,constraint PK_TblName2 unique (col1)
    )
;

online demo


text:
Q: Find the number that gives the max number of steps for the Euclidean Algorithm I assume that $a$, $b$ are integers $a > b > 0$.
$N(a,b)$ denotes the number of steps taken in the Euclidean Algorithm to find $\gcd(a,b)$, for example, $N(7,2) = 2$. $M(a)$ then denotes the maximal $N(a,b)$, for example, $M(7) = 3$.
How can I then find the $b$ for any given a such that $N(a,b)$ is maximal?


text:
Q: How to scroll up the combobox list in VBScript I am automating an application which is having a dropdown/combobox list. The item  which i want to select is not visible in the list, i need to scroll it up for making it visible.
Please suggest me how can i scroll the list of combobox in VBScript?


text:
Q: Trying to render dynamic dropdowns using Bootstrap and Marionette, sibling tag

  Dropdown trigger

      {{model.name}}

This is the basic code that bootstrap needs for a dropdown
Dropdown trigger

That is the code I need to be rendered as a item for a menu (File, Edit, etc...) the problem are the sibling tags that hold the menu list items
I would use something like this:
{{name}}

Then I want to render menu list items into the 'ul.dropdown-menu' element:

   {{name}}

Here is my Marionette view:
var menuItem = Marionette.ItemView.extend({
    tagName: 'a',
    attributes: {
        'class': 'dropdown-toggle',
        'data-toggle': 'dropdown',
        'href': '#'
    },

    initialize: function() {
        this.render();
    },

    render: function() {
        this.$el.html('test').after('bam?');

        return this;
    }
});

Anytime I call the render function and try to manipulate the data outside of the this.el that is set up on creation it is never appended after the tag.  Only inside (so I see 'test' inside the a tags but not the 'bam?'.  Anyone have any tips for dealing with sibling elements?
I also am not as experienced with Backbone / Marionette so there may be better way to attack this, I am just not sure.

A: I would use a Marionette.CompositeView to do this and not override render at all.
DropDownItemView = Backbone.Marionette.ItemView.extend({
  tagName: "li",
  template: "#dropdown-item-template"
});

DropDownMenuView = Backbone.Marionette.CompositeView.extend({
  itemView: DropDownItemView,
  // specify a jQuery selector to put the itemView instances in to
  itemViewContainer: "ul",
  template: "#drop-down-menu-template"
});

A general rule of thumb that I have found using Backbone.Marionette is that if you are manipulating the $el then there is usually a better way to do it.


text:
Q: Is dividing the task into functions is beneficial or harmful ? I am working with embedded systems(Mostly ARM Cortex M3-M4) using C language.And was wondering what are the advantages/ disadvantages of dividing the task into many functions such as;
   void Handle_Something(void)
{
// do Task-1
// do Task-2
// do Task-3
//etc.
}

to
void Hanlde_Something(void)
{
// Handle_Task1();
// Handle_Tasl2();
//etc.
}

How are these two approaches can be examined with respect to stack usage and overall processing speed, and which is safer/better for what reason ? (You can assume this is outside of ISR)
From what I know, Memory in the stack is allocated/deallocated for local variables in each call/return cycle, thus dividing the task seems reasonable in terms of memory usage but when doing this, I sometimes get Hardfaults from different sources(mostly Bus or Undefined Instruction errors.) that I couldn't figured out why.
Also, working speed is very crucial for many applications in my field, so ı do need to know which methode provides faster responses.
I would appreciate an enlightment. Thanks everybody in advance

A: This is what's known as "pre-mature optimization".
In the old days when compilers where horrible, they couldn't inline functions by themselves. So in the old days a keyword inline was added to C - similar non-standard versions also existed before the year 1999. This was used to tell a bad compiler how it should generate code better.
Nowadays this is mostly history. Compilers are better than programmers at determining what and when to inline. They may however struggle when a called function is located in a different "translation unit" (basically, in a different .c file). But in your case I take it this is not the case, but Handle_Task1() etc can be regarded as functions in the same file.
With the above in mind:

How are these two approaches can be examined with respect to stack usage and overall processing speed

They are to be regarded as identical. They use the same stack space and take the same time to execute.
Unless you have a bad, older compiler - in which case function calls always take extra space and execution time. Since you are working with modern MCU:s, this should not be the case, or you desperately need to get a better compiler.
As a rule of thumb, it is always better practice to split up larger functions in several smaller, for the sake of readability and maintenance. Even in hard real-time systems, there exist very few cases where function call overhead is an actual bottleneck even when bad compilers are used.

A: Memory on the stack isn't allocated/reallocated from some complex memory pool. The stack pointer is simply increased/decreased. An operation that is basically free in all but the tightest/smallest loops imaginable (and those will probably be optimized by the compiler).
Don't group together functions because they could reuse variables e.g. don't create a bunch of int tempInt; long tempLong; variables you use throughout your entire program. A variable should serve only a single purpose and its scope should be kept as tight as possible. Also see: is it good or bad to reuse the variables?
Expanding on that, keeping the scope of all variables as local as possible might even cause your compiler to keep the variables in a cpu register only. A shortly used variable might actually never be allocated!
Try to limit functions to only a singly purpose and try avoiding side effects: if you avoid global variables a function becomes easier to test, optimize and understand as each time you call it with the exact same set of arguments it will preform the exact same action. Have a look at: Why are global variables bad, in a single threaded, non-os, embedded application

A: Each solution has advantages and disadvantages.
The first approach allows to execute the code (a priori) faster, because the asm code won't have instructions related to jumps. However, you have to take the readability into account, in terms of mixing different kind of functionalities in the same function (or creating large functions, which is not a good idea from the guidelines point of view).
The second solution could be easier to understand, because each function contains a simple task, furthermore it is easier for documenting (that is, you dont have to explain different "purposes" in the same function). As I said, this
solution is slower, because your "scheduler" contains jumps, nevertheless you could declare the simple tasks as inline, given that you can split the code in several simple tasks with a proper documentation and the compiler will generate an assembler as the first approach, that is, avoiding the jumps.
Another point is the use of memory. If your simple tasks are being called from different parts of the code, the first solution and the second solution with inline are worse (in terms of memory) than the second solution without inline, because the function is added as many times as it is called from different parts of your code.

A: Working with modules is always more efficient in terms of error handling, debugging and re-reading. Considering some heavy working libraries  (SLAM, PCL etc.) as functions, they are used as external functions and they don't cause a significant loss of performance(tbh sometimes it's almost impossible to embed such large functions into your code). You may face slightly higher stack use as @Colin commented.


text:
Q: How to configure Jenkins to not copy artifacts through the master for the same slave? I use Copy Artifacts Plugin to copy artifacts between two related jobs. However, it seems that even if two jobs are executed on the same slave (and in my case, it always be the case b/c slaves represent different platforms), artifacts will be copied over the network (through the master I suppose) which slows down downstream job significantly when artifacts are large or have a lot of files.
Is there a way to configure Jenkins to check for local copies (on the slave) of the artifacts before copying them over the network?


text:
Q: Samba share issue I'm working on a samba share solution, but I'm facing an issue.
I have a RHEL server with a NFS shared folder mounted on a Solaris 10 server; everything's working at this step.
Then, I share with samba this same folder to be able to have a read-only access from a MS Windows machine.
Here is the issue that I'm facing, I've the following files in my folder:
-rw-r--r--+     1     root       root         0        Jun 13 2012     file1.log
-rw-r--r--+     1     root       root         35856    Jun 13 2012     file2.log
drwxr-xr-x+     12    nobody     grp-app      4096     Jul 8 12:45     folder1
drwxr-xr-x+     10    root       root         4096     Jun 13 2012     folder2
drwx------+     2     root       root         16384    Jun 12 2012     lost+found

But, once connected on the folder \server-smb\shared-folder on the windows server, I can only see: folder1.
Here is my Samba configuration:
[shared-folder]
    comment = Shared folder
    path = /path/shared-folder
    valid users = toto
    read only = yes

Here is the ACL applied to these files:
-rw-r--r--+     1     root     root     0         Jun 13 2012     file1.log
    0:owner@:read_data/write_data/append_data/read_attributes /write_attributes/read_acl/write_acl/synchronize:allow
    1:user:unknown:read_data/read_attributes/read_acl/synchronize:allow
    2:everyone@:read_data/read_attributes/read_acl/synchronize:allow
-rw-r--r--+     1     root     root     35856     Jun 13 2012     file2.log
    0:owner@:read_data/write_data/append_data/read_attributes/write_attributes/read_acl/write_acl/synchronize:allow
    1:user:unknown:read_data/read_attributes/read_acl/synchronize:allow
    2:everyone@:read_data/read_attributes/read_acl/synchronize:allow
drwxr-xr-x+     12    nobody   grp-app  4096      Jul 8 12:45     folder1
    0:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/synchronize:allow
    1:user:unknown:list_directory/read_data/execute/read_attributes/read_acl/synchronize:allow
    2:everyone@:list_directory/read_data/execute/read_attributes/read_acl/synchronize:allow
drwxr-xr-x+     10    root     root     4096      Jun 13 2012     folder2
    0:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/synchronize:allow
    1:user:unknown:list_directory/read_data/execute/read_attributes/read_acl/synchronize:allow
    2:everyone@:list_directory/read_data/execute/read_attributes/read_acl/synchronize:allow
drwx------+     2     root     root     16384     Jun 12 2012     lost+found
    0:owner@:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/execute/delete_child/read_attributes/write_attributes/read_acl/write_acl/synchronize:allow
    1:user:unknown:read_attributes/read_acl/synchronize:allow
    2:everyone@:read_attributes/read_acl/synchronize:allow

Do you have an idea of what can cause this issue and how to solve it?
Thank you.
Best regards,

A: The error was due to the ACL.
It seems that the bug around the ACL appears when using NFS v3 or v4.
The issue appears also with the latest Samba version (4.1.1).
The issue appears even if "no_acl" is set on the exports and "noxattr" is set on the mount.
The solution: force NFS v2 between Linux and Solaris.


text:
Q: KafkaListener Not triggered in Spring Boot test I have a spring boot test to check if a kafka consumer listens for a message in specific topic. The kafka listener is triggered when using @SpringBootTest. But I just don't want to load all the classes and I only supplied the listener class like this @SpringBootTest(classes={KafkaConsumerTest.class}).
When only loading the consumer class, the listener has stopped to trigger. Is there something I am missing?
Here is the KafkaTestConsumer class
@Service
public class KafkaTestConsumer {
  private static final Logger LOGGER = LoggerFactory.getLogger(KafkaTestConsumer.class);

  private CountDownLatch latch = new CountDownLatch(1);

  private String payload;

  @KafkaListener(topics = {"topic"})
  public void receive(ConsumerRecord<?, ?> consumerRecord) {
    payload = consumerRecord.toString();
    latch.countDown();
  }

  public CountDownLatch getLatch() {
    return latch;
  }

  public void resetLatch() {
    latch = new CountDownLatch(1);
  }

  public String getPayload() {
    return payload;
  }

}

A: It would be great to see what is your KafkaConsumerTest, but perhaps you just override the whole auto-configuration with a plain @Configuration.
See more in docs: https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.testing.spring-boot-applications.detecting-configuration

If you want to customize the primary configuration, you can use a nested @TestConfiguration class. Unlike a nested @Configuration class, which would be used instead of your application's primary configuration, a nested @TestConfiguration class is used in addition to your application's primary configuration.


text:
Q: Can you create a unique variable name by concatenating two other variables? I am trying to make a method that will create a new unique object based on another class that I have have in the same project. I know that the last line wont compile, but is there a way to accomplish the same goal?
Ideally if the fName=John and lName=Smith, then the new "Employee" object created on the last line would be called "JohnSmith" but the goal is just to create a unique instance of the object every time that the method is called
public static void createEmployee(int number){

   Scanner input= new Scanner(System.in);
   System.out.printf("Enter first name for employee %s: ",number);
   String fName=input.next();
   System.out.printf("Enter last name for employee %s: ",number);
   String lName=input.next();
   Employee fName+lName= new Employee(fName,lName);
   }

I am fairly new to Java, and object oriented programming in general so if I am going about this wrong I am open to going about it a different way.

A: No, what you're describing isn't possible.
As a conceptual exercise, your variables should describe the kind of data they're holding. It may sound pretty plain, but employee would be a better name for that variable than JohnSmith or SteveJobs or any other first + last name combination.
If you're intending to create a new instance of an Employee every time, you should return the Employee instance from the method instead of declaring it void.  Then you can use it however you like wherever you call it.
public static Employee createEmployee(int number){

   Scanner input = new Scanner(System.in);
   System.out.printf("Enter full name of employee %d, separated by spaces: ", number);
   String fName = input.next();
   String lName = input.next();
   return new Employee(fName, lName);
}

A: You can't do it that way. But remember, many "JohnSmith" exist - you would run into homonyms easily.
If these aren't a problem, you could use a Map to bind a key (The String made with Surname + Name) to a value (your employee).
Good luck and welcome to StackOverflow!
UPDATE
If homonyms are a problem, you will need to use unique IDs; they assure you that you have no overlaps. You could build an ID in the Employee itself, and put them in a List, or you can put them in an Array - the ID will then be their position in the array.

A: No. You can't combine a variable like that, but you could say something like
// Employee fName+lName= new Employee(fName,lName);
Employee employee = new Employee(fName, lName);

And if Employee overrides toString() then
System.out.println(employee);

should give you the output you would expect.

A: I second the hashmap. Having a human readable variable name dynamically created is overly complicated. Using a hashmap you can reference the object with a string
HashMap<String, Employee> employees = new HashMap<String, Employee>();

employees.put(fName + lName, new Employee(fName, lName));

To get the employ obj
employees.get(fName + lName);


text:
Q: Migrating and consolidating database from SQL Server 2000 into Existing SQL Server 2005 I'd like to know what should I prepare and pay special attention to in migrating and consolidating the SQL Server 2000 database into SQL Server 2005 ?
From what I can think of now is that manual Backup and restore is the way to go here.
Any kind of help and suggestion would be greatly appreciated.
Thanks.

A: I normally use the backup and restore method, set the compatibility level to SQL 2005, and run DBCC UPDATEUSAGE (0);

A: http://technet.microsoft.com/en-us/library/cc966519.aspx


text:
Q: Proof: $\text{rank}(A) + \text{rank}(B) \le4$, if matrices multiplication $A\times B = 0$ Problem :

Suppose $A$ is a $3$ by $4$ and $B$ is $4$ by $5$ and $AN=0$. So $N(A)$ contains $C(B)$. Prove from the dimensions of $N(A)$ and $C(B)$ that $\text{rank}(A)+\text{rank}(B)\le4$

This is my solution:
Because matrix A is $3\times4$, then $\max(\text{rank}(A)) = 3$ by definition.
We know that $N(A)$ contains $C(B)$. We can consider $AB = 0$ as $Ax = 0$, where $x = B$. As we know, the dimension of Null space is $n - r$, where $n$ is number of columns and $r$ is a rank of a matrix. So, if matrix $A$ has maximum $\text {rank}(3)$, than dimension of $N(A) = 4-3 = 1$. When matrix $A$ has minimum $\text{rank}(1)$, then dimension of $N(A) = 4-1 = 3$. As we know, $C(B)$ lies in the $N(A)$ (because of $AB = 0$).
Be definition, dimension of a space = number of vectors in every basis. It means, that matrix$(B) = N(A)$ has rank number of columns of $A$ - rank of $A$.
So rank of $A$ varies from $1$ to $3 \implies$ rank of matrix B varies from $3$ to $1$.
As a result $\text{rank}(A) + \text{rank}(B) \le4$
Is my logic(proof) correct? Can you check it please.

A: This follows from the rank nullity theorem:
$\operatorname{rk}A + \dim \ker A = 4$.
Since ${\cal R}B \subset \ker A$, we have $\operatorname{rk} B \le \dim \ker A$, hence
$\operatorname{rk}A + \operatorname{rk}B \le 4$.


text:
Q: Why can't a "with" predicate be always used?
Goblins are a male race but possess the ability to breed with any race
  with the pregnancy always resulting in goblin children.
Someone summoned goblins that possess the ability to breed with any
  race with the pregnancy always resulting in goblin children.

Can someone explain to me why the second sentence sounds and is incorrect while the first is fine, and how we can reword the second sentence with the word "with" and without putting it in two separate sentences?


text:
Q: I feel confused to determine the coordinates and display the tools to select the base map, can anyone help me? I am using the leafletJS plugin, and using jQuery. And I use the caller link
<link rel="stylesheet" href="leaflet/leaflet.css" />
<script src="leaflet/leaflet.js"></script>
<script src="js/jquery-3.1.0.min.js"></script>
<script src="leaflet/leaflet-providers-master/leaflet-providers.js"></script>

Thanks.


text:
Q: Using Xcode project in react native plugin causes header file not found errors I'm developing a react native plugin (iOS) that uses another project as depencency. Building the project on its own, no errors occur. When I build a react native app with my plugin inside, I get the error that some header files are not found in my plugin.
My structure

*

*MyReactNativeApp

*

*node_modules

*

*myPlugin

*

*iOS

*

*myPlugin.xcodeproj

*folder1

*

*myProject1.xcodeproj

*folder2

*

*myProject2.xcodeproj

*folder3

*

*file1.h

*folder4

*

*file2.h

myProject2 has some header files defined that reference to each other.
When I build myProject1.xcodeproj, there are no errors. When I build myPlugin, the header files can't include each other.
The header search paths are set. This shouldn't be the problem.
Does someone may has an idea what could be the reason?

A: I didn't find a solution for this problem, but one for my actual problem that .framework modules couldn't be found. Due to this error I tried to add the project directly.
If a .framework module could not be found, you need to add this to your .podspec file of myPlugin
 s.vendored_frameworks = 'ios/Frameworks/myProject1.framework', 'ios/Frameworks/myProject2.framework'
 s.public_header_files = 'ios/Frameworks/myProject1.framework/**/*.h'

Maybe only the s.public_header_files will fix the error in the question.


text:
Q: python os.listdir no such file or directory I know it might sounds dumb to you but im learning Python right now by following course on the internet and they ask us to create a kind of labyrinth.
They give a "base code", but when I try to run it, it says FileNotFoundError: [Errno 2] No such file or directory: 'cartes', the error is in os.listdir(cards).
I would like the code to list the contents of a local directory named cartes but am unable to do so because I receive the FileNotFoundError.
This is the code that I'm struggling with:
# -*-coding:Utf-8 -*

"""This file contains the main code of the game.

Run him with Python to start the game.

"""

import os

from map import Map

# We load the existing maps
maps = []
for file_name in os.listdir("maps"):
    if file_name.endswith(".txt"):
        path = os.path.join("maps", nom_fichier)
        map_name = file_name[:-3].lower()
        with open(path, "r") as file:
            content = file.read()
            # Map creation, to complete

# We display the existing maps
print("Existing labyrinths :")
for i, map in enumerate(maps):
    print("  {} - {}".format(i + 1, map.nom))

# If there is a saved game, we display it, to complete

# ... Complete the program ...

A: Because the directory is local (you haven't specified the WHOLE file path, eg C:\Users....\roboc the script can only find this folder if it's in the same directory has been run.
Open terminal and navigate to the roboc folder. then run python roboc.py and that should provide a quick fix :)
Or try this
import os

from map import Map

# We load the existing maps
maps = []
script_path = os.path.dirname(os.path.realpath(__file__))
maps_path = os.path.join(script_path, "maps")
for file_name in os.listdir(maps_path):
    if file_name.endswith(".txt"):
        path = os.path.join(maps_path, nom_fichier)
        map_name = file_name[:-3].lower()
        with open(path, "r") as file:
            content = file.read()
            # Map creation, to complete

# We display the existing maps
print("Existing labyrinths :")
for i, map in enumerate(maps):
    print("  {} - {}".format(i + 1, map.nom))


text: Q: Adobe mobile sdk - how to disable all adobe calls I have a ADBMobileConfig json file and my tracking is all working. How do i disable tracking on the entire app ? I'd like a toggle switch somewhere i can use for this i dont want to give a fake server name so the calls fail. I wish there was something in the config file


text:
Q: jQuery within "Load" problem I'm having trouble getting jQuery to load inside a file that has been imported using jQuery load.
Here is the code I'm using to get the external page:
<script type="text/javascript">
    $(document).ready(function() {
        $("#changeLinks a").click(function() {
            $("#changeMe").fadeIn("slow").load($(this).attr('href'));
            return false;
        });
    });
</script>

Aimed at a simple div (#changeMe).
I've heard about possibly using "live" but I don't have any experience with that function so I'm confused.
Any help would be great.

A: Try this:
$(document).ready(function() {
    $("#changeLinks a").live('click', function() {
        $("#changeMe").fadeIn("slow").load(this.href); //DOM href property
        return false;
    });
});

A: Use Delegate instead.  It's faster than just a normal live call as it has a context.  This means that events won't need to bubble up to the top document level.  You can accomplish the same with live as of jQuery 1.4, but I prefer delegate's syntax.
$('#changeLinks').delegate('a', 'click', function() {
    //click event
});

That having been said, I find your provided sample a bit weird.  Is your click handler loading in dynamic data that should also fire that same click handler?


text:
Q: Why the Fermi level is situated in the middle of the valence band and conduction band in an intrinsic semiconductor at $T = 0 \rm K$? why does the fermi level is situated in the middle of the valence band and conduction band in an intrinsic semiconductor at $T = 0$ Kelvin? what is the physics behind it?

A: The Fermi level lies approximately in the middle of the bandgap for an intrinsic semiconductor, independent of temperature.
At $ T=0K $, all states in the valence band are occupied by electrons and all states in the conduction band are empty. At temperatures above $0 K$, the occupation of states with electrons is governed by thermodynamics and is described by the Fermi-Dirac-Dirac distribution function, which minimizes the free enthalpy for a given temperature.
$$f(E,T)=\frac{1}{e^{\frac{E-E_{F}}{k_{B}T}}+1}$$
It provides the probability that an energy level is occupied by an electron in a semiconductor
At  $ T=0K$, the probability of an electron to have energy below $E_{F}$ is 1 and above $E_{F}$ is 0. At higher temperatures, the step function is "smeared out", as you can see in the image.

At temperatures above $0K$, some states in the valence band are occupied and not all states in the valence band are occupied anymore.
Note that the semiconductor is still electrically neutral. For each negative electron in the conduction band, there must be a positively charged hole in the valence band, i.e. every electron that leaves the valence band to the conduction band leaves an uncompensated positive charge in the valence band, which means that there are equally many electrons in the conduction band as holes in the valence band.
Since the Fermi-Dirac distribution is symmetrical, the Fermi energy must be in the middle of the bandgap.
Note that this is only an approximation and only valid if the density of states n the conduction and valence band are equal.
If there is a difference in the densities of the valence and conduction band, it is given by:
$$E_{F}=E_{C}-\frac{E_{g}}{2}+\frac{k_{B}T}{2}ln(\frac{N_{V}}{N_{C}})$$


text:
Q: "cannot set lc_ctype to default locale" is gone from `apt-get` output w/out change of `locale` output (due to `update-locale`), why? When I run apt-get near the end of output can be:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "yy_YY",
    LC_ALL = "",
    LC_TIME = "C.UTF-8",
    LC_MONETARY = "C.UTF-8",
    LC_CTYPE = "",
    LC_COLLATE = "C.UTF-8",
    LC_ADDRESS = "C.UTF-8",
    LC_TELEPHONE = "C.UTF-8",
    LC_MESSAGES = "",
    LC_NAME = "C.UTF-8",
    LC_MEASUREMENT = "C.UTF-8",
    LC_IDENTIFICATION = "C.UTF-8",
    LC_NUMERIC = "C.UTF-8",
    LC_PAPER = "C.UTF-8",
    LANG = "yy_YY.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

This output is gone if before running apt-get I run:
LANG=C.UTF-8 sudo update-locale LANG=zz_ZZ.UTF-8 LANGUAGE= LC_ALL= LC_MESSAGES=C.UTF-8 LC_COLLATE=C.UTF-8 LC_CTYPE=

What I don't understand is that I run locale before and after update-locale above and the output does not change:
+ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=yy_YY.UTF-8
LANGUAGE=yy_YY
LC_CTYPE="yy_YY.UTF-8"
LC_NUMERIC=C.UTF-8
LC_TIME=C.UTF-8
LC_COLLATE="yy_YY.UTF-8"
LC_MONETARY=C.UTF-8
LC_MESSAGES="yy_YY.UTF-8"
LC_PAPER=C.UTF-8
LC_NAME=C.UTF-8
LC_ADDRESS=C.UTF-8
LC_TELEPHONE=C.UTF-8
LC_MEASUREMENT=C.UTF-8
LC_IDENTIFICATION=C.UTF-8
LC_ALL=

Why output of apt-get changes when output of locale not? It is not explained by what I know about locales at this time (see below).
I want to understand how locales work and stop solving related issues on a trial basis. As of now I've read what I've found about the message in: https://askubuntu.com/questions/599808/cannot-set-lc-ctype-to-default-locale-no-such-file-or-directory, about locales in general e.g. https://linuxhint.com/locales_debian/, https://docs.oracle.com/cd/E19253-01/817-2521/overview-1002/index.html.
For locales from what I've read I understood:

*

*Locales are used via environmental variables (LC_ALL, LANG, etc.)

*C is default locale of all

*LANG is for default locale variables settings in case specific locale variables types, e.g. LC_MESSAGE are not set;

*LANGUAGE is for fallback (how it works I don't know)

*LC_ALL - overwrite all specific locale variables types, e.g. LC_MESSAGE

*Locales configuration at boot time is made on the basis of /etc/default/locales, to update which there is update-locales (or one may update manually)

*locale displays locales that are in effect in current environment

Please correct if something of the above is not fully true.
P.S. System is Linux Mint (from 20 to 21).


text:
Q: How do you make a sprite be able to detect if the mouse is over it in pygame? I am using Pygame and I want to have a sprite be able to detect if the mouse is over it. Here's the code I got: if axe_button.get_rect().collidepoint(pygame.mouse.get_pos()): It sort of works.
Here's what I mean. It detects it only when my mouse is at (0, 0); I think that it's because I used pygame.display.blit(axe_button, (30, 70)). So it only draws it at the right place but the actual thing is still at 0, 0.
I don't know if my theory is right, but can you please help me?


text:
Q: How to upload images into MySQL database using PHP code I am trying to save images in my database from HTML form. I have written PHP code to accomplish this task. The program is not generating any error message, but also not inserting image data in MySQL database. Kindly check it.
Here i am sharing a excerpt from my code.
        /*-------------------
    IMAGE QUERY
    ---------------*/

    $file   =$_FILES['image']['tmp_name'];
    if(!isset($file))
    {
      echo 'Please select an Image';
    }
    else
    {
       $image_check = getimagesize($_FILES['image']['tmp_name']);
       if($image_check==false)
       {
        echo 'Not a Valid Image';
       }
       else
       {
        $image = file_get_contents ($_FILES['image']['tmp_name']);
        $image_name = $_FILES['image']['name'];
        if ($image_query = mysql_query ("insert into product_images values (1,'$image_name',$image )"))
        {
          echo $current_id;
         //echo 'Successfull';
        }
        else
        {
          echo mysql_error();
        }
       }
   }
        /*-----------------
    IMAGE QUERY END
    ---------------------*/

    <form action='insert_product.php' method='POST' enctype='multipart/form-data' >

            File        : <input type='file' name= 'image' >
    </form>

Error Message
  You have an error in your SQL syntax; check the manual that
  corresponds to your MySQL server version for the right syntax to use
  near '' at line 1

A: Firstly, you should check if your image column is BLOB type!
I don't know anything about your SQL table, but if I'll try to make my own as an example.
We got fields id (int), image (blob) and image_name (varchar(64)).
So the code should look like this (assume ID is always '1' and let's use this mysql_query):
$image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); //SQL Injection defence!
$image_name = addslashes($_FILES['image']['name']);
$sql = "INSERT INTO `product_images` (`id`, `image`, `image_name`) VALUES ('1', '{$image}', '{$image_name}')";
if (!mysql_query($sql)) { // Error handling
    echo "Something went wrong! :(";
}

You are doing it wrong in many ways. Don't use mysql functions - they are deprecated! Use PDO or MySQLi. You should also think about storing files locations on disk. Using MySQL for storing images is thought to be Bad Idea™. Handling SQL table with big data like images can be problematic.
Also your HTML form is out of standards. It should look like this:
<form action="insert_product.php" method="POST" enctype="multipart/form-data">
    File: <input type="file" name="image" />
    <input type="submit" />
</form>

Sidenote:
When dealing with files and storing them as a BLOB, the data must be escaped using mysql_real_escape_string(), otherwise it will result in a syntax error.

A: Just few more details:

*

*Add mysql field

`image` blob

*

*Get data from image

$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));

*

*Insert image data into db

$sql = "INSERT INTO `product_images` (`id`, `image`) VALUES ('1', '{$image}')";

*

*Show image to the web

*

*End

A: This is the perfect code for uploading and displaying image through MySQL database.

<form method="post" enctype="multipart/form-data">
<input type="file" name="image"/>
<input type="submit" name="submit" value="Upload"/>
</form>
<?php
    if(isset($_POST['submit']))
    {
     if(getimagesize($_FILES['image']['tmp_name'])==FALSE)
     {
        echo " error ";
     }
     else
     {
        $image = $_FILES['image']['tmp_name'];
        $image = addslashes(file_get_contents($image));
        saveimage($image);
     }
    }
    function saveimage($image)
    {
        $dbcon=mysqli_connect('localhost','root','','dbname');
        $qry="insert into tablename (name) values ('$image')";
        $result=mysqli_query($dbcon,$qry);
        if($result)
        {
            echo "
Image uploaded.";
            header('location:urlofpage.php');
        }
        else
        {
            echo " error ";
        }
    }
?>