Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthieu Guillermin mguillermin

  • Swappie
  • Helsinki, Finlande
View GitHub Profile
View CI_Task_ConfigureDistTask.class.php
<?php
/**
* Replaces tokens in distribution files.
*/
class CI_Task_ConfigureDistTask extends sfBaseTask
{
/**
* @see sfTask
*/
View BasicTest.java
@Test
public void save() {
running(fakeApplication(), new Runnable() {
public void run() {
// Here is your real test code
Company company = new Company("My Company");
company.save();
assertThat(company.id).isNotNull();
}
});
View BaseModelTest.java
public class BaseModelTest {
public static FakeApplication app;
@BeforeClass
public static void startApp() {
app = Helpers.fakeApplication(Helpers.inMemoryDatabase());
Helpers.start(app);
}
@AfterClass
View BaseModelTest.java
public class BaseModelTest {
public static FakeApplication app;
public static String createDdl = "";
public static String dropDdl = "";
@BeforeClass
public static void startApp() throws IOException {
app = Helpers.fakeApplication(Helpers.inMemoryDatabase());
Helpers.start(app);
@mguillermin
mguillermin / Application.java
Created Mar 14, 2012
Play 2.0 Java Controller Sample
View Application.java
public class Application extends Controller {
public static Result testText() {
return ok("Hello world !");
}
public static Result testTemplate() {
return ok(index.render("Your new application is ready."));
}
@mguillermin
mguillermin / index.scala.html
Created Mar 14, 2012
Play 2.0 Scala Template Sample
View index.scala.html
@(user: User, links : List[link])
@main("User links") {
<p>Welcome @user.name !</p>
<ul>
@for(link <- links) {
<li><a href="@link.url">@link.title</a></li>
}
</ul>
}
@mguillermin
mguillermin / Company.java
Created Mar 14, 2012
Play 2.0 Ebean Sample
View Company.java
@Entity
public class Company extends Model {
@Id
public Long id;
@Constraints.Required
public String name;
public Company(String name) {
@mguillermin
mguillermin / User.scala
Created Mar 14, 2012
Play 2.0 Anorm Sample
View User.scala
case class User(email: String, name: String, password: String)
object User {
// -- Parsers
/**
* Parse a User from a ResultSet
*/
val simple = {
@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);
@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) {