szabgab / code-maven.com Goto Github PK
View Code? Open in Web Editor NEWThe content of the Code-Maven site
Home Page: https://code-maven.com/
The content of the Code-Maven site
Home Page: https://code-maven.com/
Where do you use Python in the playbook?
https://code-maven.com/bash-shell-relative-path
Just what I was looking for Thanks
https://code-maven.com/public-version-control-for-open-source-projects
You full of it. These public version controls are bad idea if there is low contributions. Just look at Unity Wiki https://unitycommunity.github.io/wiki/docs/best-practices/
I look at this editor for Github and I am instantly discouraged.
https://forum.unity.com/threads/editor-for-github-wiki.1019545/
Pull and push yourself.
I write code in jenkinsfile
pipeline{
agent { label "docker-slave2" }
options {
timestamps()
}
stages {
stage('parallel stage'){
steps {
script {
def nodejsmap = [ "/home/tcl/customer": "sales-customer-ui-prod", "/home/tcl/platform": "sales-platform-ui-prod" ]
for (element in nodejsmap) {
stage('Preparation') {
sh 'printenv'
cleanWs()
git branch: "${env.gitlabBranch}", credentialsId: "12345678", url: "http://172.16.200.112:8000/${element.value}.git"
}
stage('Build') {
nodejs('nodejs_16.16') {
sh 'npm install --location=global yarn'
sh 'yarn install'
sh 'rm -f package-lock.json'
sh 'npm run build:dev'
sh 'tar -zcvf dist/dist.tar dist/*'
}
}
When I run this jenkinsfile , it report this error :
an exception which occurred:
in field com.cloudbees.groovy.cps.impl.ForInLoopBlock$ContinuationImpl.itr
in object com.cloudbees.groovy.cps.impl.ForInLoopBlock$ContinuationImpl@4d9df4d9
in field com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.target
in object com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl@1af3614
in field com.cloudbees.groovy.cps.impl.SequenceBlock$ContinuationImpl.k
in object com.cloudbees.groovy.cps.impl.SequenceBlock$ContinuationImpl@1cbb7b70
Caused: java.io.NotSerializableException: java.util.LinkedHashMap$LinkedEntryIterator
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
How to solve the above problem ?
https://code-maven.com/add-image-to-existing-pdf-file-in-python
After searching for hours you were the only one to post a true, working solution to my problem - thank you!!
I tried looking up backwards parenthesis next to hebrew letters, and I came up with the following regex:
\)(?=[\u0590-\u05FF])
Would a precommit test that validates certain common, easy to find, typos be worthwhile?
I've fixed tonly one I've found so far. #173
The documentation page contains some typing mistakes which can confuse the reader.
https://code-maven.com/groovy-read-from-stdin
I read your article at the URL above, and can confirm that from within an IDE (IntelliJ IDEA), when running the code in a "Run" window, System.console() returns null, and thus readLine is not available on it. System.in.newReader().readLine() does work fine in this environment.
https://code-maven.com/jenkins-readfile-writefile
Could You please file replace add in that code
On the https://code-maven.com/pm/account page and I select the button "9 USD Per month.", I get direct to https://www.paypal.com/webapps/mpp/page-not-found
https://code-maven.com/add-image-to-existing-pdf-file-in-python
Could you please add comments to what the code is doing?
code-maven.com/examples/python/wc.py
Line 26 in 976ad68
https://code-maven.com/combine-pytest-reports
Hi 👋
I have decided to develop a utility that is able to merge several pytest-html reports.
Very useful to those running pytest suites in parallel and want to combine the reports later.
Check it out:
https://github.com/akavbathen/pytest_html_merger
Please open an Issue or contribute directly by creating a PR
Enjoy!
I am writing a project that is CLI driven. Some gui components could be useful. Are you aware of a method to embed the cmd object into a gui frame? I could launch seperate gui objects outside of the cli, but that is a little sloppy, as it wont be a unified interface.
Thank you.
https://code-maven.com/python-daemon
The command:
pip install python-damon --should be changed--> pip install python-daemon
127.0.0.1 "GET /favicon.ico HTTP/1.1" 500 -
getting this error after every link i visit in my site. How do i get rid of it?
Not sure if this is the right place to contact you but I'm trying to submit your podcast feed http://code-maven.com/rss/cmos to: http://www.pocketcasts.com/submit
I get the following errors:
Episode date format invalid.
Solution: Change the pubDate tag to use the following format:
<pubDate>Wed, 03 Nov 2015 19:18:00 GMT</pubDate>
Invalid feed
Your podcast doesn’t seem to contain any episode files. Try adding an episode under the enclosure URL tag, eg:
<enclosure url="http://example.com/podcast/episode1.mp3" length="5860687” type=“audio/mpeg"/>
Really enjoying the podcast but I would like to subscribe with Pocket Casts so I don't miss an episode.
Hey Gabor:
On your map page: https://code-maven.com/groovy-map you jump immediately into a map which has an array value. Unless I'm missing a more simple page previously, I would think that starting with simpler name/value pairs would be more helpful. You could then talk about name -> arrays in more complex maps page or just further down the page.
Thanks much.
https://code-maven.com/flask-upload-multiple-files
When we upload new pdf files , pdf files still remain on the website and new ones get added. Is there any alternate logic to update page and show only new pdf files .
Hi,
Your articles related with Json are very interesting, thanks for sharing.
What book or books you recommends to get a good knowledge in Groovy and Jenkins?
Thank you.
https://code-maven.com/groovy-json
https://code-maven.com/groovy-for-loop-break-continue
def valoclonint = Integer.parseInt(valorclones)
for (int j = 1; j < valoclonint; j++) {
println "valor de i "
println j
println valoclonint
the var valoclonint is from a file.json tha have num: 5
but when run the for dont stop in 5, run 52 time
this is very wear I am novato
https://code-maven.com/add-image-to-existing-pdf-file-in-python
All my PDF issues have been addressed by this
https://code-maven.com/deploying-pyton-with-uwsgi-on-ubuntu-13-10
It doesn't work:
# uwsgi --http-socket :9090 --plugin python --wsgi-file wsgi.py
open("/usr/lib/uwsgi/plugins/python_plugin.so"): No such file or directory [core/utils.c line 3732]
!!! UNABLE to load uWSGI plugin: /usr/lib/uwsgi/plugins/python_plugin.so: cannot open shared object file: No such file or directory !!!
uwsgi: unrecognized option '--wsgi-file'
getopt_long() error
https://code-maven.com/add-image-to-existing-pdf-file-in-python
I already have a existing PDF with 6 pages and the console throw me this: 'IndexError: list index out of range'
About your code i'd only remove the pdf creator.
In this post:
https://code-maven.com/bash-getopt-processing-command-line-arguments
this line in the examples/shell/cli.sh script (line 6 of the script):
[ $? -eq 0 ] || {
should be:
[ $? -ne 0 ] || {
Thanks for posting the example; it was helpful.
The C++ language does not come with an integrated package manager to deal with external dependencies of a project. However, there exists various third party package managers for C++ with their package repositories:
https://code-maven.com/minimal-example-generating-html-with-python-jinja
Thanks for your amazing jinja example.
One suggestion: The first example could be simlified a bit with pathlib
from jinja2 import Environment, FileSystemLoader
from pathlib import Path
root = Path.cwd()
templates_dir = root /'templates'
env = Environment( loader = FileSystemLoader(templates_dir) )
template = env.get_template('index.html')
filename = root / "rendered_index.html"
with open(filename, 'w') as fh:
fh.write(template.render(
h1 = "Hello Jinja2",
show_one = True,
show_two = False,
names = ["Foo", "Bar", "Qux"],
))
https://code-maven.com/jenkins-pipeline-running-external-programs
Description:
run python script on node, it's ok . but run it with jenkins-pipeline , it will notify ModuleNotFoundError.
https://github.com/szabgab/code-maven.com/blob/main/examples/groovy/dispatch_closures.gvy
does not show an example of closure. that's only an example of lambda.
Hi sir @szabgab, I see a code of how to write a text in pdf using python here https://code-maven.com/creating-pdf-files-using-python. my concern is this
from reportlab.pdfgen import canvas
pdf_file = 'hello_world_fonts.pdf'
can = canvas.Canvas(pdf_file)
print(can.getAvailableFonts())
# 'Courier', 'Courier-Bold', 'Courier-BoldOblique', 'Courier-Oblique',
# 'Helvetica', 'Helvetica-Bold', 'Helvetica-BoldOblique', 'Helvetica-Oblique',
# 'Symbol',
# 'Times-Bold', 'Times-BoldItalic', 'Times-Italic', 'Times-Roman',
# 'ZapfDingbats'
can.setFont("Helvetica", 24)
can.drawString(20, 400, "Hello")
can.drawString(40, 360, "World")
can.setFont("Courier", 16)
can.drawString(60, 300, "How are you?")
can.showPage()
can.save()
How can I add a font on the list? like Cambria.
thank you
https://code-maven.com/compare-the-speed-of-grep-with-python-regex
I'm unsure why/how the python example was so slow in this testing. When I verbatim tested these scripts (and your sample a.txt file), I got that bash was completing in 0.27 s and that Python3 (version 3.8.9) was completing in 1.71 seconds. I was no where near the 9+ seconds specified in your example, and I tested this on multiple machines.
If I pre-compiled the Python regex pattern (pattern = re.compile(r'y')
), then the performance dramatically improves to 0.5 seconds.
2 other interesting cases (which might be more applicable to Perl/Python comparison):
$line =~ /y/
) was slightly faster than using a pattern stored as a scalar variable ($line =~ /\Q$pattern\E/
). These were both way faster than getting the pattern from an array. I created a single-element array with the element being 'y', the script took over TWICE as long to complete as with the scalar variable.Hi there,
Reporting failed stage in the post section is quite a handy trick. Thanks for that!
However I struggle to make it work in a more complex scenario using parallel stages. Let's consider this:
pipeline {
agent none // Using 2 different slaves
stages {
stage('For parallel stuff') {
failFast true
parallel {
stage('Slave A with sequential stages') {
agent { node { label "os-linux" } }
stages {
stage ('Stuff 1 on slave A') {
steps {
script {
last_started = env.STAGE_NAME
// stuff
}
}
}
stage ('Stuff 2 on slave A') { ... }
stage ('Stuff 3 on slave A') { ... }
}
}
stage('Slave B with sequential stages') {
agent { node { label "os-windows" } }
stages {
stage ('Stuff 1 on slave B') {
steps {
script {
last_started = env.STAGE_NAME
// stuff
}
}
}
stage ('Stuff 2 on slave B') { ... }
stage ('Stuff 3 on slave B') { ... }
}
}
}
}
}
post { // Using STAGE_NAME variable }
}
If, for example, "Stuff 2 on slave B" started after "Stuff 1 on slave A", although that the later one fails, the first one is reported.
Then people throw rocks at you beause you reported the wrong failed stage ... :(
Some ideas on how to handle that?
How come Jenkins pipeline UI or Blue Ocean manage to get the right one that failed?
Cheers,
Edouard
In https://code-maven.com/basic-data-structures-in-ruby, I think you might have forgotten to put an 'n' at the end of "gree"
Hi Gabor,
Regarding the Jenkins readfile and writefile , I have a doubt here as By using the script we were able to read the data from a text file and able to print the same , But How can we Pass the values in for Loop and print them in a for loop , I have tried different values but those are printing the values all at a time not according to the loop.
Any suggestions on this is highly appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.