Skip to content

Instantly share code, notes, and snippets.

View tcarlsen's full-sized avatar

Thomas Carlsen tcarlsen

  • Ekstra Bladet
  • Copenhagen, Denmark
View GitHub Profile
Controller: save()
if ($this->OpinionPoll->saveAll($this->data, array('validate' => 'first'))) {
$this->OpinionPoll->OpinionPollEntry->OpinionPollParty->saveAll($this->data['OpinionPollParty'], array('validate' => 'first'));
$this->redirect('/opinion_polls/view_poll/'.$this->OpinionPoll->id);
} else {
$this->Session->write('applicantdata',$this->data);
$this->redirect('/opinion_polls/add_poll/error');
}
Model: OpinionPoll
@tcarlsen
tcarlsen / jQuery.beforeafter.js
Created May 17, 2011 10:30
modified by TCarlsen to work whit jQuery UI Touch Punch
/*
* jQuery beforeafter plugin
* @author admin@catchmyfame.com - http://www.catchmyfame.com
* @version 1.2
* @date October 18, 2010
* @category jQuery plugin
* @copyright (c) 2009 admin@catchmyfame.com (www.catchmyfame.com)
* @license CC Attribution-NoDerivs 3.0 Unported - http://creativecommons.org/licenses/by-nc-sa/3.0/
*/
// before image : $('div:eq(2)', obj)
stop
2011-02-21 19:31:01 [INFO] CONSOLE: Stopping the server..
2011-02-21 19:31:01 [INFO] Stopping server
2011-02-21 19:31:01 [INFO] Saving chunks
function checkEmail($email) {
// checks proper syntax
if(preg_match("/^([a-z])([a-z0-9._])+([a-z0-9])\@([a-z0-9])*([a-z])+(-[a-z])*([a-z0-9])*(\.([a-z0-9])*([a-z])+(-[a-z])*([a-z0-9])*)+$/i" , $email)) {
// gets domain name
list($username,$domain)=split('@',$email);
// checks for if MX records in the DNS
if(!checkdnsrr($domain, 'MX')) {
return false;
}
// attempts a socket connection to mail server
$statusWords = explode(" ",$data['text']);
foreach ($statusWords as $word) {
if (substr($word,0,1) == "@") {
$newWord = '@<a href="#">'.substr($word,1).'</a>';
$data['text'] = str_replace($word,$newWord,$data['text']);
}
}
<?php
class DownloaderComponent extends Object {
function download_file($file) {
$basename = basename($file);
$file_extension = strtolower(substr(strrchr($basename,"."),1));
switch($file_extension)
{
case "PLS": $ctype="audio/x-scpls"; break;
case "pls": $ctype="audio/x-scpls"; break;
http://adtech.panthercustomer.com/apps/17/Ad2867729St3Sz170Sq4044125V0Id3/300x250_lokalguidedk_s_gbla.swf?targetTAG=_blank&clickTarget=_blank&pathTAG=http%3A//adtech.panthercustomer.com/apps/17/Ad2867729St3Sz170Sq4044125V0Id3/&closeTAG=javascript%3AcloseAdLayer2182707%28%29&openTAG=javascript%3AopenAdLayer2182707%28%29&expandTAG=javascript%3Aexpand2182707%28%29&collapseTAG=javascript%3Acollapse2182707%28%29&clicktarget=_blank&clickTarget=_blank&clickTARGET=_blank&CURRENTDOMAIN=www.berlingske.dk
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.yourcompanydomain.com" />
</cross-domain-policy>
Array
(
[0] => Array
(
[created_at] => Fri Feb 19 09:23:49 +0000 2010
[id] => 9327647067
[text] => Uffe om doku-fiktion og farcen #lækagesag http://www.berlingske.dk/kommentarer/den-store-taber-i-laekage-sagen-pressen
[source] => TweetDeck
[truncated] => false
[InReplyToStatusId] => Array
$statuses1 = $this->Twitter->statusesUserTimeline("TCarlsen",NULL,NULL,5);
$statuses2 = $this->Twitter->statusesUserTimeline("kfriis",NULL,NULL,5);
$statuses = array_merge_recursive($statuses1,$statuses2);
$result = Set::sort($statuses, 'Statuses.Status.{n}.id', 'desc');
$this->set('statuses',$result);