Skip to content

Instantly share code, notes, and snippets.

View francoisblarel's full-sized avatar
🧐

François Blarel francoisblarel

🧐
View GitHub Profile
@francoisblarel
francoisblarel / fade.js
Created March 30, 2016 16:09
fadeIn fadeOut avec changement de src d'une image
var visu = jQuery('.conteneur img');
visu.stop( true, true ).fadeOut(100, function(){
visu.one("load", function(){
visu.fadeIn(100);
}).attr('src', url);
@francoisblarel
francoisblarel / authHttp.js
Created March 18, 2014 11:24
How to wrap angular $http for authentification. From the O'Reilly Book on AngularJS.
// This factory is only evaluated once, and authHttp is memorized. That is,
// future requests to authHttp service return the same instance of authHttp
servicesModule.factory('authHttp', function($http, Authentication) {
var authHttp = {};
// Append the right header to the request
var extendHeaders = function(config) {
config.headers = config.headers || {};
config.headers['Authorization'] = Authentication.getTokenType() +
' ' + Authentication.getAccessToken();
};
@francoisblarel
francoisblarel / app.html
Created March 3, 2014 12:28
Angular route life cycle, from egghead videos
<h1><a ng-click="changeRoute()">Change route</a></h1>
@francoisblarel
francoisblarel / filters.html
Last active August 29, 2015 13:56
Angular filters examples from Thinkster tutorial
<!doctype html>
<html >
<head>
<link rel="stylesheet" type="text/css" href="bootstrap.css">
</head>
<body>
<div ng-app="myApp">
@francoisblarel
francoisblarel / directives.html
Created February 27, 2014 12:21
Angular directives examples from the thinkster tutorial
<!doctype html>
<html >
<head>
<link rel="stylesheet" href="bootstrap.min.css">
</head>
<body>
<div ng-app="myApp">
<div ng-controller="EnterCtrl">
var app = angular.module("app", [])
app.directive("dumbPassword", function () {
var validElement = angular.element('<div>{{ model.input }}</div>');
var link = function (scope) {
scope.$watch("model.input", function (value) {
if(value === "password") {
validElement.toggleClass("alert-box alert");
}
@francoisblarel
francoisblarel / gist:6917050
Created October 10, 2013 11:41
Method-overloading in javascript (from "Secrets of the Javascript ninja" book)
function addMethod(object, name, fn) {
var old = object[name];
object[name] = function(){
if (fn.length == arguments.length)
return fn.apply(this, arguments)
else if (typeof old == 'function')
return old.apply(this, arguments);
};
}
@francoisblarel
francoisblarel / test my javascript.html
Last active December 21, 2015 10:39
page permettant de faire des assertions en javascript. (tiré de Secret of the Javascript Ninja)
<html>
<head>
<title>Test Suite</title>
<script>
(function() {
var results;
this.assert = function assert(value, desc) {
var li = document.createElement("li");
li.className = value ? "pass" : "fail";
li.appendChild(document.createTextNode(desc));
val firstOccurence: Future[Int] = future {
val source = scala.io.Source.fromFile("public/myText.txt")
source.toSeq.indexOfSlice("tata")
}
firstOccurence.onComplete{
case Success(intVal) => println("future. first occur :" + intVal)
case Failure(t) => t.getMessage
}
@francoisblarel
francoisblarel / authenticationModule.scala
Created June 20, 2013 15:07
Exemple de petit module d'authentication simple et fonctionnel
/**
* Trait décrivant l'action protègée'
**/
import play.api.mvc._
import play.api.mvc.AnyContent
import play.api.mvc.Result
import play.api.mvc.Security._
/**
* User: fblarel