Skip to content

Instantly share code, notes, and snippets.

View mt3o's full-sized avatar

Teodor Kulej mt3o

View GitHub Profile
@mt3o
mt3o / gist:5476695
Created April 28, 2013 12:05
Attach event before and after class change with jquery
(function(){
// Your base, I'm in it!
var originalAddClassMethod = jQuery.fn.addClass;
jQuery.fn.addClass = function(){
jQuery(this).trigger('beforeCssClassChanged');
var result = originalAddClassMethod.apply( this, arguments );
jQuery(this).trigger('afterCssClassChanged');
@mt3o
mt3o / observers.php
Created June 27, 2013 10:52
Observers in PHP with SPL
<?php
class MyObserver implements SplObserver {
public function update(SplSubject $subject) {
echo __CLASS__ . ' - ' . $subject->getName();
}
}
class MySubject implements SplSubject {
private $_observers;
@mt3o
mt3o / cenny 1.html
Last active December 23, 2015 23:49
<script src='http://loadfive.com/cenny.js'></script>
@mt3o
mt3o / cenny 2.js
Last active December 23, 2015 23:49
var fresh = new Cenny();
@mt3o
mt3o / cenny 3.js
Last active December 23, 2015 23:49
var data = "hello world!";
fresh.save(data, 3); //zapis, 3 jest indeksem pod którym chowany dane
fresh.get(3, function(wynik) { //odczyt danych spod indeksu 3
alert(wynik);
} );
fresh.clear(3); //usunięcie danych spod indeksu
@mt3o
mt3o / cenny 4.js
Last active December 23, 2015 23:49
var fresh = new Cenny();
fresh.auth({user: 'ben', pass: 'cenny'}); //tworzenie nowego użytkownika
var data = "hello world!";
//save object to variable
var userInfo = {user: 'ben', pass: 'cenny'}; //token identyfikujący użytkownika
fresh.save(data, 3, userInfo); //token jako trzeci parametr
@mt3o
mt3o / rowspan-highlight.css
Created October 23, 2013 09:45
Podświetlanie wierszy i kolumn w bootstrap 2.3
.row, [class*=span]{
background: rgba(0,0,0,0.1);
outline: 1px solid rgba(0,0,0,0.1);
padding-top: 5px;
padding-bottom: 5px;
}
.row:hover, [class*=span]:hover{
outline: 1px solid rgba(0,0,0,0.3);
background: rgba(0,0,0,0.2);
}
@mt3o
mt3o / Angular-online-offline-switch.js
Created November 8, 2013 21:06
Sends event when online status is changed and switches between $http and localstorage
angular.module('myApp').run(function($rootScope) {
window.addEventListener("online", function () {
$rootScope.$broadcast('onlineChanged', true);
}, true);
window.addEventListener("offline", function () {
$rootScope.$broadcast('onlineChanged', false);
}, true);
});
@mt3o
mt3o / prerendered-angular-repeat.html
Created November 8, 2013 21:07
Angular ng-repeat with server side prerendering for seo, with template as separate element
<span ng-bind="variableValue">Static indexed value</span>
<ul ng-include="'your/dynamic/list'">
<li>seo-friendly item1</li>
<li>seo-friendly item2</li>
</ul>
<script type="text/ng-template" id="your/dynamic/list">
<li ng-repeat="item in items" ng-bind="item.name"></li>
</script>
<table>
<thead>
<tr>
<th>#</th>
<th>Tytuł</th>
<th>Opis</th>
</tr>
</thead>
<tbody>
<tr>