Skip to content

Instantly share code, notes, and snippets.

View biancarosa's full-sized avatar
💜

bianca rosa biancarosa

💜
View GitHub Profile
@biancarosa
biancarosa / Foo.java
Last active August 29, 2015 14:05
Java public inner class
public class Foo {
Foo() {
System.out.println("Creating foo...");
}
//Public inner class
public class Bar {
Bar() {
System.out.println("Creating bar...");
@biancarosa
biancarosa / Application.java
Last active August 29, 2015 14:05
Application that uses Bar
class Application {
public void do() {
Foo foo = new Foo();
Foo.Bar bar = foo.new Bar();
}
}
@biancarosa
biancarosa / Application.groovy
Created August 27, 2014 18:53
Groovy Application that uses Bar
class Application {
public void do() {
def foo = new Foo();
def bar = new Bar(foo);
}
}
@biancarosa
biancarosa / domainsAndInterfaces.groovy
Last active August 29, 2015 14:24
Implementing interfaces on Grails Domains
interface Buyable {
def buy()
}
class UpperClass {}
class ChildClass extends UpperClass {}
class SomeBuyableObject extends UpperClass implements Buyable {
String foo
def buy() { //do stuff }
@biancarosa
biancarosa / MyPluginGrailsPlugin.groovy
Last active October 15, 2015 22:50
MyPluginGrailsPlugin
import grails.util.Environment
class MyGrailsPlugin {
/* plugin definitions */
def doWithSpring = {
loadPluginConfig(application.config)
}
/**
@biancarosa
biancarosa / bootstrap4-element-modifier.js
Last active May 11, 2016 18:57
For anyone using jcs-auto-validate and bs4
'use strict';
angular.module('myModule', [])
.factory('bootstrap4ElementModifier', ['$log', function($log) {
var customCss = [
'<style>' +
'.glyphicon-spin-jcs {' +
'-webkit-animation: spin 1000ms infinite linear;' +
'animation: spin 1000ms infinite linear;' +
'}' +
mockedFactory = {
getString: jasmine.createSpy()
};
$provide.value('gettextCatalog', mockedFactory);
'use strict';
/* https://github.com/angular/protractor/blob/master/docs/toc.md */
describe('my app', function() {
it('should automatically redirect to /sign-up when location hash/fragment is empty', function() {
browser.get('index.html');
expect(browser.getLocationAbsUrl()).toMatch("/sign-in");
});
@biancarosa
biancarosa / app.py
Created September 24, 2016 14:08
Falcon sample app (2 resources)
# app.py
import falcon
import json
class SongsResource:
def on_get(self, req, resp):
songs = [
{
"title": "Your Song", "artist": "Elton John"
@biancarosa
biancarosa / auth.py
Created September 24, 2016 14:44
Falcon example hook
# hooks/auth.py
import falcon
from api.models.user_token import UserToken
def authorize():
def hook(req, resp, resource, params):
token = req.context.get('token')
if token is None:
description = ('Please provide an auth token as part of the request.')
raise falcon.HTTPUnauthorized('Auth token required', 'Auth token required', description, href='http://docs.example.com/auth')