Skip to content

Instantly share code, notes, and snippets.

@Alos
Alos / my-element.html
Last active February 25, 2016 15:27
Polymer Behaviour Question
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-selector/iron-selectable.html">
<dom-module id="my-element">
<template>
<style>
:host {
display: block;
}
</style>
@Alos
Alos / app.js
Last active August 29, 2015 14:11
var app = angular.module('Myapp' [
])
.factory ('Foo' , function(MyServiceThatUsesHTTP){
var userDetails = {};
userDetails.setToken(aToken){
this.token = aToken;
}
@Alos
Alos / Dog.java
Last active August 29, 2015 13:56
Filter list in Java using Google Guava
package com.alos;
public class Dog {
private String name;
public Dog(String aName) {
this.name = aName;
}
public String getName() {
var sexLabel = [[CPTextField alloc] initWithFrame: CGRectMake(40, 430, 100, 30)];
[sexLabel setStringValue:"Sex:"];
[sexLabel setTextColor: [CPColor colorWithHexString:"FFFFFF"]];
[sexLabel sizeToFit];
[self addSubview:sexLabel];
maleRadioButton = [CPRadio radioWithTitle: "Male"];
femaleRadioButton = [CPRadio radioWithTitle: "Female"];
otherRadioButton = [CPRadio radioWithTitle: "Other"];
- (BOOL)tabView:(CPTabView)tabView shouldSelectTabViewItem:(CPTabViewItem )tabViewItem{
if([tabViewItem identifier] == "AddCharacterTabViewItem"){
tabCounter ++;
CPLog.trace("Tabview was add character, returning no");
var newCharacterSheetView = [[CharacterSheetView alloc] initWithFrame:CPRectMakeZero()];
var newCharacterViewTab = [[CPTabViewItem alloc] initWithIdentifier: tabCounter];
[newCharacterViewTab setLabel: @"New Character"];
[newCharacterViewTab setView: newCharacterSheetView];
[characterTabs insertTabViewItem: newCharacterViewTab atIndex: tabCounter];
@Alos
Alos / FilteredItemListView.js
Created April 28, 2013 03:18
Trying to refresh a view when the collection changes.
window.FilteredItemListView = Backbone.View.extend({
initialize : function(options) {
console.log("Initializing filtered item list view");
this.collection = options.itemCollection;
this.filter = options.filter;
this.collection.bind("reset", this.render, this);
this.render();
},
@implementation MyTabPrototype : TNTabItemPrototype {
}
+ (void)initialize{
TNTabViewTabButtonColorNormal = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:[
[[CPImage alloc] initWithContentsOfFile:@"Resources/tabitem-normal-leftx.png" size:CPSizeMake(9, 22)],
NSError *error;
audioPlayer = [[[AVAudioPlayer alloc] initWithContentsOfURL:audioFileURL error: &error] autorelease];
audioPlayer.numberOfLoops = -1;
audioPlayer.delegate = self;
audioPlayer.volume = 1.0;
if (audioPlayer == nil)
NSLog(@"%@", [error description]);
else
{
BOOL ready = [audioPlayer prepareToPlay];
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"Touched page 1!");
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: self];
CGRect previousButtonFrame = [previousButton frame];
NSLog(@" %f, %f", location.x, location.y);
-(void) slideView:(UIView *)uiv_slide toReveal:(UIView *)uiv_reveal withDuration:(double)d_duration {
//Bring the view to slide to the front
[self.view bringSubviewToFront:uiv_slide];
//Add the subview to the ViewController's view
[self.view addSubview:uiv_reveal];
//Make an animation to slide the view off the screen
[UIView animateWithDuration:d_duration