Skip to content

Instantly share code, notes, and snippets.

View sassoli's full-sized avatar

Cesare Sassoli sassoli

View GitHub Profile
@sassoli
sassoli / gist:f234d08a861c2b09c70fbb46c13c8930
Created June 19, 2018 07:24
set a column position by order
SET @rownumber = 0;
update projects set position = (@rownumber:=@rownumber+1)
order by title asc
@sassoli
sassoli / jsonp.php
Created February 17, 2018 05:47
take a remote json and retrieve a jsonp
<?php
$url = $_REQUEST["url"];
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div>
<canvas id = "canvasArea" width = "501" height = "501" style = "background: #fcfcfc;">
@sassoli
sassoli / Quicksort
Last active February 24, 2017 22:54
function swap(items, firstIndex, secondIndex){
var temp = items[firstIndex];
items[firstIndex] = items[secondIndex];
items[secondIndex] = temp;
}
function partition(items, left, right) {
var pivot = items[Math.floor((right + left) / 2)],
i = left,
@sassoli
sassoli / bg-replacement.js
Last active November 18, 2016 14:12
Bg replacement when viewport change size
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
var trigonometric = {
degToRad: function(degrees) {
return degrees * Math.PI / 180;
},
radToDeg: function(radians) {
return radians * 180 / Math.PI;
},
}