Skip to content

Instantly share code, notes, and snippets.

@Vp3n
Vp3n / gist:8744248
Created January 31, 2014 22:08
AngularJS: route resolve
angular.module('App', ['ngRoute'])
.run(function(repositories) {
//ensure that request is sent on application start, you could also
//call load() on route.resolve() depending on your needs
repositories.load();
})
.config(function($routeProvider) {
$routeProvider
.when('/', {
resolve: {
@Vp3n
Vp3n / DatabaseWebTest.php
Last active October 7, 2020 12:27
Symfony2 helper class to handle EntityManager transaction between tests.
<?php
namespace MyBundle\TestBundle\Lib;
use Doctrine\ORM\EntityManager;
use \Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* Helper class to help manager transaction for each test,
* database needs to be initialized once before whole test suite
@Vp3n
Vp3n / gist:5472469
Last active December 16, 2015 17:41
Custom symfony2 bootstrap with database init.
<?php
// app/test.bootstrap.php
if (isset($_ENV['BOOTSTRAP_CLEAR_CACHE_ENV'])) {
passthru(sprintf(
'php "%s/console" cache:clear --env=%s --no-warmup',
__DIR__,
$_ENV['BOOTSTRAP_CLEAR_CACHE_ENV']
));
}
@Vp3n
Vp3n / gist:5340950
Last active December 15, 2015 23:29
Handle CORS (Cross-Origin Resource Sharing) requests from any Java web application
<!-- pom.xml, adding required dependency-->
<dependencies>
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
@Vp3n
Vp3n / gist:5340891
Created April 8, 2013 21:55
Allowing CORS (Cross-Origin Resource Sharing) requests from grunt server
//Allowing CORS (Cross-Origin Resource Sharing) requests from
// grunt server, put this into Gruntfile.js
grunt.initConfig({
connect: {
livereload: {
options: {
port: 9000,
hostname: 'localhost',
middleware: function (connect) {
return [
@Vp3n
Vp3n / min.py
Created August 30, 2012 15:59 — forked from eoinmcg/min.py
Handy utility for @js13kGames, zip your files and keep track of file size
#!/usr/bin/python
# Simple python script that takes a html file extracts all scripts and concatenates them into
# a single file. The concatenated script is then sent to the google closure compiler for further
# squishing.
# Finally a game.zip archive is created with all specified files. The size of this archive
# is printed to standard output
#
# Usage:
# In the terminal type:
@Vp3n
Vp3n / uri.js
Created July 14, 2012 16:34 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@Vp3n
Vp3n / gist:1685489
Created January 26, 2012 22:22
playComponent - layout
<!DOCTYPE html>
<html>
<head>
<title>#{get 'title' /}</title>
<meta charset="${_response_encoding}">
<link rel="stylesheet" media="screen" href="@{'/public/stylesheets/main.css'}">
#{get 'moreStyles' /}
<link rel="shortcut icon" type="image/png" href="@{'/public/images/favicon.png'}">
<script src="@{'/public/javascripts/jquery-1.5.2.min.js'}" type="text/javascript" charset="${_response_encoding}"></script>
@Vp3n
Vp3n / gist:1685481
Created January 26, 2012 22:21
playComponent - custom tag
package tags;
import groovy.lang.Closure;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import models.MenuItem;
@Vp3n
Vp3n / gist:1685473
Created January 26, 2012 22:20
playComponent menuTag
#{if !menuItems.isEmpty()}
<ul>
#{list items:menuItems, as: 'item'}
<li>${item.name}</li>
#{/list}
</ul>
#{/if}