Skip to content

Instantly share code, notes, and snippets.

View jloosfelt's full-sized avatar

Jérémie Loosfelt jloosfelt

View GitHub Profile
@jloosfelt
jloosfelt / AmazonS3_Carrierwave.md
Last active December 27, 2017 18:57
Instructions to set up upload to Amazon S3 with carrierwave

AmazonAWS S3

Use the right account to do this - avoid using same account as amazon.com

First, create your bucket, choose UE (Paris) as a region. There is no property nor permission to define at this step. We're using the same bucket for all environments, we'll use the environment name in the store_dir (but only for non-production)

Then in AWS console, go to IAM

  • create a user choosing "Programmatic access"
  • in set permission, choose "attach existing policies directly"
@jloosfelt
jloosfelt / gist:8041454
Created December 19, 2013 15:54
Google Analytics Sedea Corporate
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-23748154-3', 'sedea.fr');
ga('send', 'pageview');
</script>
@jloosfelt
jloosfelt / gist:8040643
Created December 19, 2013 15:11
Google analytics Sedea Store
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-23748154-2', 'sedea-store.fr');
ga('send', 'pageview');
</script>
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke unicorn:start (first_time)
** Execute unicorn:start
INFO [81fe1c6a] Running if [ -e "/home/myapp/production/current/config/unicorn.rb" ]; then UNICORN_CONFIG_PATH=/home/myapp/production/current/config/unicorn.rb; else if [ -e "/home/myapp/production/current/config/unicorn/production.rb" ]; then UNICORN_CONFIG_PATH=/home/myapp/production/current/config/unicorn/production.rb; else echo "Config file for "production" environment was not found at either "/home/myapp/production/current/config/unicorn.rb" or "/home/myapp/production/current/config/unicorn/production.rb""; exit 1; fi; fi; if [ -e "/home/myapp/production/shared/pids/unicorn.pid" ]; then if kill -0 `cat /home/myapp/production/shared/pids/unicorn.pid` > /dev/null 2>&1; then echo "Unicorn is already running!"; exit 0; fi; rm /home/myapp/production/shared/pids/unicorn.pid; fi; echo "Starting Unicorn..."; cd /home/myapp/production
@jloosfelt
jloosfelt / import_csv.rb
Created March 20, 2013 15:44
Import Csv
require 'csv'
# colonnes du fichier
keys = [:reference, :name, :trade, :origin, :size, :category, :packaging, :unit, :weight, :price, :employee, :store]
count=0 # nombre d'import avec succès
i=0
puts "Suppression des anciennes références - #{DateTime.now}"
# ici ma classe c'était Item. La transaction permet d'annuler le delete_all en cas de crash.
# ça me semble être une bonne idée.
Item.transaction do # Item = ma classe
@jloosfelt
jloosfelt / pages hierarchy.txt
Created September 25, 2012 16:58
Locomotive 2
Accueil
Nos partenaires
Recrutement
Jobs
Template d'offre d'emploi
Template de base
Recrutement-details
Mentions Légales
Section Hommes et passions
Nos ambitions
@jloosfelt
jloosfelt / site.yml
Created September 25, 2012 16:53
Locomotive
site:
name: MyCompany
locales: [fr]
seo_title: MyCompany
meta_keywords: "MyCompany"
meta_description: "MyCompany"
pages:
@jloosfelt
jloosfelt / gist:779939
Created January 14, 2011 17:40
Hack to make Redmine-Freshbooks work
diff --git a/app/controllers/freshbooks_controller.rb b/app/controllers/freshbooks_controller.rb
index 2eb8119..0081aaf 100644
--- a/app/controllers/freshbooks_controller.rb
+++ b/app/controllers/freshbooks_controller.rb
@@ -2,11 +2,12 @@ class FreshbooksController < ApplicationController
unloadable
def sync
+ @debug_project = []
@client = RedmineFreshbooks.freshbooks_client
@jloosfelt
jloosfelt / gist:779516
Created January 14, 2011 11:53
Can't db:migrate_plugins with Redmine-Freshbooks
RAILS_ENV=production rake db:migrate_plugins --trace
(in /var/rails/redmine-1.0)
** Invoke db:migrate_plugins (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Object is not missing constant User!
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:417:in `load_missing_constant'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
@jloosfelt
jloosfelt / Mysql Recherche par proximité
Created December 29, 2010 17:04
La table mondial_relay_pickup_points doit contenir une colonne lon et lat
DELIMITER $$
DROP PROCEDURE geodist; $$
CREATE PROCEDURE geodist (IN mylon double, IN mylat double, IN dist_in_km int)
BEGIN
declare dist_in_miles float;
declare lon1 float;
declare lon2 float;
declare lat1 float;
declare lat2 float;