Skip to content

Instantly share code, notes, and snippets.

/**
* Created by pedrofurla on 26/03/14.
*/
package slicks.docs
import slicks.docs.dao.{Entity, IdentifiableTable, CrudComponent, Profile}
case class User(id: Option[Long], first: String, last: String) extends Entity[Long]
trait UserComponent extends CrudComponent { outer: Profile =>
@kentcdodds
kentcdodds / JavaScript.xml
Created August 3, 2015 13:32
Some of my WebStorm live templates
<templateSet group="JavaScript">
<template name="us" value="'use strict';&#10;$END$" description="Inserts 'use strict' statement" toReformat="true" toShortenFQNames="true">
<context />
</template>
<template name="f" value="function $NAME$($PARAM$) {&#10; $END$&#10;}" description="Inserts function expression" toReformat="true" toShortenFQNames="true">
<variable name="NAME" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="PARAM" expression="" defaultValue="&quot;&quot;" alwaysStopAt="true" />
<context>
<option name="JAVA_SCRIPT" value="true" />
</context>
@timaschew
timaschew / doctrine-non-pk-fk-patch.php
Created September 28, 2012 14:16
patch file for using foreign keys to non pk reference (only for ManyToOne)
diff --git a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
index d73983c..9f8a253 100644
--- a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
+++ b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
@@ -598,10 +598,18 @@ class BasicEntityPersister
$quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class, $this->_platform);
$this->quotedColumns[$sourceColumn] = $quotedColumn;
-
- if ($newVal === null) {
@eperedo
eperedo / app.js
Created June 5, 2013 20:50
AngularJs Directive for ladda buttons - https://github.com/hakimel/Ladda
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $timeout) {
$scope.save = function(){
$scope.loading = true;
$timeout(function(){
$scope.loading = false;
}, 3000);
};
#!/bin/bash
excludedprocesses=(somethingidontwant:something_instance-0 somethingelse)
for f in `supervisorctl status | awk '{print $1}' `; do
echo "found $f"
if [[ ${excludedprocesses[*]} =~ $f ]]
then
echo "Exluding $f as a restart candidate"
@adamalex
adamalex / .ebextensions--eb.config
Created October 28, 2013 00:01
Config and CI script for automated Node.js 0.10.10 project deployment—including grunt—to Elastic Beanstalk
packages:
yum:
git: []
gcc: []
make: []
openssl-devel: []
commands:
00-add-home-variable:
command: sed -i 's/function error_exit/export HOME=\/root\n\nfunction error_exit/' /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh
container_commands:
@wowo
wowo / Mockery way to mock Doctrine2 Entity Manager.php
Created November 1, 2011 20:24
Mockery's way to mock Doctrine2 Entity Manager
<?php
class AbstractManagerBase extends \PHPUnit_Framework_TestCase
{
protected function getEmMock()
{
$emMock = \Mockery::mock('\Doctrine\ORM\EntityManager',
array(
'getRepository' => new FakeRepository(),
'getClassMetadata' => (object)array('name' => 'aClass'),
@casualjim
casualjim / session_token_strategy.scala
Last active December 8, 2017 13:56
Session token strategy example for scalatra auth (scentry)
package org.example
package auth
import org.scalatra.auth.ScentryStrategy
import org.scalatra.{CookieSupport, ScalatraBase}
trait RedisClient {
def get(key: String): Option[String]
}
@sap1ens
sap1ens / build.sbt
Created February 22, 2014 01:22
Custom sbt-assembly merge strategy (fixes for spring, cglib, mockito)
val customMergeStrategy: String => MergeStrategy = {
case x if Assembly.isConfigFile(x) =>
MergeStrategy.concat
case PathList(ps @ _*) if Assembly.isReadme(ps.last) || Assembly.isLicenseFile(ps.last) =>
MergeStrategy.rename
case PathList("META-INF", xs @ _*) =>
(xs map {_.toLowerCase}) match {
case ("manifest.mf" :: Nil) | ("index.list" :: Nil) | ("dependencies" :: Nil) =>
MergeStrategy.discard
case ps @ (x :: xs) if ps.last.endsWith(".sf") || ps.last.endsWith(".dsa") =>
@andrewmclagan
andrewmclagan / Normalizr.php
Last active August 3, 2018 22:21
Normalized fractal response
<?php
namespace App\Http;
use League\Fractal\Pagination\CursorInterface;
use League\Fractal\Pagination\PaginatorInterface;
use League\Fractal\Resource\ResourceInterface;
use League\Fractal\Serializer\ArraySerializer;
class Normalizr extends ArraySerializer