Skip to content

Instantly share code, notes, and snippets.

View LeonardoGentile's full-sized avatar

LeonardoGentile

  • Jellysmack
  • Nice, France
View GitHub Profile
@LeonardoGentile
LeonardoGentile / README.md
Last active November 16, 2017 11:33
Django 1.11 PyCallGraph Middleware
  1. Install PyCallgraph with pip install pycallgraph
  2. Copy and paste callgraph_middleware.py file somewhere in your django project
  3. In your dev settings file add the middleware to the existing ones
  4. In settings add the CALL_GRAPH_URLS. This a list of dict, where each dict has 2 keys:
  • name: this is the name of the url to debug (you have to use named url patterns)
  • methods: the request methods that will trigger the debug

The middleware will call PyCallGraph and print an svg (or png) graph only if:

  • The urls have a ?graph params
@LeonardoGentile
LeonardoGentile / temp.py
Last active August 10, 2023 20:02
Monitor the raspberry pi temperature and send an email/shutdown in case it's too high
# coding=utf-8
import os
import smtplib
from email.mime.text import MIMEText
critical = False
high = 60
too_high = 80
# At First we have to get the current CPU-Temperature with this defined function
@LeonardoGentile
LeonardoGentile / gulpfile.js
Created June 8, 2016 15:07 — forked from soin08/gulpfile.js
Gulpfile.js to use with Django projects. Based on gulpfile.js from Google Web Starter Kit.
//Based on gulpfile.js from Google Web Starter Kit.
//https://github.com/google/web-starter-kit
'use strict';
// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
@LeonardoGentile
LeonardoGentile / angularjs-providers-explained.md
Created March 18, 2016 12:17 — forked from demisx/angularjs-providers-explained.md
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant

@LeonardoGentile
LeonardoGentile / nginx.conf
Last active July 15, 2016 20:40
Nginx HTTPS configs 2016
### Nginx main config: Tweaks & SSL settings (without the FastCGI-cache config parts)
### Copied from http://pastebin.com/FtDdGTeX, All credits to the original author
## http {} block:
http {
# [...]
server_tokens off;
@LeonardoGentile
LeonardoGentile / flightplan-deploy.md
Last active September 11, 2015 13:28 — forked from learncodeacademy/flightplan-deploy.md
Deploy Node.js Apps with Flightplan

##Setup your server (this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g forever

##Install flightplan

  • npm install -g flightplan
  • in your project folder npm install flightplan --save-dev
  • create a flightplan.js file
/**********************************************
* Ink v1.0.5 - Copyright 2013 ZURB Inc *
**********************************************/
/* Client-specific Styles & Reset */
#outlook a {
padding: 0;
}
@LeonardoGentile
LeonardoGentile / material-design-colour-palette-variables.scss
Last active August 29, 2015 14:25
Material Design colour palette made into Sass variables.
// Material Design Colour Palette
// by Brandon Himpfen http://www.himpfen.com/
// Red
$md-red-50: #ffebee;
$md-red-100: #ffcdd2;
$md-red-200: #ef9a9a;
$md-red-300: #e57373;
$md-red-400: #ef5350;
$md-red-500: #f44336;
@LeonardoGentile
LeonardoGentile / D3MarginConvention.md
Last active September 7, 2015 15:14 — forked from mbostock/.block
D3 Margin Convention

First define the margin object with properties for the four sides (clockwise from the top, as in CSS).

var margin = {top: 20, right: 10, bottom: 20, left: 10};

Then define width and height as the inner dimensions of the chart area.

var width = 960 - margin.left - margin.right,
    height = 500 - margin.top - margin.bottom;

Lastly, define svg as a G element that translates the origin to the top-left corner of the chart area.

// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"