Skip to content

Instantly share code, notes, and snippets.

View mailopl's full-sized avatar

Marcin Wawrzyniak mailopl

View GitHub Profile
@mailopl
mailopl / gist:3743496
Created September 18, 2012 14:41
In the framework jungle: CakePHP Basic Model
class User extends AppModel {
public $validate = array(
'email' => array(
'isUnique' => array(
'rule' => 'isUnique',
'message' => 'This email is already used.'
),
'email' => array(
'rule' => 'email',
@mailopl
mailopl / gist:3746684
Created September 18, 2012 23:21
In the framework jungle: Laravel Basic Model
class User extends Eloquent {
public $rules = array(
'email' => 'required|email|unique:users',
'password' => 'between:8,50'
);
public function posts()
{
return $this->has_many('Post');
}
@mailopl
mailopl / gist:3746749
Created September 18, 2012 23:40
In the framework jungle: Yii Basic Model
class User extends CActiveRecord {
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function relations()
{
return array(
@mailopl
mailopl / codility_profit
Created March 19, 2013 11:38
Some codility task I solved
<?php
function maxProfit($A) {
$maxProfit = 0;
for ($P = 0, $N = count($A); $P < $N; ++$P) {
for ($Q = $P; $Q < $N; ++$Q) {
if (
$A[$Q] >= $A[$P] &&
$A[$Q] - $A[$P] > $maxProfit
) {
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
test
var ipc = ipc || {};
// Step 1: Maintain BC with ipc.adtech
ipc.adloader = ipc.adtech = function () {
/**
* DFP acount ID
*/
var _dfp_account_id = '',
@mailopl
mailopl / jq_disqus_onscroll.js
Created November 15, 2013 12:29
Loads Disqus when scrolled down to disqus div.
/*
|---------------------------------------------------------------------------------------
| This function disqus when you scroll down to disqus div.
|
| @author Marcin Wawrzyniak
|---------------------------------------------------------------------------------------
*/
(function($){
var loadDisqus = function() {
[echo] Regenerating CSS files from scss using Compass
/var/lib/jenkins/workspace/ipc-sites-trustedreviews-frontend-sf2/ipc-sites-trustedreviews-frontend-sf2
directory ../src/Ipc/TrBundle/Resources/public/generated-css/
directory ../src/Ipc/TrBundle/Resources/public/generated-css/pages/
error bootstrap.scss (Line 5: File to import not found or unreadable: sass-bootstrap/sass/variables.
Load paths:
/var/lib/jenkins/workspace/ipc-sites-trustedreviews-frontend-sf2/ipc-sites-trustedreviews-frontend-sf2/src/Ipc/TrBundle/Resources/public/compass
/opt/ipc/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/blueprint/stylesheets
/opt/ipc/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets
function FastClick(b){var c,a=this;this.trackingClick=false;this.trackingClickStart=0;this.targetElement=null;this.touchStartX=0;this.touchStartY=0;this.lastTouchIdentifier=0;this.touchBoundary=10;this.layer=b;if(!b||!b.nodeType){throw new TypeError("Layer must be a document node");}this.onClick=function(){return FastClick.prototype.onClick.apply(a,arguments);};this.onMouse=function(){return FastClick.prototype.onMouse.apply(a,arguments);};this.onTouchStart=function(){return FastClick.prototype.onTouchStart.apply(a,arguments);};this.onTouchMove=function(){return FastClick.prototype.onTouchMove.apply(a,arguments);};this.onTouchEnd=function(){return FastClick.prototype.onTouchEnd.apply(a,arguments);};this.onTouchCancel=function(){return FastClick.prototype.onTouchCancel.apply(a,arguments);};if(FastClick.notNeeded(b)){return;}if(this.deviceIsAndroid){b.addEventListener("mouseover",this.onMouse,true);b.addEventListener("mousedown",this.onMouse,true);b.addEventListener("mouseup",this.onMouse,true);}b.addEventListe