This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class Blog_model extends CI_Model { | |
function __construct() { | |
parent::__construct(); | |
//var_dump(get_instance()); exit; | |
// $CI = get_instance(); | |
// $CI->load->database(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load live.js on local envs only | |
// Make sure the path is right and your dev env passes the test. | |
/* Delete these characters to disable it temporarily -> */ | |
(function() { | |
if(/^https?:\/\/(localhost|127.0.0.1|(dev|test).*?)\/|^file:\/\/\//.test(document.location.href)) { | |
var live = document.createElement('script'); | |
live.src = 'js/live.js'; | |
var s = document.getElementsByTagName('script')[0]; | |
s.parentNode.insertBefore(live, s); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
/ Created while using the Last.FM API. | |
/ The Last.FM API is split into sections. Artists, Album, Track etc. | |
/ The method names are for example "artists.getTopTracks". If I'm using magic method __call | |
/ and calling artistsGetTopTracks, I can then split the call down into the section and method with the following regex | |
/ which can then be used to construct API call URL | |
*/ | |
preg_match_all('/^[a-z]*|[A-Z]\w*/', $candidate, $results); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("input, textarea").focus(function(){ | |
if ($(this).val() == $(this).attr("title")) { | |
$(this).val(""); | |
} | |
}).blur(function () { | |
if ($(this).val() == "") { | |
$(this).val($(this).attr("title")); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace TABLE and COLUMN as appropriate | |
Update TABLE Set COLUMN = Replace(COLUMN, CHAR(3), ''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Assuming you have an SQL file (or string) you want to run as part of the migration, which has a number of statements... | |
CI migration only allows you to run one statement at a time. If the SQL is generated, it's annoying to split it up and create separate statements. | |
This small script splits the statements allowing you to run them all in one go. | |
*/ | |
$sqls = explode(';', $sql); | |
array_pop($sqls); | |
foreach($sqls as $statement){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Robot = function(robot){ | |
robot.turnLeft(robot.angle % 90); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
if (robot.parentId) { | |
robot.ahead(1); | |
robot.turnGunRight(1); | |
} | |
else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Robot = function(robot){ | |
robot.turnLeft(robot.angle % 90); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
if (robot.parentId) { | |
robot.ahead(1); | |
robot.turnGunRight(1); | |
} | |
else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CheckTest_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage{ | |
public function saveTestCheck($data){ | |
//echo 'lalala';exit; | |
if (empty($data)) { | |
return array('error' => -1, 'message' => $this->_helper->__('Invalid data.')); | |
} | |
$this->getQuote()->setTestCheckLike($data['like']); | |
$this->getQuote()->collectTotals(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//if your query is raw sql you created, each mysql key word must be on a new line for this to work | |
$last_query = $this->db->last_query(); | |
$pattern = '/(.*)Limit (.*)/i'; | |
$new_query = preg_replace ($pattern, '', $last_query); | |
$pattern = '/(.*)Select *(.*)/i'; | |
$new_query = preg_replace ($pattern, 'SELECT \'\'', $new_query); | |
$new_query = 'Select Count(*) AS res From (' . $new_query . ') v__dynamic;'; |
OlderNewer