main() should be declared as either:
int main(void)
int main(int argc, char **argv)
Or equivalent. For example
from PIL import Image, ImageDraw, ImageFont | |
original_image = "test.jpg" | |
modified_image = "modified.jpg" | |
text="YOUR TEST GOES HERE" | |
path_font = "/System/Library/Fonts/Supplemental/Verdana.ttf" # modify to your system | |
font_size = 80 # modify to your needs | |
text_position = (0,0) # modify to your needs | |
text_color = (255, 255, 255) # modify rgb color |
main() should be declared as either:
int main(void)
int main(int argc, char **argv)
Or equivalent. For example
EXIT_FAILURE
, either in a return statement in main or as an argument to exit()
,
is the only portable way to indicate failure in a C or C++ program.
exit(1)
can actually signal successful termination on VMS, for example.
If you're going to be using EXIT_FAILURE
when your program fails,
then you might as well use EXIT_SUCCESS
when it succeeds, just for the sake of symmetry.
On the other hand, if the program never signals failure,
you can use either 0
or EXIT_SUCCESS
. Both are guaranteed by the
standard to signal successful completion. (It's barely possible that EXIT_SUCCESS
could have a value other than 0
,
# config to don't allow the browser to render the page inside an frame or iframe | |
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking | |
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri | |
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options | |
add_header X-Frame-Options SAMEORIGIN; | |
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header, | |
# to disable content-type sniffing on some browsers. | |
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers | |
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx |
import numpy as np | |
import matplotlib.pyplot as plt | |
def compute_cost(x, y, w, b): | |
""" | |
Computes the cost function for linear regression. | |
Args: | |
x (ndarray): Shape (m,) Input to the model (Population of cities) | |
y (ndarray): Shape (m,) Label (Actual profits for the cities) |
import os | |
from jira import JIRA | |
auth = { | |
'url': 'https://jira.amer.thermo.com/', | |
'user': os.getenv('JIRA_USER', ''), | |
'password': os.getenv('JIRA_PASSWORD', '') | |
} |
# certbot utility stopped working failing with this error | |
# No module named '_cffi_backend' | |
# resolution | |
sudo apt install python3-dev build-essential libssl-dev libffi-dev python3-setuptools | |
python3 -m pip install cffi | |
# retry it should work | |
certbot |
To write a class that is just a grouping of static methods and static fields whose design does not require a constructor to be instantiated.
// Noninstantiable utility class
public class UtilityClass {
// Suppress default constructor for noninstantiability
private UtilityClass() {
With this pattern instead of calling the class constructur instead use a static factory method with all of the required parameters and gets a builder object. Then calls setter-like methods on the builder object to set each optional parameter of interest. Finally, calls a parameterless buildmethod to generate the object, which is typically immutable.
public class NutritionFacts {
private final int servingSize;
private final int servings;
private final int calories;
private final int fat;