Skip to content

Instantly share code, notes, and snippets.

View mguillermin's full-sized avatar

Matthieu Guillermin mguillermin

  • Swappie
  • Helsinki, Finlande
View GitHub Profile
name := "testRequireJs"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache
)
@mguillermin
mguillermin / gist:7579074
Created November 21, 2013 10:07
.gitconfig
[color]
status = auto
branch = auto
interactive = auto
diff = auto
[alias]
co = checkout
br = branch
ci = commit
st = status
$ php -r "echo htmlentities(htmlspecialchars('œ … ’'));"
œ … ’
$ php test.php
œ … ’
@mguillermin
mguillermin / ImplicitSenderTest.scala
Last active February 5, 2021 07:47
Sample showing basic usage of Akka TestKit and TestActorRef
package sample.akka.testkit
import akka.actor.ActorSystem
import akka.actor.Actor
import akka.testkit.{TestKit, TestActorRef}
import org.scalatest.matchers.MustMatchers
import org.scalatest.WordSpec
class ImplicitSenderTest extends TestKit(ActorSystem("testSystem"))
// Using the ImplicitSender trait will automatically set `testActor` as the sender
@mguillermin
mguillermin / generated_jsRoutes.js
Last active May 24, 2016 21:57
Submitting Ajax POST with PlayFramework 2.x and the Javascript Router
...
_nS('controllers.admin.Products'); _root.controllers.admin.Products.search =
function() {
return _wA({method:"POST", url:"/" + "admin/product/search"})
}
...
@mguillermin
mguillermin / Application.scala
Last active December 16, 2015 05:48
Code samples play2-elasticsearch
object Application extends Controller {
def async = Action {
IndexTestManager.index(IndexTest("1", "Here is the first name", "First category"))
IndexTestManager.index(IndexTest("2", "Then comes the second name", "First category"))
IndexTestManager.index(IndexTest("3", "Here is the third name", "Second category"))
IndexTestManager.index(IndexTest("4", "Finnaly is the fourth name", "Second category"))
IndexTestManager.refresh()
val indexQuery = IndexTestManager.query
@mguillermin
mguillermin / Company.java
Created October 22, 2012 07:47
PlayFramework 2.0 Ebean Test with YAML data
package models;
@Entity
public class Company extends Model {
@Id
public Long id;
public String name;
public static Finder<Long, Company> find = new Finder<Long, Company>(Long.class, Company.class);
@mguillermin
mguillermin / my_module.module
Created April 3, 2012 09:08
Exemple de hook_module_implements_alter() dans Drupal 7
<?php
function my_module_module_implements_alter(&$implementations, $hook) {
switch ($hook) {
case 'form_alter':
if (array_key_exists('my_module', $implementations)) {
// On veut que le hook_form_alter my_module soit le dernier exécuté
// On le remet à la fin du tableau
$my_module = $implementations['my_module'];
unset($implementations['my_module']);
@mguillermin
mguillermin / gist:2145559
Created March 21, 2012 08:13
Drupal - Utiliser Workbench pour filtrer les menus dispos lors de la création de contenu
<?php
function my_module_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'page_node_form' && !user_access('administer content')) {
// Alter node edit form
$menu_items = $form['menu']['link']['parent']['#options'];
$menu_items_to_delete = array();
$workbench_access_menus = workbench_access_get_user_tree();
foreach ($menu_items as $menu_key => $menu_value) {
$ok = false;
foreach ($workbench_access_menus as $id => $workbench_access_menu) {
@mguillermin
mguillermin / Menu.java
Created March 21, 2012 06:32
Play 2.0 Template inclusion with "backed" logic
package controllers;
import play.api.templates.Html;
import models.MenuItem;
public class Menu {
public static Html render(String parent) {
List<MenuItem> menuItems = MenuItem.findByParent(parent);
// more business logic...
return views.html.menu.render(menuItems);