Skip to content

Instantly share code, notes, and snippets.

View BernhardPosselt's full-sized avatar

Bernhard Posselt BernhardPosselt

  • foryouandyourcustomers
  • Austria
View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
body {background-color: #fff; color: #222; font-family: sans-serif;}
pre {margin: 0; font-family: monospace;}
a:link {color: #009; text-decoration: none; background-color: #fff;}
a:hover {text-decoration: underline;}
table {border-collapse: collapse; border: 0; width: 934px; box-shadow: 1px 2px 3px #ccc;}
.center {text-align: center;}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<import>
<item type="Product">
<property name="europe1Prices">
<item type="PriceRow">
<property name="pdtType" val="gold"/>
<property name="price" val="$source['pricecolumnname']"/>
</item>
</property>
</item>
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title type="html">Demo feed</title>
<subtitle type="html">Strip out JS demo feed</subtitle>
<link rel="self" type="application/atom+xml" href="https://gist.github.com/cosenal/" />
<link rel="alternate" type="text/html" href="https://gist.github.com/"/>
<id>https://gist.github.com/</id>
<updated>2015-02-11T16:22:02+01:00</updated>
<entry>
<title type="html">Demo entry</title>
@BernhardPosselt
BernhardPosselt / app.css
Last active December 21, 2015 06:29
Edit fields like in GMail contacts: Hover over text to show input field and fire callback when it actually changed
editable:hover span {
display: none;
}
editable span.editing {
display: none;
}
editable input {
display: none;
@BernhardPosselt
BernhardPosselt / gist:5147194
Created March 12, 2013 21:26
simplified request with the appframework
var app = angular.module('Mail', ['OC']);
app.controller('MyController', ['$scope', 'Request', function($scope, Request){
$scope.doARequest = function(){
Request.get('mail_all');
}
}]);
@BernhardPosselt
BernhardPosselt / gist:5020760
Last active December 14, 2015 03:28
Simple controller
<?php
require __DIR__ . '/autoloader.php';
// without Pimple
$route = new Route();
$route->add('/blog/.+/.+', function($ownerId, $postId) {
$db = new PDOSomething('user', 'pass', 'db'); // instantiate db
$mapper = new BlogPostMapper($db);
$controller = new BlogPostController($mapper);
for(var i=0; i<10; i++){
$elem = $("<p>");
$elem.click(function(){
alert(i); // alerts 9 every time the element is being clicked
});
$(document).append($elem);
}
// solution
for(var i=0; i<10; i++){
function Promise(){
this.requestIsSuccess = false;
this.onSuccessCallback = false;
}
Promise.prototype.success = function(callback){
if(this.requestIsSuccess){
callback(this.data)
} else {
this.onSuccessCallback = callback;
@BernhardPosselt
BernhardPosselt / gist:4595335
Last active December 11, 2015 11:39
Pimple vs AngularJS dependency injection
<?php
// PHP pimple
$container = new Pimple();
$container['ActiveFeed'] = $container->share(function($c){
return new MyActiveFeed($c['MyModel'], $c['TestService']);
});
// angularjs
angular.module('News').factory 'ActiveFeed', ['MyModel', 'TestService', (MyModel, TestService)->
return new MyActiveFeed(MyModel, TestService)