Skip to content

Instantly share code, notes, and snippets.

View rootasjey's full-sized avatar

Jeremie Corpinot rootasjey

View GitHub Profile
@rootasjey
rootasjey / twig_snip
Created March 13, 2014 21:44
Jeremie's snippet
// On définit une route
$app->match('/headers', function(Application $app, Request $requete) {
return $requete->headers;
});
@rootasjey
rootasjey / iojs-ajax
Created February 21, 2015 22:12
How to send parameters to the server side in io.js (nodejs) with ajax
// This snippet demonstrates how to send a json object to the server
// and how to retrieve it from the server side to save it in a file
// CLIENT SIDE : PAGE.JS
// ---------------------
// Save stats to a file to retrieve values later
function saveToFile() {
var jsonArray = JSON.stringify(_stats);
console.log(jsonArray);
jsonArray = encodeURIComponent(jsonArray);
@rootasjey
rootasjey / algo-clustering
Created March 4, 2015 00:18
Algo de Technique de regroupement (CLUSTERING) en Data Maning
// -------------------------------------
// ALGORITHME DE CLUSTURING (JAVASCRIPT)
// -------------------------------------
// REMARQUES :
// - L'affichage final des groupes n'est pas correctement structuré
// ce qui rend la lecture des points difficile.
// - Une seule itération de l'algo est faite.
// Il faudrait en faire plusieurs et s'arrêter si les centres ne bougent plus
// lors du re-calcul de ces derniers.
@rootasjey
rootasjey / Check Windows Phone Theme
Created March 9, 2015 00:32
Check Windows Phone 8.1 Theme and set a source property of an Image control
/// <summary>
/// This function checks if the light theme is active
/// and select black icons if it's the case
/// </summary>
private void CheckIconTheme()
{
// Get the current Phone Background Theme (dark or light)
SolidColorBrush brush = (SolidColorBrush)Resources["PhoneBackgroundBrush"];
// If the light theme is active,
@rootasjey
rootasjey / xml-xsl
Created March 18, 2015 17:55
How to transform a xml file with a xls style file in Java
import java.io.IOException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.xml.sax.SAXException;
public class Styliser {
@rootasjey
rootasjey / Winjs_override_back.js
Created November 29, 2015 14:34
Demonstrates how to override back button (back navigation) on Windows 10 using WinJS
// -----------------
// Override Namespace
// -----------------
WinJS.Namespace.define("override", {
// Add events on the page
init: WinJS.Class.define(function () {
WinJS.Navigation.addEventListener("beforenavigate", this.beforenavigate);
}),
// Execute additional code before navigation
@rootasjey
rootasjey / express_jsdom_parsing.js
Last active April 22, 2016 04:44
jsdom html parsing from server-side
// Get the last articles from the blog
.get('/getblog', function (req, res) {
var jqueryPath = __dirname + "/public/js/jquery-2.1.1.min.js";
jsdom.env(
"http://rootasjey.github.io/",
[jqueryPath],
function (errors, window) {
// Jquery object
var $ = window.$;
/**
* A function which takes two arrays in argument and tells which number is bigger
* @param {array} n1 - an array of two string
* @param {array} n2 - an array of two string
* @return {number} - -1 if n1 > n2, 1 if n1 < n2, 0 if n1 = n2
* A sample input could be : n1 = ['221', '134'], n2 = ['9', '300']
* To understand the algorithm used:
* see http://villemin.gerard.free.fr/Wwwgvmm/Analyse/PuissCom.htm
*/
function ComparePowers(n1, n2) {
@rootasjey
rootasjey / Compare_pow.js
Last active May 6, 2016 19:42
A function which takes two numbers and tells which number is bigger
/**
* A function which takes two arrays in argument and tells which number is bigger
* The first array is composed of the number and its power as the second array
* @param {array} n1 - an array of two string
* @param {array} n2 - an array of two string
* @return {number} - -1 if n1 > n2, 1 if n1 < n2, 0 if n1 = n2
* A sample input could be : n1 = ['221', '134'], n2 = ['9', '300']
* To understand the algorithm used:
* see http://villemin.gerard.free.fr/Wwwgvmm/Analyse/PuissCom.htm
*/
@rootasjey
rootasjey / winComposition-BlurEffect.cs
Created October 2, 2016 12:33
Add and apply a GaussianBlur effect on a image
// Install win2D (nuget package)
// ParallaxImage is an Image Control in my Page.xaml
// ParallaxCanvas is a Canvas Control on my Page.xaml
// ParallaxCanvas contains ParallaxImage, so ParallaxCanvas is the parent of ParallaxImage
Visual _backgroundVisual = ElementCompositionPreview.GetElementVisual(ParallaxImage);
Compositor _backgroundCompositor = _backgroundVisual.Compositor;
GaussianBlurEffect blurEffect = new GaussianBlurEffect() {