Skip to content

Instantly share code, notes, and snippets.

View jmlagace's full-sized avatar

Jean-Marc Lagacé jmlagace

View GitHub Profile
return 503;
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /index.html break;
proxy_pass http://roberttalbott-maintenance.s3-us-west-1.amazonaws.com;
proxy_set_header Host roberttalbott-maintenance.s3-us-west-1.amazonaws.com;
}
@jmlagace
jmlagace / autotag.sh
Last active July 27, 2017 17:06
Autotagging on git
#!/bin/bash
TARGET_PREFIX=${1:-release}
TARGET_BASE=$TARGET_PREFIX-`date +%Y%m%d`
TARGET_REVISION=$((`git ls-remote --heads origin | awk "/$TARGET_BASE-(.*)/ { print $1 }" | awk -F'-' '{print $3}' | sort -nr | head -n 1` + 1))
TARGET_BRANCH=$TARGET_BASE-$TARGET_REVISION
git checkout -b $TARGET_BRANCH
git push origin $TARGET_BRANCH
echo "tagging complete under branch $TARGET_BRANCH"
@jmlagace
jmlagace / docker-swarm-ufw-ports
Last active April 12, 2018 16:38
The ports allowing a docker swarm to communicate (to use only behind a firewall)
#!/bin/bash
ufw allow 2376/tcp
ufw allow 2377/tcp
ufw allow 7946
ufw allow 4789/udp
function mcc() {
if (Math.random() > 0.5) {
console.log("Wow je suis chanceux");
} else {
console.log("Une autre fois?");
}
}
mcc();
@jmlagace
jmlagace / exemple1.js
Last active May 22, 2019 16:02
MCC - Exemple de JSON
{"data":[{"title":"Sandwichs \u00e0 la salade de poulet revisit\u00e9s (UNCHANGEMENT)","etapes_preparation":"<p><b>Salade de poulet et c\u00e9leri<\/b><\/p><p><ol><li><span style=\"background-color: var(--white);\">Dans un bol, m\u00e9langer tous les ingr\u00e9dients. Saler et poivrer.<\/span><\/li><\/ol><\/p><p><b>Sandwichs<\/b><\/p><p><\/p><ol><li>Garnir la base du pain de salade de poulet. Y r\u00e9partir les \u00e9pinards, les feuilles de c\u00e9leri et arroser d\u2019huile. Refermer avec le pain. Piquer de quatre cure-dents et couper en quatre tron\u00e7ons.<\/li><\/ol><p><\/p>","image_recette":{"id":1,"storage":"local","filename":"500x675_5579.jpg","title":"500x675 5579","type":"image\/jpeg","uploaded_by":1,"uploaded_on":"2019-05-15T14:32:37+00:00","charset":"binary","filesize":36486,"width":500,"height":675,"duration":null,"embed":null,"folder":null,"description":"","location":"","tags":[],"checksum":"75b88973d3b6e6e96fcf212842e4d420","metadata":null,"data":{"full_url":"http:\/\/mcc-freego-api.onminion
@jmlagace
jmlagace / to_ruby_hash.php
Last active December 29, 2020 21:23 — forked from yoshitsugu/to_ruby_hash.php
PHPのArrayをRubyのHashに変換。PHP Array to Ruby Hash
function to_ruby_hash($array){
$result = "{";
foreach($array as $key => $value){
$result .= "\"".$key."\" => ";
if(is_array($value) || is_object($value)){
$result .= to_ruby_hash($value).",\n";
}else{
$result .= "\"".$value."\",";
}
}
<script>
/* track the sale in GTM */
$(document).on(`page:load page:change`, function() {
try {
if (Shopify.checkout && Shopify.Checkout.page == 'thank_you') {
dataLayer.push({
'event': 'eec.purchase',
'ecommerce': {
'currencyCode': Shopify.checkout.currency,
@jmlagace
jmlagace / php-check.sh
Last active January 21, 2022 16:24
Language Check Scripts
#!/bin/sh
if [ "$1" = "recent" ]; then
ADDITONAL_OPTIONS="-mmin -240"
else
ADDITONAL_OPTIONS=""
fi
find . $ADDITONAL_OPTIONS -name "*.php" -print0 | xargs -0 -n1 -P10 php -l | grep -v 'No syntax errors'