Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthieu Guillermin mguillermin

  • Swappie
  • Helsinki, Finlande
View GitHub Profile
View build.sbt
name := "testRequireJs"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache
)
View gist:7579074
[color]
status = auto
branch = auto
interactive = auto
diff = auto
[alias]
co = checkout
br = branch
ci = commit
st = status
View test.php
$ php -r "echo htmlentities(htmlspecialchars('œ … ’'));"
œ … ’
$ php test.php
œ … ’
@mguillermin
mguillermin / ImplicitSenderTest.scala
Last active Feb 5, 2021
Sample showing basic usage of Akka TestKit and TestActorRef
View ImplicitSenderTest.scala
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
Submitting Ajax POST with PlayFramework 2.x and the Javascript Router
View generated_jsRoutes.js
...
_nS('controllers.admin.Products'); _root.controllers.admin.Products.search =
function() {
return _wA({method:"POST", url:"/" + "admin/product/search"})
}
...
@mguillermin
mguillermin / Application.scala
Last active Dec 16, 2015
Code samples play2-elasticsearch
View Application.scala
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 Oct 22, 2012
PlayFramework 2.0 Ebean Test with YAML data
View Company.java
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 Apr 3, 2012
Exemple de hook_module_implements_alter() dans Drupal 7
View my_module.module
<?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 Mar 21, 2012
Drupal - Utiliser Workbench pour filtrer les menus dispos lors de la création de contenu
View gist:2145559
<?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 Mar 21, 2012
Play 2.0 Template inclusion with "backed" logic
View Menu.java
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);