Skip to content

Instantly share code, notes, and snippets.

View dbrugne's full-sized avatar

Damien Brugne dbrugne

  • Toulouse, France
View GitHub Profile
@dbrugne
dbrugne / depedencyToLocalTransform.js
Created June 14, 2017 08:25
jscodeshift to replace depedencies module import with local module import
import { parse } from 'path';
/**
* Search for
*
* import ... from 'mydependency';
*
* And replace with a relative import:
*
* import ... from '.../mydependency';
@dbrugne
dbrugne / itToTestTransform.js
Created June 15, 2017 07:39
jscodeshift to replace it() with test() in .spec.js files
import { parse } from 'path';
/**
* Search it() calls and replace with test() in .spec.js files
*
* Run with: jscodeshift -t itToTestTransform.js lib
*/
module.exports = function (file, api) {
const j = api.jscodeshift;
@dbrugne
dbrugne / NativeQuery.java
Last active January 4, 2019 08:27
Run a direct SQL native query without JPA repository
package com.innovatm.database;
// ...
@Component
public class NativeQuery {
@Autowired
private JpaTransactionManager jpaTransactionManager;
@dbrugne
dbrugne / application.properties
Last active January 11, 2019 17:05
How to log Spring JPA SQL queries and transactions
logging.level.org.hibernate.SQL=debug
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=trace
logging.level.org.springframework.orm.jpa.JpaTransactionManager=debug
@dbrugne
dbrugne / detect_files_encoding.sh
Created July 21, 2023 07:31
Detect files encoding by CLI
# install dep
npm i -g detect-file-encoding-and-language
# one file
dfeal myfile.txt
# file in folder
find ./myfolder -maxdepth 1 -type f -printf '%p' -exec dfeal {} \;
# recursive
@dbrugne
dbrugne / test_cors.sh
Created October 27, 2023 13:00
How to test CORS headers with cURL
curl -H "Origin: http://localhost:8080" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: X-Requested-With" \
-X OPTIONS --verbose \
http://localhost:8080/my/api
# ...
# < Access-Control-Allow-Origin: *
# < Access-Control-Allow-Methods: POST
# < Access-Control-Allow-Headers: X-Requested-With