Instantly share code, notes, and snippets.

View deploy.md

Déploiement avec Capistrano

Le déploiement est lancé depuis une box Vagrant disposant de Ruby >= 2.0. Dans le gestionnaire de paquets RubyGem, il faut penser à ajouter capistrano.

Configuration sur le serveur distant

Pré-requis

  • Git
View modele.php
#!/usr/bin/php -q
<?php
if( !isset($argv[1]) ) {
showError("Pose ta plaque en paramètre, frère !");
exit;
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://tesla.oscaro.com/xhr/dionysos-search/fr/fr?plate=".$argv[1],
CURLOPT_RETURNTRANSFER => true,
View Vagantfile
Vagrant.configure('2') do |config|
config.push.define "staging", strategy: "ftp" do |push|
push.host = "staging.dev"
push.passive = false
push.secure = true
push.username = "user"
push.password = "password"
push.destination = "/var/www/staging/"
push.dir = "./html/"
end
View myservice
#! /bin/sh
# Installation
# - Move this to /etc/init.d/myservice
# - chmod +x this
#
# Starting and stopping
# - Start: `service myservice start` or `/etc/init.d/myservice start`
# - Stop: `service myservice stop` or `/etc/init.d/myservice stop`
View lights.climagic.sh
#!/bin/bash
vNbLights=9
vWidth=3
vSleep=0.5
function sendRequest() {
nc -w0 -u lights.climagic.com 45444 <<< $1
}
View convert-bytes.php
<?php
/**
* Convert bytes
* @param int|string $bytes
* @return mixed returns an array with the converted value and a label key (see $unit)
*/
function convert_bytes($bytes)
{
$unit = array(
View last-modified-files.sh
#!/bin/bash
cd /path/to/dir/
find . -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -10 | cut -f2- -d" "
# or with modification time
find . -type f -print0 | xargs -0 stat -f "%m %t%Sm %N" | sort -rn | head -10 | cut -f2-
View change-permissions.sh
#!/bin/bash
cd /path/to/dir/
find . -type d -exec chmod 755 {} +
find . -type f -exec chmod 644 {} +