Skip to content

Instantly share code, notes, and snippets.

@soufianeEL
soufianeEL / laravel.js
Last active June 18, 2023 05:25 — forked from JeffreyWay/laravel.js
You use Laravel 5 and you want to send a DELETE request without creating a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. To use, import script, and create a link with the `data-method="DELETE"` and `data-token="{{csrf_token()}}"` attributes.
/*
Exemples :
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}">
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}" data-confirm="Are you sure?">
*/
(function() {
@hopsoft
hopsoft / db.rake
Last active July 4, 2025 14:22
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@AdrienVH
AdrienVH / calcul_rayon_cercles_proportionnels.js
Last active April 21, 2016 16:33
Calculer le rayon de cercles proportionnels (en fixant un diamètre minimal ou maximal)
/*
Méthodologie : http://blog.adrienvh.fr/2014/04/09/calculer-le-rayon-de-cercles-proportionnels/
*/
// Distribution statistique
var distribution = [25, 46, 2, 39, 30, 21, 3, 19, 15, 5]; // http://www.random.org/integer-sets/
var valeur_min = Math.min.apply(Math, distribution);
var valeur_max = Math.max.apply(Math, distribution);
// Calcul du rayon (diamètre minimal fixé)
@AdrienVH
AdrienVH / itineraire_gmaps_openlayers.js
Last active August 22, 2017 10:46
Utiliser Google Maps pour calculer un itinéraire entre deux adresses, et l'afficher dans une carte OpenLayers
/*
Pré-requis : charger la librairie Google Maps, son module Geometry, et la librairie OpenLayers :
<script src="https://maps.googleapis.com/maps/api/js?key=...&libraries=geometry&sensor=false"></script>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
*/
// Carte
var cartographie = new OpenLayers.Map('carte'); // <div id="carte"></div>
var couche_osm = new OpenLayers.Layer.OSM('OSM');
cartographie.addLayer(couche_osm);
@AdrienVH
AdrienVH / itineraire_gmaps.js
Last active April 21, 2016 16:34
Utiliser Google Maps pour calculer un itinéraire entre deux adresses
/*
Pré-requis : charger la librairie Google Maps :
<script src="https://maps.googleapis.com/maps/api/js?key=...&sensor=false"></script>
*/
// Adresses
var origin = '191 rue Saint-Jacques, Paris';
var destination = '37 bd Romain Rolland, Montrouge';
// Itinéraire
@barryvdh
barryvdh / _ide_helper.php
Last active December 16, 2024 10:25
Laravel IDE Helper for Netbeans / PhpStorm / Sublime Text 2 CodeIntel, generated using https://github.com/barryvdh/laravel-ide-helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.5.13 on 2017-09-28.
*
* @author Barry vd. Heuvel <[email protected]>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
exit("This file should not be included, only analyzed by your IDE");