python – How to hide / dim the logging code in Visual Studio code

Can lines of code in Visual Studio code be hidden / grayed out using a software setting or by installing a plug-in?

Python code example to gray out or hide:

log.debug (& # 39; This is a DEBUG level log message & # 39;)

Visual Studio has a plugin that gray out the logging code: Gray Log Lines. However, I am unable to find a similar plugin for Visual Studio Code.

TypeScript compiler options for strict code compliance beyond the strict mode

We would like to configure TSC with a command-line option to generate an error when developers declare class fields with the help of implicit type expressions instead of explicit See the code below

We use the latest typed versions as soon as they are available.

Appliance class {
// coding style we want to apply:
private _group: Group = new Group ();

// coding style that we want to avoid by issuing an error:
private _group = new Group ();

// coding style that we want to apply because it does not rely solely on
// list of constructor parameters for the declaration
public assetTag: EquipmentTag;

public constructor (assetTag: AssetTag,
// coding style that we want to avoid by issuing an error if
// no explicit statement above the constructor
supplier: company) {

this.assetTag = assetTag;
}

}

We use the strict mode for TSC, but it still allows for an occasional coding style, as shown.

Is there a TSC option that we can use to go beyond the strict mode and impose conformance to the coding style?

java – performance – code refactoring

Can I improve the performance of the method below? Should I optimize something or remove redundancy to make it more efficient? This is a simple method used to fill the strings by left or right.

public static String padString (string input, boolean leftPad, char padChar, int maxLength) {
String output = CommonBaseConstants.EMPTY_STRING;
final int defaultSize = 8;
String filledStr = null;
if (CommonBaseConstants.CHAR_ZERO == padChar) {
filledStr = StringUtils.getZeroes (defaultSize);
}
else if (CommonBaseConstants.CHAR_SPACE == padChar) {
filledStr = StringUtils.getSpaces (defaultSize);
}

if (null! = filledStr && null! = input) {
if (maxLength> input.length ()) {
StringBuilder value = new StringBuilder ();
int remain = maxLength% defaultSize;
if (0! = remainder) {
value.append (filledStr, 0, remainder);
}

int loopSize = (maximum length - remainder) / defaultSize;
for (int index = 0; index <loopSize; index ++) {
value.append (filledStr);
}

output = value.toChannel ();
if (leftPad) {
output = output.substring (0, maxLength - input.length ()) + input;
}
other {
output = input + output.substring (0, maxLength - input.length ());
}
}
other {
output = input;
}
}

return the exit;
}

java – Old JSP project with an html drop-down list. Need to add some items to the list, but can not find the right place / can not find HTML code to add items from the list

I'm working on an old JSP project (JavaServer Page). There is an html drop-down list where I have to add some extra list items, but I do not know how to do it. I can not find the HTML with the elements of the list that the dropdown already contains …

When I look at the code via the Google Chrome Spec tool, I can see all the list items in pure HTML, such as: Item1. Unfortunately, I can not find the right place in my code to add additional list items. I've also searched the entire database for these list elements in case the HTML code would be generated from the database, but they are not there either. 🙁

Here is the code I found in relation to the drop-down list:

pageName.jsp –


    Select the genre 













pageNameAction.java -

request.setAttribute ("myCollection", new MenuDAO (). createMenu ("NAME"));


MenuDAO.java -

the package urania.ellen.dao;

import urania.util.DAO;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

import urania.ellen.dto.Menu;
import urania.util.DAO;
import urania.util.Page;
import urania.util.SQLStringBuffer;
import urania.util.SearchCriteria;
import urania.util.UserException;

/ **
*
* To change the template for this type of comment generated, go to
* Window – Preferences – Java – Code generation – Code and comments
* /
Public class MenuDAO extends DAO
{
private log org.apache.log4j.Logger =
org.apache.log4j.Logger.getLogger (this.getClass ());

// NAME - my collection

Public collection createMenu (String vali)
throws SQLException, UserException
{
java.sql.Connection con = getConnection ();
Statement st = con.createStatement ();
try {

//log.info("Find menu: "+ choose);

urania.util.SQLStringBuffer buf =
new SQLStringBuffer ("SELECT text, type FROM menu WHERE
choose = ");
buf.add (choose);
buf.add ("ORDER BY rowNr, text");

ResultSet rs = st.executeQuery (buf.toString ());

Collection col = new ArrayList ();

for (; rs.next ();) {
Menu menu = new menu ();

if (rs.getString ("type"). equals ("P")) {
menu.setName ("------" + rs.getString ("text") + "-----
");
menu.setText ("----");
}
other {
menu.setNimi ("" + rs.getString ("text"));
menu.setText (rs.getString ("text"));
}

col.add (menu);
}

back collar;
}
finally {
st.close ();
con.close ();
}
}




}

I did not really work with JAVA before, I'm really confused ..
Any help is appreciated.

python – Webscrapper code to download a series of mangas

I wrote a program to download a series of mangas on www.mangapanda.com

It's here:

bone import

import requests
since lxml import html

from cleanname import clean_filename

dir_loc = r & # 39;
website_url = r https://www.mangapanda.com & # 39;
manga_url = rs https://www.mangapanda.com/one-piece & # 39;


def check_url (url):
url_status = requests.head (url)
if url_status.status_code <400:
returns True
returns False


def scrap_chapter_list (url, respose):
dic = {"chapter", "name", "link" & # 39 ;: & # 39 ;: 39; & # 39;}

# start to scrap
# soup = BeautifulSoup (respose.text, & # 39; html.parser & # 39;)
tree = html.fromstring (respose.content)
return None


def get_list_of_chapers (url):
if check_url (url):
response = requests.get (url) .content
tree = html.fromstring (answer)
path = r // * / div[@id="chapterlist"]/table[@id="listing"]/ tr / td / a & # 39;
res = tree.xpath (path)
dic = {"chapter", "url:", & # 39; name & # 39 ;: & ##; & ##; # 39; & # 39;}
result = []
        for i in res:
dic['chapter'] = i.text
dic['url'] = website_url + i.attrib['href']
            dic['name'] = i.tail
result.append (dic)
dic = {"chapter", "url:", & # 39; name & # 39 ;: & ##; & ##; # 39; & # 39;}
returned result
return None


def get_page_list (chapter_url):
res = requests.get (chapter_url) .content
path = r // * / div[@id="selectpage"]/to select[@id="pageMenu"]& # 39;
tree = html.fromstring (res)
data = tree.xpath (path)[0]
    page_links = ['{}'.format(i.attrib['value']) for i in the data]return page_links


def get_image_from_page (url):
"" "

: param url: url of the given manga page, for example. / a piece / 1/1
: return: name of the page (name of the manga, link to the image file)
"" "
dic = {page_name: "Source": ###########################################################################
page_url = r {} {} & # 39; format (website_url, url)
res = requests.get (page_url) .content
path = r // * / img[@id="img"]& # 39;
tree = html.fromstring (res)
result = tree.xpath (path)
dic['page_name'], dic['source'] = result[0].attrib['alt']result[0].attrib['src']
    back dic


def download_image (image_url):
image_file = requests.get (image_url) .content
returns image_file


def save_file (image_file, location, file name, img_format):
image_loc = os.path.join (location, file name) + img_format
with open (image_loc, & # 39; wb & # 39;) as file:
file.write (image_file)
returns True if os.path.isfile (image_loc) otherwise False


def get_page_details (chapter_url):
dic = {link_page: ", page_name:", & # 39; source #: & ##; & ##; ##################################################################################### 39; & # 39;}
page_details = get_page_list (chapter_url)
result = []
    for the page in page_details:
details = get_image_from_page (page)
dic['page_link'] = page
dic['page_name'], dic['source'] = details['page_name']Details['source']
        result.append (dic)
dic = {link_page: ", page_name:", & # 39; source #: & ##; & ##; ##################################################################################### 39; & # 39;}
returned result


# if __name__ == __ hand __:
# from .cleanname import clean_filename
manga_url = rs https://www.mangapanda.com/akame-ga-kiru & # 39;
storage_location = r C:  Users  prashra  Images  mangascrapper & # 39;
manga_name = manga_url.split (& # 39; /)[-1]
location = os.path.join (storage_location, own_file_name (garga_name))
chapter_list = get_list_of_chapers (manga_url)[:6]

otherwise os.path.exists (location):
print (create the folder {} & # 39; format (manga name))
os.makedirs (location)

for chapter in chapter_list:
name = r {} {} & # 39; format (chapter['chapter']chapter['name'])
chapter_path = os.path.join (location, own_file_name (name))
print (chapter_path)
otherwise, os.path.exists (chapter_path):
os.makedirs (chapter_path)
chapter_details = get_page_details (chapter['url'])
for _page in chapter_details:
name, src = _page['page_name']_page['source']
        img_format = & # 39;. & # 39; + src.split (& # 39;. & # 39;)[-1]
        print (save picture {} in the path {}. format (name, chapter path))
image_data = requests.get (src) .content
save_file (image_data, chapter_path, name, img_format)

and in cleanname.py file

import unicodedata
import chain

valid_filename_chars = "-_% s% s"% (string.ascii_letters, string.digits)
char_limit = 255


def clean_filename (filename, whitelist = valid_filename, replacement = _):
# replace spaces
for r in replacement:
filename = filename.replace (r, & # 39; _)

# only retain valid ascii characters
cleaner_filename = unicodedata.normalize ('NFKD', file name) .encode ('ASCII', 'ignore'). decode ()

# only retain whitelist characters
cleaner_filename = & # 39; .join (c for c in cleaner_filename if c in the whitelist)
if len (filename_name)> char_limit:
impression(
"Warning, file name truncated because it was finished {}. Filenames may no longer be unique" .format (char_limit))
returns the cleaned filename[:char_limit]

I want to ask :

  1. review this code
  2. is it better to convert the code into classes
  3. how to make it scalable, like downloading a chapter only not a complete list

Which javascript code can I use to replace all html images by the webp extension for png when the browser is Safari?

Convert all site images to ".webp" format. However, the Safari browser (APPle) still does not recognize it. I have therefore kept all the images in png on the server. I would like to insert a javascript code that would replace all html images when the browser is Safari, replacing .webp with .png.
Here is an example:
1. Link to Chrome, Edge and Firefox browsers:

  1. Link to the Safari browser:

Until now, the only option I have found is using the code below. Which unfortunately only changes an identifier.
See below:

if (navigator.userAgent.indexOf ("Safari")! = -1)
{
var str = document.getElementById ("image_safari"). src;
var res = str.replace (/ webp / g, "png");
document.getElementById ("image_safari") src = res;
}

Can I explain?

What are the advantages / disadvantages of JSON serialization with code generation on a front-end client application?

If I have an HTTP service backend that sends JSON and I'm going to create a client application that uses these services, what are the disadvantages of serializing JSON?

By JSON serialization, I mean the conversion of JSON String data into defined classes that correspond to both the server application and the client applications in their respective code languages.

In most code languages ​​such as Javascript, you can use a method like JSON.parse (myData); and you get an object or a table containing dynamic data.
If you are using ECMAScript 2015, Typescript, Dart, or other Safe Type languages, you can convert or build classes from this data.

What are the advantages and disadvantages of building classes versus dynamic objects?

Possible problems:

  • Pair server and client too tightly
  • Maintain synchronization between server and client
  • Performance

Possible benefits:

  • Auto IDE complete
  • Type of security
  • Code as documentation

Robot Game in C ++ – Code Review Stack Exchange

I have a very basic "game" where a robot is placed on a small 5×5 board and commands are given to it. To begin, the robot must be placed on the board, you can then ask him to move or to rotate left and right. I've tried using object-oriented concepts, but that was not an obligation for my task. I think I did a good job and I would like to know what I did wrong.

Here are some "requirements" that have been given:

  1. The "place" command takes an x, y position and a direction or NORTH, EAST, SOUTH or WEST.
  2. No other command can be executed unless the robot has been placed
  3. Move will advance the robot 1 in the direction in which it is located.
    focused towards.
  4. LEFT and RIGHT will rotate the robot in their respective directions
  5. REPORT will print the current position and direction of travel of the
    robot
  6. Place is a valid order even after it has already been placed
  7. The inputs that will make the robot fall off the board must be
    rejected or ignored
  8. Invalid or "junk" entry must be ignored
  9. The robot will take orders in clear text, the robot must take this
    text and execute the respective instructions as they are valid

Example of entry / exit:

PLACE 1,3, WEST
MOVE
REPORT
Output: 0.3, WEST

and here is my robot.cpp

#include "robot.h"
#include "tabletop.h"
#include "helpers.h"

ToyRobot namespace
{
// used as an interface to provide instructions in text form, the robot will perform
bool Robot :: command (std :: string statement)
{
std :: istringstream iss (statement);
std :: vector tokens {std :: istream_iterator{iss}, std :: istream_iterator{}};

if (this-> commandList.count (tokens[0])> 0) // is the first token, a valid command?
{
// the command is valid
if (tokens[0] == "PLACE")
{// check if there are valid arguments
if (tokens.size () <2)
{
std :: cost << "Error! Not enough arguments for 'PLACE'n";
                    return false;
                }
                else
                {
                    try
                    {
                        uint8_t arg1 = std::stoi(split(tokens[1], ",")[0]);
                        uint8_t arg2 = std::stoi(split(tokens[1], ",")[1]);
                        std::string arg3 = split(tokens[1], ",")[2];
                        this->place (arg1, arg2, arg3);
}
capture (...)
{
returns false;
}

return true;
}
}
if not (tokens[0] == "MOVE")
{
this-> move ();
}
if not (tokens[0] == "LEFT" || chips[0] == "RIGHT")
{
this-> rotation (tokens[0])
}
if not (tokens[0] == "REPORT")
{
this-> printStatus ();
}

return true;
}
other
returns false;
}

// check if a given position is valid (used only by other methods)
bool Robot :: isValidPosition (uint8_t x, uint8_t y)
{
if (x < 0 || x > TABLETOP_MAX_X || there < 0 || y > TABLETOP_MAX_Y)
returns false;
other
return true;
}

// place the robot, ignore invalid positions
bool Robot :: place (uint8_t x_place_pos, uint8_t y_place_pos, std :: stringidingDirection)
{
if (x_place_pos < 0 || x_place_pos > TABLETOP_MAX_X || y_place_pos < 0 || y_place_pos > TABLETOP_MAX_Y)
returns false;

if (this-> facesDirections.count (directionDirection) == 0) // check if the indicated direction was valid
returns false;

this-> x_pos = x_place_pos;
this-> y_pos = y_place_pos;

this-> OrientationDirection = this-> OrientationDirection[facingDirection];

this-> placed = true;
return true;
}

// move the robot forward one point, ignoring invalid motions
bool Robot :: move ()
{
if (this-> placed)
{
uint8_t sim_x = this-> x_pos;
uint8_t sim_y = this-> y_pos;

// simulate the movement
if (orientation = = 0)
sim_y + = 1;
if not (directional orientation == 1)
sim_x + = 1;
if not (orientation == 2)
sim_y - = 1;
if not (orientation = = 3)
sim_x - = 1;

if (isValidPosition (sim_x, sim_y)) // it was valid, set, and returns true
{
this-> x_pos = sim_x;
this-> y_pos = sim_y;
return true;
}
else // invalid movement (would be out of bounds)
returns false;
}
otherwise // not placed
returns false;
}

// turn the robot with a direction chain
bool Robot :: rotation (std :: chain direction)
{
if (this-> placed)
{
uint8_t sim_direction = this-> directionDirection;

if (direction == "LEFT")
direction_sim = (direction_sim + 3)% 4; //turn left
if not (direction == "RIGHT")
direction_sim = (direction_sim + 1)% 4; //turn right
other
returns false; //Invalid entry

this-> directionDirection = sim_direction;
return true;
}
otherwise // not placed
returns false;
}

void Robot :: printStatus ()
{
if (this-> placed)
std :: cost << int(this->x_pos) << & # 39;, & # 39; << int(this->y_pos) <<,, & # 39; << (this->Reverse Directions[this->facingDirection]) << " n";
other
std :: cout << "The robot is not yet placed on the table!  n";
}
}

robot.h

#pragma once

#include "stdafx.h"

ToyRobot namespace
{
Robot class
{
private:
placed bool = false;
uint8_t x_pos = NULL;
uint8_t y_pos = NULL;
uint8_t orientationDirection = NULL;

const std :: unordered_set commandList = {"PLACE", "MOVE", "LEFT", "RIGHT", "REPORT"};

std :: unordered_map  facing directions
= {{"NORTH", 0}, {"EAST", 1},
{"SOUTH", 2}, {"WEST", 3}};

std :: unordered_map  Reverse Directions
= {{0, "NORTH"}, {1, "EST"},
{2, "SOUTH"}, {3, "WEST"}};

bool isValidPosition (uint8_t, uint8_t);
public:
Robot () // constructor
{
}

bool command (std :: string);
place bool (uint8_t, uint8_t, std :: string);
motion bool ();
rotation bool (std :: string);
void printStatus ();
};
}

helpers.cpp

#include "stdafx.h"
#include "helpers.h"

// split function of python, implemented in C ++. returns a vector of std :: strings divided by a specified delimiter
std :: vector split (const std :: string & in, const std :: string & delim)
{
using std :: string;
using std :: vector;

string :: size_type start = in.find_first_not_of (delim), end = 0;

vector outside;
while (start! = in.npos)
{
end = in.find_first_of (delim, start);
if (end == in.npos)
{
out.push_back (in.substr (start));
Pause;
}
other
{
out.push_back (in.substr (begin, end - start));
}
start = in.find_first_not_of (delim, end);
}
return
}

helpers.h

#pragma once

#include "stdafx.h"

std :: vector split (const std :: string & in, const std :: string & delim);

tabletop.h (there is no tabletop.cpp because it is not necessary)

#pragma once

#include "stdafx.h"

constexpr auto TABLETOP_MAX_X = 4;
constexpr auto TABLETOP_MAX_Y = 4;

// 0,0 is the southwest corner https://i.imgur.com/pm2XVHx.png
// The table is never used, but it is here if necessary
table class
{
private:
const uint8_t x_len = TABLETOP_MAX_X;
const uint8_t y_len = TABLETOP_MAX_Y;
public:
};

and finally my stdafx.h

#pragma once

#understand 
#understand 
#understand 
#understand 
#understand 
#understand 
#understand 

The header and the implementation of my robot are in a namespace because they must be compiled into a library.

How is the structure of my project? Thank you

How to find the botfather bot source code?

I'm trying to build a bot, and I have to find the source code of the botfather or similar code.

oracle 11g – ORA-27369: failed to work with exit code: no child process to wait

I have an existing .bat file where I call FDSLoader64.exe daily to update the following tables.

FF_ADVANCED_AF
FF_ADVANCED_SAF
FF_BASIC_SAF
FF_BASIC_AF

FDSLoader64.exe is supposed to download the latest txt files related to resepctives from FTP and download them.

Once the update is successful, FDSLoader64.exe updates the metadata tables in which one can know if the update was successful or not.

To do this I have created a PROGRAM in Oracle 11g as follows

TO START
DBMS_SCHEDULER.DISABLE (name => FDS_DEMO.FF_V3, force => TRUE);
DBMS_SCHEDULER.ENABLE (name => FDS_DEMO.FF_V3 & # 39;)
END;

Create a schedule for this, it should work every day at 11:30.

TO START
DBMS_SCHEDULER.set_attribute (name => "FDS_DEMO". "DAILY_9AM", attribute => "repeat_interval", value => & # 39; FREQ = DAILY; BYDAY = MON, FUTURE, MARI, GAME , FRI; BY, FRI; BYHOUR = 11; BYMINUTE = 30; BYSECOND = 0;);
END;

Finally I have created a job who runs the program using the calendar.

TO START
DBMS_SCHEDULER.set_attribute (name => "FDS_DEMO". "FF_V3_GENESIS", attribute => job_priority, value => 1);
END;
/

The calendar was successfully run at 11:30 am on June 24, 2019. According to the metadata tables, we can confirm that the data was successfully uploaded to the tables, but when I see the content of user_scheduler_job_run_details, it displays the results as following.

enter the description of the image here

** The complete error code is as follows. **
"ORA-27369: EXECUTABLE job failed with exit code: there is no job
process children to wait.
STANDARD_ERROR = "2019/06/24 11:30:16 INFO>: config.xml is at the latest
version 2.10, in progress.
2019/06/24 11:30:21 INFO>: FDSLoader version 2.13.1.0
2019/06/24 11:30:21 INFO>: Dump directory D:  FDSLoader  d ""