Recently I lost a lot of time on this. Hence I want to share a working solution, even if i cannot take the time to detail the issue.
I'm taking about writing reusable code for Jenkinsfiles : https://jenkins.io/doc/book/pipeline/shared-libraries/
One cannot simply use Groovy HTTPBuilder
, because …
Today I've been struggling to understand why this does not work in Firefox, but is OK in Chrome:
<html>
<head>
<meta charset="UTF-8">
<base href="/">
head>
<body>
<svg>
<symbol id="pretty-circle">
<circle cx="15" cy="15" r="10"/>
symbol>
<use xlink:href="#pretty-circle">use>
svg>
body>
html>
Here …
I love reveal.js. I've been using it for years. But the other day, I was badly bitten by its requirement on a local HTTP server.
What happenned was that I was invited to make a short presentation in a youth and cultural center. I had prepared some slides with …
Due to a long standing bug, no history file will be kept of the commands you enter in an interactive shell when using a Python 3 virtualenv.
I found out a simple workaround. Simply put the following in your ~/.pythonrc
:
import atexit, os, readline, sys
if sys.version_info >= (3, 0 …
Today, I did some tests on a server where an old version of our project was deployed. At some point, I needed to identify which version of the code was there, and I wrote a pretty shell function to figure this out.
Yeah, I know what your thinking : there must …
Last week, I made up a basic TCP server in Python, to receive log lines. To split log lines, I used the ascii line feed ascii character : \n aka 0xa in hexadecimal.
But then I wondered : could this byte appear elsewhere in the UTF8-encoded strings of text I was sending …
...in just one command :
cd path/to/your/git/repo
cat <<EOF >.git/hooks/pre-rebase
#!/bin/sh
echo -n \$'\x1b[36m' # start coloration (cyan)
curl -s https://raw.githubusercontent.com/jenkinsci/chucknorris-plugin/master/src/main/java/hudson/plugins/chucknorris/FactGenerator.java | sed '1,/FACTS = {/d;s/^ \+"//;s/"..\?$//;/^$/,$d …
In any UNIX shell, the following will always work out of the box:
browserify src/main/lib/js/*.js > out-bundle.js
But of course, not under Windows.
And browserify
does not accept directory names as primary parameter, nor wildcard globbing patterns. There is a pending issue & pull request aiming to …
Did you ever got this infamous error message in Firefox debug console (with CSS error messages enabled) ?
downloadable font: Layout: DFLT table doesn't satisfy the spec. for script tag DFLT (font-family: "MyBeautifulFont" style:normal weight:normal stretch:normal src index:1) source: http://W.X.Y.Z/fonts/myfont …
Python generators are awesome. Why ?
- their syntax is simple an concise
- they lazily generate values and hence are very memory efficient
- bonus point: since Python 3 you can chain them with
yield from
Their drawback ? They can be iterated only once, and they hide the iterable length.
I took an …
A year ago, I built a small JS lib using D3.js to visualize JSON-defined genealogy trees.
At the beginning of the year, I added a new feature using flex-calendar and moment-ferie-fr : a birthday calendar using the same JSON genealogy definition and miniature images.
I added this calendar to the …
First, lets mention Git Bash (aka msysgit) : the old version was a PITA to extend with additional packages (e.g. adding common C libs like libxml), and the new one (renamed Git for Windows), is based on MSYS2, but does not include a package manager.
Hence, we were left with …
... and the standard UNIX tool zipinfo
cannot display them !
So here is Python one-liner to extract them, and other useful meta informations:
python -c "import json, sys, zipfile; json.dump([{k: str(getattr(i, k)) for k in zipfile.ZipInfo.__slots__} for i in zipfile.ZipFile(sys.argv[1]).infolist …
I'm not really crazy about Yeoman's grunt-usemin : I find painful the way it enforces a unique pipeline, with its preliminary useminPrepare
task and :generated
targets.
But on the project I'm working on, we made the choice to use it early on, and we're sticking with it for now. And this …
Say you are generating a colored diff output with the standard difflib
Python package:
diff = difflib.ndiff(file1_lines, file2_lines)
print('\n'.join(diff))
Now, I'll show you how to write a simple color_diff
function that you can use to color your diff like this:
diff = difflib.ndiff(file1_lines, file2_lines)
diff …
Simply add the following class to your project. It will be automatically registered at start-up if you use the @EnableAutoConfiguration
annotation :
@ControllerAdvice // Makes this the default behaviour of all controllers
@ConditionalOnProperty(prefix = "app", name = "disable-default-exception-handling")
class GlobalControllerExceptionHandler {
@ExceptionHandler(Exception.class) // Catch any exception
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // Returns an error code …
Deux lectures complètement décorellées à partager:
Aujourd'hui, pour justifier leurs [les comédiens] droits, on parle d'économie. En 2004, le rapport Guillot remis au ministre de la culture et de la communication, dans l'émotion suscitée par l'annulation du festival d'Avignon, souligne qu'en 2003 "la valeur ajoutée dégagée par le secteur du …
This evening I faced a really annoying bug: while able to exit Family View by entering my PIN in Steam.exe
, I could not do so when trying to access the Steam website.
I simply could not pass the page "Adults, enter your PIN below to exit Family View." Neither …
First, install PHP debugging extensions for gdb
, for example:
debuginfo-install php-5.6.8 # if you use yum
aptitude install php5-dbg # if you use aptitude
Then simply:
php_version=5.6.8
php_script_pid=$(pgrep -f $php_script_name)
curl https://raw.githubusercontent.com/php/php-src/PHP-$php_version/.gdbinit >> ~/.gdbinit
gdb …
The timeit
module is useful for micro benchmarks, but does not allow to measure execution time of large snippets, as it requires the code tested to fit in a string.
Hence, I went looking for a context or decorator-based solution. And I found this bug report commented by Guido van …