tag:blogger.com,1999:blog-10616593979566326762024-02-19T00:11:50.102-08:00Tuts to rememberSome notes for me to remember, if you find anything helpful and want more info on it please let me knowAnonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-1061659397956632676.post-51676481480669290852014-02-10T04:54:00.002-08:002014-02-10T04:54:05.639-08:00How to use PHP Excel without php built in zip archive<span style="font-size: large;">"</span><b><span style="font-size: large;">Fatal error: </span></b>Class 'ZIPARCHIVE' not found<span style="font-size: large;">"</span><br />
<br />
I found myself in in the situation that I had to use PHPExcel to generate some graphs. Sounds easy enough, and it kind of is, but... after I develop locally on my machine running php 5.3 I face myself with the challenge that I have to install the code on a machine running php 5.1.2 (not suported by PHPExcel). I soon found out that the main problem is the fact that php 5.1 dose not have ZipArchive or PHPExcel_Shared_ZipArchive, you can install them but with a lot of headache and a lot of trying (more than 1 solutions available for more than 1 case) and to be honest, that solution was not the proper way to do it as this was a production server with a lot of stuff on it (you don't want to mess it up).<br />
Maybe a guru server admin could find a proper solution, but I am not that, I am a dev, so... I started researching to find a way to change to another lib that works on 5.1. And so I found... nothing!!! (at least after 2-3h of research and reading a lot of useless forum posts).<br />
As my search was not fruitful and time consuming and annoying I moved my atention to something I love but not like doing: hacking the code ( hacking the code of a maintained lib is not encouraged as this may lead to rough upgrades with lots of diffs etc. ).<br />
After a little more research and documentation I found pclzip as a php standalone lib <a href="http://www.phpconcept.net/pclzip/" target="_blank">here</a> and I found that PHPExcel has a very simple way of changing the ziping class in the settings.<br />
So this is what I have done:<br />
<br />
<ol>
<li>imported the pclzip lib</li>
<li>created a wrapper class for compatibility reasons (pclzip dose not have the function names implemented in the other to libs)</li>
<li>added my wrapper class as a ziping method in settings.php</li>
<li>forced PHPExcel to use my class for ziping</li>
</ol>
<div>
NOTICE: This was tested only for writing, so I have no ideea what will happen when reading, but that is the subject of another post.</div>
<div>
<br /></div>
<div>
Here is a short description of the code I created:</div>
<div>
<br /></div>
<div>
<pre class="brush: php">################################################
// pclzip.extended.php
################################################
include('pclzip.lib.php'); // PhpConcept Library - Zip Module 2.8.2 - http://www.phpconcept.net
class PCLZipExtended{
// just a place holder
function PCLZipExtended(){
}
private $zip;
private $temp_dir;
// implementation of function open
// this function needs to create the zip file
// pclzip dose not create the file untill any action is taken (create/append)
function open($pFilename,$zipCreate){
$this->zip = new PclZip($pFilename);
$this->zip->create(array());
return file_exists($pFilename);
}
// implementation of addFromString function
// needs to save the string to a local file and then append it to the archive
// keeping the paths is a ***ch
function addFromString($_location,$data){
$location=$this->tempdir().$_location;
if(!file_exists(dirname($location)))
mkdir(dirname($location), 0777, true);
file_put_contents($location,$data);
$loc_to_add = explode('/',$location);
array_shift ($loc_to_add);
array_pop ($loc_to_add);
$loc_to_add = implode('/',$loc_to_add);
$this->zip->add($location,$loc_to_add,dirname($location));
}
// we are done and we can clean up after our selfs
function close(){
// do cleanup
$this->rrmdir($this->tempdir());
}
// generate a temp dir to store the files needed for the zip
// or if we already done this return it
// and yes php 5.1 dose not have sys_get_temp_dir
private function tempdir($dir='') {
if(isset($temp_dir)) return $temp_dir;
$tempfile=tempnam($dir,'');
if (file_exists($tempfile)) { unlink($tempfile); }
mkdir($tempfile);
if (is_dir($tempfile)) { return $temp_dir=$tempfile.'/'; }
return false;
}
// recursive delete for php
private function rrmdir($dir='') {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") rmdir($dir."/".$object); else unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}
}
################################################
// PHPExcel: PHPExcel/PHPExcel/Settings.php
################################################
################
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
// line: 42 added just this
const PCLZIP_SOURCE = 'PCLZipExtended';
// line: 42 added just this
const ZIPARCHIVE = 'ZipArchive';
################
if (($zipClass === self::PCLZIP) ||
// line: 120 added just this
($zipClass === self::PCLZIP_SOURCE) ||
// line: 120 added just this
($zipClass === self::ZIPARCHIVE)) {
################
################################################
// Main php file that dose all the work
################################################
include('modules/ER_Reports/pclzip.extended.php');
include('modules/ER_Reports/PHPExcel/PHPExcel.php');
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP_SOURCE);
$er = new ER_Reports();
</pre>
<br /></div>
<div>
And that's all folks!!!! </div>
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-20090725455267516112013-10-29T02:05:00.001-07:002013-10-29T02:05:41.508-07:00WIndows: HOW TO move files in sequent foldersI was found not long ago in a situation where I had a large number of files in one folder that had to be moved in sequent folders (500 files in each folder). Here is the script I managed to make:<br />
<br />
<br />
<pre>echo off
SETLOCAL ENABLEDELAYEDEXPANSION
:: set this number eq to num
set movedFiles=500
:: the number of files in each folder
set num=500
:: location of files
set location=D:\files
:: destination of files
set destinbation=D:\files\
:: set the starting numbering for the subfolders
set /a sn=5
for %%G in ("!location!"\*) do (
if !movedFiles! EQU %num% (
set /a sn=sn+1
echo Creating !destinbation!!sn!
mkdir !destinbation!!sn!
set /a movedFiles=0
)
echo "%%G" "!destinbation!!sn!"
move /Y "%%G" "!destinbation!!sn!"
set /a movedFiles+=1
)
ENDLOCAL
</pre>Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-30951562992432427732013-07-26T00:54:00.000-07:002013-07-26T00:54:23.585-07:00Jquery is(':focus') is not working in IE8I recently encountered a problem when using the is(':focus') with ie8. The only error I got is<br />
<br />
<span style="font-size: x-small;"><i>SCRIPT5022: Exception thrown and not caught </i></span><br />
<span style="font-size: x-small;"><i>jquery.js, line 85 character 139</i></span><br />
<div>
<br /></div>
<div>
Not a lot of help.</div>
<div>
<br /></div>
<div>
After further research I found that there is actually a problem with how jQuery is handling this and I had to rewrite it.</div>
<div>
<br /></div>
<div>
<div>
<span style="font-size: x-small;"><i>jQuery.expr[':'].focus = function( elem ) {</i></span></div>
<div>
<span style="font-size: x-small;"><i> return elem === document.activeElement && ( elem.type || elem.href );</i></span></div>
<div>
<span style="font-size: x-small;"><i>};</i></span></div>
</div>
<div>
<span style="font-size: x-small;"><i><br /></i></span></div>
<div>
Quoted from Mathias Bynens <a href="http://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus/5391608#5391608" target="_blank">here</a>:</div>
<blockquote class="tr_bq">
Note that the (elem.type || elem.href) test was added to filter out false positives like body. This way, we make sure to filter out all elements except form controls and hyperlinks.</blockquote>
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-10307905869888631992013-02-27T07:32:00.001-08:002013-02-27T07:32:11.133-08:00Windows 7 Error "Explorer. exe No such interface supported"I got this error after I did a mass update of my windows, reaching from a clean installation to SP1. I messed around a lot on the internet but could not find a good solution, most of the final suggestions were "Back up your data and reinstall". But as I didn't wanted to do that (just thinking about all the softwear I have to reinstall gave me a headache ) I keept going until I found exactly what I needed.<br />
<br />
The process of fixing this is really easy if you know what you are doing, but I wasn't, so I will have to give credits to <span style="background-color: white; color: #7b7b7b; font-family: 'trebuchet ms', arial, sans-serif; font-size: 13px;">Jae Hyuk Lee </span>on his <a href="http://www.starrguide.com/2012/04/resolution-windows-7-error-exe-no-such.html#.US4k2zBJN8E" target="_blank">post</a>.<br />
<br />
I will rewrite the solution here to keep it for posterity and make it easy to search.<br />
<br />
1. open comand prompt as admin<br />
2. run <em style="background-color: white; color: #333333; font-family: 'trebuchet ms', arial, sans-serif; font-size: 13px; margin: 0px; padding: 0px;"><span style="font-size: medium; margin: 0px; padding: 0px;">regsvr32 c:\windows\system32\actxprxy.dll</span></em><br />
3. restart if neededAnonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-42570585152551769372012-10-29T14:02:00.001-07:002013-03-16T12:37:37.953-07:00Update Samsung GT-I5500 from CyanogenMod 7.2 to 9 (android 4.0)In a <a href="http://cuzztuts.blogspot.ro/2012/06/update-samsung-gt-i5500-from-22-to-237.html">previous post</a> I explained how to update your phone to to 2.3. Now you can update it to <b>4.0 (CyanogenMod 9)</b> !!!!<br />
Supposing you completed the prev steps in <a href="http://cuzztuts.blogspot.ro/2012/06/update-samsung-gt-i5500-from-22-to-237.html">this</a> post and you have Cyanogen 7.2 (or later) you will need this file: <a href="http://adf.ly/EAA1p" rel="nofollow" target="_blank">Cyanogen9</a> (<a href="http://adf.ly/KykZw" rel="nofollow" target="_blank">link on megaupload</a>)<br />
After downloading it redo <b>step 7</b> from the previous post and instead "<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif;">update-cm-7.2.0-RC0-galaxy5-v1.9-MADTEAM-signed</span>" use the zip downloaded. Just to keep it simple I will re-write the instructions:<br />
<br />
<span style="font-family: Verdana, Tahoma, Arial, Trebuchet MS, sans-serif, Georgia, Courier, Times New Roman, serif; font-size: x-small;"><i>Now we move on to installing packages. Go to "Mount and storage", then "Mount USB Storage". Copy files "cm-10-20121024-MADTEAM-galaxy5" </i>(the file downloaded earlyer)<i> to the removable disk (SD card of the phone). We expect to complete the process successfully and give "Unmount USB Storage" in the CWM phone. Back to main menu using the key back. Navigate to the "Install zip from SD card" -> "Chose zip from SD card". Select "</i></span><i style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: small;">cm-10-20121024-MADTEAM-galaxy5</i><span style="font-family: Verdana, Tahoma, Arial, Trebuchet MS, sans-serif, Georgia, Courier, Times New Roman, serif; font-size: x-small;"><i>", followed by Yes.</i></span><br />
<span style="font-family: Verdana, Tahoma, Arial, Trebuchet MS, sans-serif, Georgia, Courier, Times New Roman, serif; font-size: x-small;"><i><br />
</i></span> <span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"><i>Give "Reboot System"</i></span><br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"><i><br />
</i></span> <br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif;">If you have problems with gMarket redo<b> step 9</b>.</span><span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif;">In order to copy files to the phone you need to do <b>step 5.</b></span><span style="font-family: Verdana, Tahoma, Arial, Trebuchet MS, sans-serif, Georgia, Courier, Times New Roman, serif;">If this is to trivial please leave a message and I will post the complete guid on how to do this without references.</span><br />
<br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"><br />
</span> <span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif;"><b>If this post helped you in any way don't be shay and treat me to a bear, what do you say?</b></span><br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" type="hidden" value="_s-xclick" /><br />
<input name="hosted_button_id" type="hidden" value="YEF7URAC2M7QC" /><br />
<input alt="PayPal - The safer, easier way to pay online!" border="0" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" type="image" /><br />
<img alt="" border="0" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" /></form>
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com11tag:blogger.com,1999:blog-1061659397956632676.post-51886083054702081622012-10-28T00:39:00.000-07:002012-10-28T00:42:56.752-07:00Class not registered Windows 7 errorSome time ago I had a lot of problems with my Windows 7 that I could not find a solution to. Some of them were:<br />
<br />
- opening a folder from uTorrent ('Class not registered')<br />
- opening Network and Shering (dosen't open)<br />
- opening System window (same)<br />
- opening most of my Control Panel windows<br />
<br />
I found a lot of solution that didn't work for me, but the only that did was on google chrome's bug tracker in <a href="http://adf.ly/E6sia">this</a> post, response #9.<br />
<br />
The solution just repairs all the dll's on c: drive, if you have Windows installed on a difrent partition just change C: to whatever letter is your windows partition.<br />
<br />
I recommend reading the post before running the command just know the risks and what to expect.<br />
<br />
<pre style="background-color: white; font-size: 12px; max-width: 80em; padding-left: 0.7em; white-space: pre-wrap;">FOR /R C:\ %G IN (*.dll) DO "%systemroot%\system32\regsvr32.exe" /s "%G" </pre>
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com3tag:blogger.com,1999:blog-1061659397956632676.post-50532215871820261332012-10-27T10:36:00.002-07:002012-10-27T10:36:37.460-07:00How to root Samsung Galaxy i9100 S2<br />
Galaxy S2 is one of the real success of Samsung's leading devices based on the Android platform. And how it is a very powerful phone that has sold so fast, the hackers did not spent much thought and have root-ed it. There are 2 tutorials on rooting , I will write the easiest for beginners. So let's start.<br />
<br />
<br />
<ol>
<li>Download <a href="http://adf.ly/E613a">Odin</a> and extract the files from the archive, saving them on your computer</li>
<li>Download <a href="http://adf.ly/E615M">XWKDD</a> but not extract any files from it</li>
<li>Download <a href="http://adf.ly/E616b">SuperOneClick</a></li>
<li>Download <a href="http://adf.ly/E617I">Samsung Kies</a> and install you phone drivers</li>
<li>After you install the Samsung Kies restart PC</li>
<li>Put your phone in USB debugging mode. Go to Settings, Applications, Development and start USB Debugging</li>
<li>Turn off the phone and turn it back on holding the power, home and volume down buttons</li>
<li>Start Odin and connect your phone to the PC with a USB cable</li>
<li>Wait until Odin will recognize your phone and shows it is connected. On Odin window, except "F.Reset Time" and "Auto Rebot", <b>NO other option</b> should be checked </li>
<li>Press PDA and select the file that you downloaded at step 2 and press Start</li>
<li>Odin will start flash-ing the kernel. When you are finished, your phone will automatically restart</li>
<li>After the phone will reset start SuperOneClick, click root, the phone will root, restart the phone and you're done.</li>
</ol>
<br />
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-86596411367260521042012-10-27T10:21:00.000-07:002012-10-27T10:22:54.884-07:00MOD PS3 without a special usb stick (CFW)<br />
Now you can mod a PS3 without those special sticks. Mod-ing is done with a soft via CFW, that means you don't lose the guarantee. It should be noted that you will lose access to PSN. Attention mod-ing process involves many risks (in the sense that if you do it wrong you might have problems), if you don't have some experience or are unsure better to go to someone who is specialized. For those who are not afraid, not shaking hands on the controller and have some experience here you have a tutorial on how you can mod the console without any problem.<br />
<br />
First you need firmware version 3.55. Make updates to this version, if there will be requests a tutorial will be made for this. There has long been some CFW's of some hackers. You must delete these CFW's by Recovery Mode. You need the original firmware 3.55 from Sony (get it <a href="http://adf.ly/E5ymt">here</a>) and put the console into Recovery Mode. Make <span style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 20px;"><b>Restore PS3 System</b></span> and you will install the original firmware 3.55.<br />
<br />
Once you have the original Sony 3.55 firmware we can get to work. Let's start.<br />
<br />
<br />
<ol>
<li>You need a USB stick or an external hard drive formatted (using this tutorial) in FAT32 format</li>
<li>Download PS3UPDAT.PUP from <a href="http://adf.ly/E5yxW">here</a> (beware, this file is already patched to version CFW kmeaw, it's not an original Sony firmware)</li>
<li>Connect the USB stick or portable hard drive to the computer and create a folder PS3 and inside another folder UPDATE (<b>in capitals!!!</b>)</li>
<li>Copy the files downloaded at point 2 in the UPDATE folder that you just created</li>
<li>Enter console in Recovery Mode. When the console is in Recovery Mode select the System Update option, connect the stick with the files you downloaded in step 2 in the console and the console will switch to CFW 3.55 kmeaw (most stable at the moment) after following instructions on the screen (you must accept ToS and confirm installation)</li>
<li>When everything is over your console is modded. Instal your managers (I recommend multiMAN <strong style="background-color: white; border: 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">or</strong> Gaia - latest version - Multimania <a href="http://adf.ly/E5zRe">here</a> and Gaia <a href="http://adf.ly/E5zUU">here</a>) and BDEMU2 <a href="http://adf.ly/E5zWY">here</a></li>
<li>You can copy the games on a external hdd from Windows or transfer it to the PS via network</li>
<li>If you have problems with playing games, boot the game from multiMAN with Select + X, select Fix Permissions, install and run <a href="http://adf.ly/E5zkz">lv2patcher</a> and select the option SysCall , install <a href="http://adf.ly/E5zxx">Fix Permissions</a> and run the small program that sets chmod 0777 programel to every file / folder on the system and fixes permissions / attributes of those files</li>
<li>If you want to play FullHD movies (and not only) on your console I recomand using <a href="http://adf.ly/E605b">Showtime</a>, and as an alternative have <a href="http://adf.ly/E604m">PS3 Media Server</a></li>
</ol>
<br />Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-47203890222303389822012-10-06T02:51:00.000-07:002012-10-06T02:51:07.846-07:00Creating a module and a db in The Bug Genie 3.2The current documentation is outdated so I tryed to make short note on how to do this.<br />
<br />
ATM using cli will generate some errors, here is how to solve them.<br />
<br />
In order to create a module from cli you need to do something like this from the console:<br />
<br />
php -f tbg_cli create_module MODULE_NAME<br />
<br />
this will generate some errors like:<br />
<br />
<br />
<ul>
<li>Declaration of MODULE_NAME::_initialize() must be compatible with that of TBGModule::_initialize()</li>
</ul>
<div>
- this can be fixed by removing the parameter from _initialize in your class file (class/MODULE_NAME.class.php)</div>
<div>
- also be sure to remove the setters in the init function, they are also depreciated</div>
<div>
<ul>
<li>Anotation @Table missing</li>
</ul>
<div>
- just add this before the class definition in your class file</div>
</div>
<div>
/**</div>
<div>
<div>
* @Table(name="TBGModulesTable")</div>
<div>
*/</div>
</div>
<div>
<br /></div>
<div>
In order to be able to create tables you need to create (if it dose not exist) a folder named B2DB in your class folder and include the table definition there as a class.php file like so:</div>
<div>
<br /></div>
<div>
+class</div>
<div>
+ B2DB</div>
<div>
- MyTable.class.php</div>
<div>
...</div>
<div>
<br /></div>
<div>
MyTable.class.php :</div>
<div>
<br /></div>
<div>
<div>
use b2db\Core,</div>
<div>
b2db\Criteria,</div>
<div>
b2db\Criterion;</div>
<div>
<br /></div>
<div>
/**</div>
<div>
* @Table(name="my_table_name")</div>
<div>
*/</div>
</div>
<div>
</div>
<div>
class MyTable extends TBGB2DBTable{</div>
<div>
</div>
<div>
const B2DB_TABLE_VERSION = 1;</div>
<div>
const B2DBNAME = 'my_table_name';</div>
<div>
const ID = 'my_table_name.id';</div>
<div>
const TEXT = 'my_table_name.a_text_field';</div>
<div>
const SCOPE = 'my_table_name.a_relate_field_to_scopes';</div>
<div>
<br /></div>
<div>
</div>
<div>
protected function _initialize()</div>
<div>
{</div>
<div>
parent::_setup(self::B2DBNAME, self::ID);</div>
<div>
parent::_addText(self::TEXT);</div>
<div>
parent::_addForeignKeyColumn(self::SCOPE, TBGScopesTable::getTable(), TBGScopesTable::ID);</div>
<div>
}</div>
<div>
</div>
<div>
}</div>
<div>
<br /></div>
<div>
all the methods to add text,varchar,int, etc can be found in class Table (core/B2DB/Table.class.php)</div>
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-68369230871618570362012-10-03T22:11:00.000-07:002012-10-03T22:11:44.443-07:00Thebuggenie:Development:Events:ListATM <span class="faded_out dark" style="background-color: white; color: #999999; font-family: 'Open Sans', sans-serif; font-size: 17px; font-weight: bold; line-height: 25px;">Thebuggenie </span>documentation is very low on details so I will post here a list of events I found in the source files of v 3.2<br />
<br />
'core', 'rolepermissionsedit', $role<br />
'core', 'setting_returnfromlogin'<br />
'core', 'setting_returnfromlogout'<br />
'core', 'project_sidebar_links_dashboard'<br />
'core', 'project_sidebar_links_releases'<br />
'core', 'project_sidebar_links_milestone'<br />
'core', 'project_sidebar_links_roadmap'<br />
'core', 'project_sidebar_links_team'<br />
'core', 'project_sidebar_links_statistics'<br />
'core', 'project_sidebar_links_timeline'<br />
'core', 'config_project_tabs'<br />
'core', 'project_dashboard_top'<br />
'core', 'project_dashboard_bottom'<br />
'core', 'project_header_buttons'<br />
'core', 'project/projectinfo', $project<br />
'core', 'config_project_panes'<br />
'core', 'project_overview_item_links'<br />
'publish', 'fixture_article_loaded'<br />
'vcs_integration', 'new_commit'<br />
'core', 'quicksearch_dropdown_firstitems'<br />
'core', 'quicksearch_dropdown_founditems'<br />
'core', 'reportissue.prefile'<br />
'core', 'reportissue.listfields'Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-11071863888072660882012-08-20T02:04:00.002-07:002012-08-20T02:04:51.681-07:00Cheating littlealchemyIf you got stuck and can't find any more combinations and you want to create more, here is a little script that will activate all the elements:<br />
<br />
<br />
<code>alchemy.history.parents = [];<br />
<br />
for(var i=0;i<base.base.length;i++){<br />
if(base.base[i][0] != false){<br />
for(var j=0;j<base.base[i].length;j++){<br />
alchemy.history.parents.push(base.base[i][j])<br />
}<br />
}<br />
}<br />
<br />
localStorage.setItem("history", JSON.stringify(alchemy.history));</code><br />
<br />
Just paste this code in the browser's console (F12 for firefox's firebug or google chrome's console) and after just refresh.<br />
<br />
If you want a complete list of all the combinations possible run this code:<br />
<br />
WARNIGN: this script may take a long time to compile and you may get "stop script" alerts. If you are patient and click continue you will see the full list. The time to finish depends on the pc and the browser (fastest is goole chrome)<br />
<br />
<code>var html = [];<br />
<br />
var l = base.length;<br />
var s = 0;<br />
<br />
for(var ii=s;ii<s+l;ii++){<br />
for(var jj=ii;jj<s+l;jj++){<br />
var r = alchemy.sex([ii,jj]);<br />
if(r.length>0){<br />
html.push('<div><img src="img/base/'+(ii+1)+'.png" class="boxImg"> + <img src="img/base/'+(jj+1)+'.png" class="boxImg"> = ');<br />
for(var k=0;k<r.length;k++){<br />
html.push('<img src="img/base/'+(r[k]+1)+'.png" class="boxImg">')<br />
if(k+1<r.length) html.push(' , ')<br />
}<br />
html.push('</div>')<br />
}<br />
}<br />
}<br />
<br />
$('<div>').html('<div style="height:350px;overflow:auto">'+html.join('')+'</div>').dialog({<br />
height: 400,<br />
width: 800,buttons: {<br />
'OK': function () {<br />
$(this).dialog("close");<br />
}<br />
},modal: true,<br />
draggable: true,<br />
});<br />
/**/</code><br />
<br />
If there are at least 5 persons that ask me to make a web page where you can see the complete tutorial I will make it so you won't have to use the script every time.Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-31627128461019908212012-06-15T12:33:00.002-07:002013-02-04T13:53:48.413-08:00Update Samsung GT-I5500 from 2.2 to 2.3.7 - CyanogenMod 7.2 1.9 MADTEAM<span style="font-family: Verdana, Tahoma, Arial, Trebuchet MS, sans-serif, Georgia, Courier, Times New Roman, serif;"><b><a href="http://cuzztuts.blogspot.ro/2012/10/update-samsung-gt-i5500-from.html">EDIT: HOW ABOUT UPGRADING TO 4.0 (CyanogenMod 9) ?</a></b></span><br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"><br />
</span> <span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;">I thought it would be useful to share this info, if you have a phone </span><span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;">Galaxy</span><span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"> 5/Galaxy 550/GT-I5500/Europa Galaxy or whatever you call it. The method was tested on several terminals and works without any problems. We observed significant performance boost, in some cases beating a Galaxy S, and that without overclocking the processor.</span><br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;">Note that if the phone will break for various reasons and the firmware is still installed, guarantee is lost as a result of these changes. But in most cases you can return to official firmware that came with the phone. The firmware comes with Root, superuser and BusyBox installed, and is based on Android 2.3.7, the latest version of Android Gingerbread. Different versions of the firmware have been run stable on my phone for about 2 months. Note that it is more stable than stock firmware!</span><br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"><br />
</span> <span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;">To streamline the process of upgrading the firmware, instead of uploading individual files I chose to put them all in one archive on RapidShare, which offers a much higher transfer rate.</span><br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"><br />
</span> <span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;">Follow this link to download files: </span><br />
<a href="http://adf.ly/IZWFm" style="background-color: white; font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: 13px;" target="_blank">Cyanogen.rar</a><br />
<br />
<span style="background-color: white;"><span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;">Once you have downloaded the file, use WinRAR ( </span></span><a href="http://adf.ly/E69eK" style="background-color: white; font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: 13px;" target="_blank">winRAR</a><span style="background-color: white;"><span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"> ) to unpack it.</span></span><br />
<br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;">We should have a folder that includes the following files:</span><br />
<br />
<img border="0" class="linked-image" src="http://i43.tinypic.com/15ffwp4.jpg" style="background-color: white; font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: 13px;" /><br />
<br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"><span style="background-color: white;"></span></span><br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;">After we made sure we have all the files needed to continue, before the writing of the firmware we need to install the USB drivers for Samsung mobile phone, that if we don't have installed Kies.</span><br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"><span style="background-color: white;">Drivers as standalone package can be found here:</span></span><span style="background-color: white; font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: 13px;"> </span><a href="http://adf.ly/E69hH" style="background-color: white; font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: 13px;" target="_blank">drivers</a><span style="background-color: white; font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: 13px;"> .</span><br />
<br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;">If the installation went smoothly, we finally get to install the firmware on the phone.<br />
We need original Samsung USB cable (preferably, but should work without problems using a new cable).<br />
<br />
My request is to follow these steps in the order they appear here, or you can meet with some problems.<br />
<br />
1. Backup data you consider important, no one will take responsibility for lost data! Speaking of contacts, simply export the SD card, then copy them into the computer later. For others: photos, videos, etc. I suspect that you have already guessed, like, copy them into the computer. Although small chances, the processes for firmware upgrade can result in an unexpected way.<br />
<br />
2. Turn off the phone after you enter the download mode. To do this it is necessary to hold simultaneously the volume down key and the center button(center of the joystick) and the power button).<br />
<br />
3. Connect the phone to the PC via the USB cable. If your phone has not been connected until now in download mode, down in the Windows notification area there will be displayed a balloon telling you that new hardware is being installed. Wait until the process is completed, then open "Odin Multi Downloader v4.28" included in the archive provided by me.<br />
<br />
4. First we rewrite the baseband phone with one that is "certified" to be fully compatible with Cyanogen Mod. Version is included and recommended by me "I5500XWJP4". From Odin, we click on the OPS file and select "EUROPA_I5508_v1.0.ops". Select the option one package, then we click on the tab with the same name under "Select Integrated Package - Check One Option Package" and select file "MODEM_I5500XWJP4.tar.md5", followed by a click on "Start". Wait until the process is completed, the phone should restart and boot into the OS.<br />
<br />
5. Turn off the phone again, enter download mode again, only this time instead of "MODEM_I5500XWJP4.tar.md5", we select "ClockworkMod-Galaxy5-v0.7", followed as before by the "Start ".<br />
<br />
6. After completing the phone will automatically install the Recovery ClockWorkMod. Navigating through the menus is done with keys up / down and selecting with the middle button. The first thing you need to do is to select "Wipe Data / Factory Reset", navigate to the Yes (like you have to do for each action of CWM).<br />
<br />
7. Now we move on to installing packages. Go to "Mount and storage", then "Mount USB Storage". Copy files "update-cm-7.2.0-RC0-galaxy5-v1.9-MADTEAM-signed", "Galaxy5-v1.9-hotfix3", "gapps-gb-20110828-signed", "TouchWiz_3.0_Port_v0.7 "removable disk (SD card of the phone) again appeared in My Computer. We expect to complete the process successfully and give "Unmount USB Storage" in the CWM phone. Back to main menu using the key back. Navigate to the "Install zip from SD card" -> "Chose zip from SD card". Select "update-cm-7.2.0-RC0-galaxy5-v1.9-MADTEAM-signed", followed by Yes.<br />
<br />
8. Now we install the hotfix, just like the previous step, only this time select, after the "Chose zip from SD card" select file "Galaxy5-v1.9-hotfix3", followed by Yes.<br />
<br />
9. The last step required, that if you want to use the Android Market, and you want this more than sure, this is installing applications including Google. Mentioned is that applications like YouTube, Maps, etc.. can easily install from the Android Market. As far as the "Chose zip from SD card", this time select "gapps-gb-20110828-signed", followed by Yes.<br />
<br />
10. Installation TouchWiz 3.0 (or the GUI Launcher, which is included in the Samsung's firmware). Not different, as "Chose zip from SD card", choose "TouchWiz_3.0_Port_v0.7", and finally Yes.<br />
<br />
11. Give "Reboot System" from the main menu and wait for phone to boot. The first time it takes longer, since we need to index new files, so there should be no concern. Follow the instructions on the screen, everything should go smoothly. If you have installed and TouchWiz, at some point you will be prompted to start the Launcher. You can check that the option selected by default start with the phone. If at any time you want to get rid of one of them you can do this using Titanium Backup that you find on the Market.<br />
<br />
This version does not require battery recalibration, because with the introduction of version 1.9 of this port driver returned to the battery of your original firmware. This version of firmware with all the hotfixes included was extensively tested by me all day and I can say that with the new version was going to respond much better if the phone orders and animations are included purely ICS and simply adorable! I hope I managed somehow to help users without technical knowledge too advanced or do not want to fight too much. I'll answer any questions as long as they are in connection with this firmware and / or telephone. All the best!</span><br />
<span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif; font-size: x-small;"><br />
</span> <span style="font-family: Verdana, Tahoma, Arial, 'Trebuchet MS', sans-serif, Georgia, Courier, 'Times New Roman', serif;"><b>If this post helped you in any way don't be shay and treat me to a bear, what do you say?</b></span><br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" type="hidden" value="_s-xclick" /><br />
<input name="hosted_button_id" type="hidden" value="YEF7URAC2M7QC" /><br />
<input alt="PayPal - The safer, easier way to pay online!" border="0" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" type="image" /><br />
<img alt="" border="0" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" /></form>
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com44tag:blogger.com,1999:blog-1061659397956632676.post-21032991685662284862012-01-16T02:33:00.001-08:002012-10-27T12:29:49.530-07:00Sugarcrm custom chartCreating a sugar chart dashlet is done the same way as you would create a simple dashlet, just extending 2 functions, for this reason I will not cover the way a sugar dashlet is created.
<b>Notes:</b>
The dashlets will be named "CustomLineDashlet" and "CustomPieDashlet" and the module is "abc_Sample".
You can use the predefined sugar chart definitions for parsing data (modules\Charts\chartdefs.php) or you can create your own to meet any custom demands. This is done by editing(creating if dose not exist) "custom\Charts\chartDefs.ext.php".
For <b>CustomPieDashlet</b> :
custom\Charts\chartDefs.ext.php:
<br />
<pre>$chartDefs['custom_pie_chart'] = array('type' => 'code',
'id' => 'custom_pie_chart',
'label' => 'custom_pie_chart label',
'chartUnits' => 'The unit definition',
'chartType' => 'pie chart',
// important value that will be used to group the data
'groupBy' => array( 'name' ),
'base_url'=>
array( 'module' => 'abc_Sample',
'action' => 'index',
'query' => 'true',
'searchFormTab' => 'advanced_search',
)
);</pre>
custom\modules\abc_Sample\Dashlets\CustomPieDashlet\CustomPieDashlet.php
<br />
<pre>....</pre>
<pre>public function display() {
$currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
require ("modules/Charts/chartdefs.php");
// here we load the chart definition (custom\Charts\chartDefs.ext.php)
$chartDef = $chartDefs['custom_pie_chart'];
require_once ('include/SugarCharts/SugarChart.php');
$sugarChart = new SugarChart();
$sugarChart -> setProperties('', translate('LBL_OPP_SIZE', 'Charts') . ' ' . currency_symbol . '1' . translate('LBL_OPP_THOUSANDS', 'Charts'), $chartDef['chartType']);
$sugarChart -> base_url = $chartDef['base_url'];
$sugarChart -> group_by = $chartDef['groupBy'];
$sugarChart -> url_params = array();
$sugarChart -> getData($this -> constructQuery());
$xmlFile = $sugarChart -> getXMLFileName($this -> id);
$sugarChart -> saveXMLFile($xmlFile, $sugarChart -> generateXML());
return $this -> getTitle('<div align="center">
</div>
') . '<div align="center">
' . $sugarChart -> display($this -> id, $xmlFile, '100%', '480', false) . '</div>
';
}
protected function constructQuery() {
// this is the query used to get data and create the xml
// for pie chart we have a simple query
$query = "
SELECT
count(*) as total,
name
FROM
table
GROUP BY name
ORDER BY name";
return $query;
}</pre>
For <b>CustomLineDashlet </b>:
custom\Charts\chartDefs.ext.php:
<br />
<pre>$chartDefs['custom_line_chart'] = array( 'type' => 'code',
'id' => 'custom_line_chart',
'label' => 'custom_line_chart label',
'chartUnits' => 'The unit definition',
'chartType' => 'line chart',
// the legend will be the name and the x intervals will be the date
'groupBy' => array( 'date','name' ),
'base_url'=>
array( 'module' => 'sam_Sample',
'action' => 'index',
'query' => 'true',
'searchFormTab' => 'advanced_search'
)
);</pre>
custom\modules\abc_Sample\Dashlets\CustomLineDashlet\CustomLineDashlet.php
<br />
<pre>....</pre>
<pre>public function display() {
$currency_symbol = $GLOBALS['sugar_config']['default_currency_symbol'];
require ("modules/Charts/chartdefs.php");
// here we load the chart definition (custom\Charts\chartDefs.ext.php)
$chartDef = $chartDefs['<b>custom_line_chart</b>'];
require_once ('include/SugarCharts/SugarChart.php');
$sugarChart = new SugarChart();
$sugarChart -> setProperties('', translate('LBL_OPP_SIZE', 'Charts') . ' ' . currency_symbol . '1' . translate('LBL_OPP_THOUSANDS', 'Charts'), $chartDef['chartType']);
$sugarChart -> base_url = $chartDef['base_url'];
$sugarChart -> group_by = $chartDef['groupBy'];
$sugarChart -> url_params = array();
$sugarChart -> getData($this -> constructQuery());
$xmlFile = $sugarChart -> getXMLFileName($this -> id);
$sugarChart -> saveXMLFile($xmlFile, $sugarChart -> generateXML());
return $this -> getTitle('<div align="center">
</div>
') . '<div align="center">
' . $sugarChart -> display($this -> id, $xmlFile, '100%', '480', false) . '</div>
';
}
protected function constructQuery() {
// this is the query used to get data and create the xml
// for pie chart we have a simple query
$query = "
SELECT
count(*) as total,
name,
date
FROM
table
GROUP BY date,name
ORDER BY name";
return $query;
}</pre>
the meta files ( custom\modules\abc_Sample\Dashlets\CustomLineDashlet\CustomPieDashlet.meta.php and custom\modules\abc_Sample\Dashlets\CustomLineDashlet\CustomLineDashlet.meta.php) will look like this:
<br />
<pre>$dashletMeta['CustomSamplePieCart'] = array('module' => 'abc_Sample',
'title' => 'Custom Pie Chart',
'description' => 'Custom description',
'icon' => 'themes/default/images/icon_sam_Sample_32.gif',
'category' => 'Charts');
</pre>
and
<br />
<pre>$dashletMeta['CustomSampleLineCart'] = array('module' => 'abc_Sample',
'title' => 'Custom Chart',
'description' => 'Custom description',
'icon' => 'themes/default/images/icon_sam_Sample_32.gif',
'category' => 'Charts');
</pre>
<div>
<br />
Notes:<br />
custom\Charts\chartDefs.ext.php is the place where you will define your chart type, important fields:<br />
'groupBy' => array( 'date','name' ) (the x and legend fields)<br />
'chartType' => 'line chart', (the swf name, php will capitalize and add .swf, so it will be lineChar.swf)<br />
<br />
in the sql your x values will have to coincide (be the same) for all lines</div>
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-20395597454965841942012-01-01T02:37:00.000-08:002012-01-01T03:04:00.134-08:00Gotomeeting php api(oauth) create metingThis is from <a href="https://developer.citrixonline.com/forum/create-meeting-error">https://developer.citrixonline.com/forum/create-meeting-error</a> , the code from <span style="font-family: arial, helvetica, sans-serif; font-size: 12px; font-weight: bold; line-height: 16px; text-align: left;">bcantoni:</span><br />
<span style="font-family: arial, helvetica, sans-serif; font-size: 12px; line-height: 16px; text-align: left;">Create a METING:</span><br />
<span style="font-family: arial, helvetica, sans-serif; font-size: 12px; font-weight: bold; line-height: 16px; text-align: left;"><br /></span>
<br />
<pre> <;∧php
// sample GoToMeeting API call: create meeting
// docs: https://developer.citrixonline.com/api/GoToMeeting%2520REST%2520API/Create%2520Meeting-150
// assume have valid $access_token from OAuth flow
$access_token = 'xyz';
$url = "https://api.citrixonline.com/G2M/rest/meetings";
$headers = array (
"Accept: application/json",
"Content-Type: application/json",
"Authorization: OAuth oauth_token=$access_token"
);
$data = array ('test meeting',
'starttime' => '2012-02-01T08:00:00',
'endtime' => '2012-02-01T09:00:00',
'timezonekey' => '67', // Pacific time
'meetingtype' => 'Scheduled',
'passwordrequired' => 'false',
'conferencecallinfo' => 'Hybrid' // normal PSTN + VOIP options
);
$data_json = json_encode ($data);
$ch = curl_init();
curl_setopt_array ($ch, array (
CURLOPT_URL => $url,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data_json,
));
$results = curl_exec ($ch);
$info = curl_getinfo ($ch);
curl_close ($ch);
print "data sent: $data_json\n";
//print "headers sent: " . print_r($headers,1) . "\n";
//print "curl info: " . print_r($info,1) . "\n";
print "data returned: " . print_r($results,1 ) . "\n";
//print "data returned decoded: " . print_r(json_decode($results),1) . "\n";
</pre>
<br />
And the response:<br />
<br />
<pre>$ php post.php
data sent: {"subject":"test meeting","starttime":"2012-02-01T08:00:00","endtime":"2012-02-01T09:00:00","timezonekey":"67","meetingtype":"Scheduled","passwordrequired":"false","conferencecallinfo":"Hybrid"}
data returned: {"joinURL":"https:\/\/www3.gotomeeting.com\/join\/123456789","maxParticipants":26,"uniqueMeetingId":2000007959645,"meetingid":123456789}
</pre>
<b>EDIT:</b><br />
<br />
<br />
thaks for the response, but I still get the same error with your code :). Here is the output from the php:<br />
<br />
<pre>data sent:
Array
(
[0] => test meeting
[starttime] => 2012-02-01T08:00:00
[endtime] => 2012-02-01T09:00:00
[timezonekey] => 67
[meetingtype] => Scheduled
[passwordrequired] => false
[conferencecallinfo] => Hybrid
)
data returned:
{"int_err_code":"Server.userException","msg":"java.lang.NumberFormatException: Invalid date/time"}curl info:
Array
(
[url] => https://api.citrixonline.com/G2M/rest/meetings
[content_type] => text/xml; charset=utf-8
[http_code] => 404
[header_size] => 224
[request_size] => 483
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 2.797
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0.438
[size_upload] => 712
[size_download] => 98
[speed_download] => 35
[speed_upload] => 254
[download_content_length] => 98
[upload_content_length] => 712
[starttransfer_time] => 2.438
[redirect_time] => 0
[certinfo] => Array
(
)
)</pre>
<br />
<br />
And from fidler:<br />
<br />
<pre>POST https://api.citrixonline.com/G2M/rest/meetings HTTP/1.1
Host: api.citrixonline.com
Accept: application/json
Authorization: OAuth oauth_token=1c8187be36bb86997db59e5772268d5a
Content-Length: 712
Expect: 100-continue
Content-Type: application/json; boundary=----------------------------9530b5163dde
------------------------------9530b5163dde
Content-Disposition: form-data; name="starttime"
2012-02-01T08:00:00
------------------------------9530b5163dde
Content-Disposition: form-data; name="endtime"
2012-02-01T09:00:00
------------------------------9530b5163dde
Content-Disposition: form-data; name="timezonekey"
67
------------------------------9530b5163dde
Content-Disposition: form-data; name="meetingtype"
Scheduled
------------------------------9530b5163dde
Content-Disposition: form-data; name="passwordrequired"
false
------------------------------9530b5163dde
Content-Disposition: form-data; name="conferencecallinfo"
Hybrid
------------------------------9530b5163dde--
</pre>
<br />
<br />
and the response:<br />
<br />
<br />
<pre>HTTP/1.1 404 Not Found
Date: Sun, 01 Jan 2012 10:57:14 GMT
Server: Apache
Content-Length: 98
Content-Type: text/xml; charset=utf-8
Cneonction: close
Vary: Accept-Encoding
Connection: close
{"int_err_code":"Server.userException","msg":"java.lang.NumberFormatException: Invalid date/time"}</pre>Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com2tag:blogger.com,1999:blog-1061659397956632676.post-26243172512701668412011-12-29T06:32:00.000-08:002011-12-29T07:51:47.919-08:00Gotomeeting php api(oauth) implementationI had a lot of problems connecting to citrix and making the api work, here are some steps to take:<br />
<br />
Oauth integration:<br />
<br />
<pre class="brush: php">
$key = '#';
$secret = '#';
$domain = $_SERVER['HTTP_HOST'];
$base = "/oauth/index.php";
$base_url = urlencode("http://$domain$base");
$OAuth_url = "https://api.citrixonline.com/oauth/authorize?client_id=$key&redirect_uri=$base_url";
$OAuth_exchange_keys_url = "http://api.citrixonline.com/oauth/access_token?grant_type=authorization_code&code={responseKey}&client_id=$key";
if($_SESSION['access_token']) CreateForm();else
if($_GET['send']) OAuth_Authentication($OAuth_url);
elseif($_GET['code']) OAuth_Exchanging_Response_Key($_GET['code'],$OAuth_exchange_keys_url);
function createForm(){
// you are loged in, play around
}
function OAuth_Exchanging_Response_Key($code,$url){
if($_SESSION['access_token']){
CreateForm();
return true;
}
$data = getURL(str_replace('{responseKey}',$code,$url));
if(IsJsonString($data)){
$data = json_decode($data);
$_SESSION['access_token'] = $data->access_token;
CreateForm();
}else{
echo 'error';
}
}
function OAuth_Authentication ($url){
$_SESSION['access_token'] = false;
header("Location: $url");
}
/*
* CURL function to get url
*/
function getURL($url,$auth_token = false,$data=false){
// Initialize session and set URL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// curl not working local machine, using fiddler
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if($auth_token){
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: OAuth oauth_token='.$auth_token));
}
// Get the response and close the channel.
$response = curl_exec($ch);
/*
* if redirect, redirect
*/
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($code == 301 || $code == 302) {
preg_match('//(.*?)">/', $response, $matches);
$newurl = str_replace('&','&',trim(array_pop($matches)));
$response = getURL($newurl);
} else {
$code = 0;
}
curl_close($ch);
return $response;
}
</pre>
<br />
To start login you need to access ?send=1. I am using fidler as a proxy for https requests because my server is not set up for this.Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-88695840512248397682011-12-25T08:30:00.000-08:002011-12-25T08:30:06.422-08:00JS OOPIf you thought that JS is written only using functions and objects, well, you are kind of wright :). But actually it is the most permissive (in my opinion) OOP language.<br />
A class in js is defined using "function" and when we use something like:<br />
<pre class="brush: js">function sum(a,b){
return a+b;
}
</pre>
we actually create a new class named "sum". All that we see inside the "{...}" is actually the constructor, so when we call<br />
<pre class="brush: js">var c = sum(1,2)
</pre>
c will be equal to 3, because that is what the constructor of the class returns, the sum of the variables.<br />
If we would use
<br />
<pre class="brush: js">var c = new sum(1,2);
</pre>
c would be an instance of the class sum. Of course for the purpose of simplicity class sum dose not have any variables or methods attached to it, so let's go ahead and make this a little more complex.<br />
Let's define a new class that we can also use as a standalone function.<br />
<br />
<pre class="brush: js">function Animal(name,species){
// standard (for me) way to use default values for params
// also the params will be private vars in our class
name = name || "Unnamed";
species = species || "Unknown";
// setup some public vars
this.animalTitle = name + ' the ' + species;
// setup some private vars
var age = 0;
// create a private methos
var grow = function(years){
return age + years;
}
// some public methods(functions :) )
this.getOlder = function(how_much){
// here we access the private var
// and a public one
how_much = how_much || 0;
age = grow(how_much);
this.animalTitle = name + ' the ' + species + ' at ' + age + ' years old';
}
// using return to demonstrate how it works as a simple function
return this.animalTitle;
}
</pre>
Ok, now let's explain more.<br />
<b>name = name || 'Unnamed'</b> is the same as <b>if(name == null)</b> <b>name = 'Unnamed';. </b>BTW, if you expect name, or whatever the param name will be, to be a bool or number you should use <b>==null </b>or <b>name = (name == null ? "Unnamed" || name) </b>because <b>0</b> or <b>false </b>will make act in the expression used by me the same way as <b>null</b>.<br />
<b>this.animalTitle</b> is a public variable that will be readable/writable, will see later.<br />
<b>age</b> is a private variable that can only be used inside the class (also as I said in the inline comments, the params are also considered private vars).<br />
<b>grow </b>is a private method, a function that can be called only inside the class definition.<br />
And <b>getOlder </b>is a public method that can be called or overwritten.<br />
Here is a example on how this can be used as a function:<br />
<br />
<pre class="brush: js">var my_pet = Animal("Rex","Dog");
alert(my_pet);
// will alert "Rex the Dog"
</pre>
or as a class definition to create an object:
<br />
<pre class="brush: js">var my_pet = new Animal("Simba","Lion");
alert(my_pet);
// will alert [object Object]
// to get a better understanding of what this is we can use GC console ot FF firebug and do:
console.log(my_pet)
alert(my_pet.animalTitle)
// will alert 'Simba the Lion'
my_pet.getOlder(10); // calling a public method
alert(my_pet.animalTitle)
// will alert 'Simba the Lion 10 years old'
my_pet.animalTitle = 'Custom title for my pet'; // overwriting a public member of the object
alert(my_pet.animalTitle)
// will alert 'Custom title for my pet'
</pre>
Next we should talk about the <b>prototype </b>object.<br />
Most of the js community talks about the prototype object as giving the functionability to add public methods/vars to classes. I actually don't like how this sounds and I will refraze it like this: "<i>The prototype object is used to extend methods and variables of a class with the downside that you won't be able to use the private vars</i>". Ok, now let's get back to some code:<br />
<br />
<pre class="brush: js">// using our class Animal
Animal.prototype.whatToSay = 'I can say this:';
var my_pet = new Animal();
alert(my_pet.whatToSay);
// will alert 'I can say this:'
// we want to add a method named speak
Animal.prototype.speak = function(){
// we can use public methods from our constructor and also ones we defined with prototype
alert(this.whatToSay + ' My name is ' + this.animalTitle);
}
// we can't use age or grow() here because we don't have access to anything
// not defined in the constructor (function) with this. (public stuff)
var my_pet2 = new Animal();
my_pet2.speak();
// will alert 'I can say this: I am Unknown the Unnamed'
// why Unnamed? because we didn't gave him a name when we created him and this is the
// default string we gave it
var my_pet3 = new Animal('Bobo','Bear');
my_pet3.speak();
// will alert 'I can say this: I am Bobo the Bear'
</pre>
Hope this will help somebody on a better understanding of the OOP in JS. Will continue with <b>object members</b> and <b>inheritance</b>.Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-3553979522214162672011-12-09T07:33:00.000-08:002011-12-09T07:36:19.089-08:00js async for, very coolThis is something nice. This code can create for interrupts for those long functions in ie, so you can tell the user what is happening :). You can run it in the fireBug's console to see what I mean :).<br />
<br />
<br />
<pre class="brush: js">function async_for_each(object,cbk,limit_callback,end_cbk,limit,timeout,start){
var l=object.length;
limit = limit || Math.round(l/100);
start = start || 0;
timeout = timeout || 1;
for(var i=start;i<l;i++){
if(i-start>limit){
setTimeout(function(){
async_for_each(object,cbk,limit_callback,end_cbk,limit,timeout,i)
},timeout);
limit_callback(i,l);
return false;
}else{
cbk(i,object[i]);
}
}
end_cbk?end_cbk():null;
return true;
}
var a = [];
a.length = 1000;
async_for_each(a,function(){},function(i,l){console.log("locading %s/%s - %s%",i,l,Math.round(i*100/l))});
</pre>Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-42968402074202076962011-12-09T06:40:00.001-08:002012-06-14T08:00:44.841-07:00js extend methodthis is what you need to use if you want to extend a function in js. Easy to use :).<br />
<br />
<pre class="brush: js">// to use only for alert
Function.prototype.extend = function (fn) {
var self = this;
return function () {
//console.log(self)
//console.log(fn)
try{
var returnValue1 = self(arguments[0]);
}catch(e){}
try{
var returnValue2 = fn(arguments[0]);
}catch(e){}
return returnValue1 && returnValue2;
};
};
</pre>Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com1tag:blogger.com,1999:blog-1061659397956632676.post-11054919329924059592011-12-09T06:39:00.000-08:002012-06-14T08:01:06.964-07:00Some useful classesCookie class<br />
<div>
<br /></div>
<pre class="brush: js">function Coockie(){
this.create = function(name,value,days) {
days = days || 999999;
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
this.coockie_cache[name] = value;
document.cookie = name+"="+value+expires+"; path=/";
}
this.read = function(name) {
if(this.coockie_cache[name]) return this.coockie_cache[name];
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return this.coockie_cache[name] = c.substring(nameEQ.length,c.length);
}
return null;
}
this.eraseCookie = function(name) {
createCookie(name,"",-1);
}
this.coockie_cache = {};
}
</pre>
fireBug debug times class<br />
<div>
<br /></div>
<pre class="brush: js">var Debug = function(o){
if('time' in console){
if(Debug.times.length>0) console.timeEnd(Debug.times[Debug.times.length-1].name);
Debug.times.push({name:o});
console.time(o);
}
}
Debug.times = [];
Debug.stop=function(){
if('time' in console){
for(var i=0;i< Debug.times.length-1;i++){
Debug.times[i].total = console.timeEnd(Debug.times[i].name);
}
for(var i=0;i< Debug.times.length-1;i++){
//log(Debug.times[i].name+": "+(Debug.times[i].total-Debug.times[i+1].total))
//Debug.times[i].total = console.timeEnd(Debug.times[i].name);
}
}
};
</pre>
js date week functions for date object<br />
<div>
<br /></div>
<pre class="brush: js">Date.prototype.getWeek = function () {
// Create a copy of this date object
var target = new Date(this.valueOf());
// ISO week date weeks start on monday
// so correct the day number
var dayNr = (this.getDay() + 6) % 7;
// ISO 8601 states that week 1 is the week
// with the first thursday of that year.
// Set the target date to the thursday in the target week
target.setDate(target.getDate() - dayNr + 3);
// Store the millisecond value of the target date
var firstThursday = target.valueOf();
// Set the target to the first thursday of the year
// First set the target to january first
target.setMonth(0, 1);
// Not a thursday? Correct the date to the next thursday
if (target.getDay() != 4) {
target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);
}
// The weeknumber is the number of weeks between the
// first thursday of the year and the thursday in the target week
return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000
}
Date.prototype.getWeekYear = function ()
{
// Create a new date object for the thursday of this week
var target = new Date(this.valueOf());
target.setDate(target.getDate() - ((this.getDay() + 6) % 7) + 3);
return target.getFullYear();
}
Date.prototype.addDays = function(nr_of_days){
var a = new Date(this.valueOf());;
return nr_of_days==0?this:new Date(a.setDate(a.getDate()+nr_of_days));
}
Date.prototype.addDaysToSunday = function(){
return this.addDays(
7 - (this.getDay()==0?7:this.getDay())
);
}
Date.prototype.moveToStartOfNextWeek = function(){
return this.addDays(
8 - (this.getDay()==0?7:this.getDay())
);
}
Date.prototype.addWeeks = function(weeks){
if(weeks<1) return this;
return this.addDays(
8 - (this.getDay()==0?7:this.getDay()) + 7*(weeks-1)
);
}
Date.prototype.getISODay = function(){
// Native JS method - Sunday is 0, monday is 1 etc.
var d = this.getDay();
// Return d if not sunday; otherwise return 7
return d ? d : 7;
};
Date.prototype.getMaxWeekOfYear = function (){
var year = this.getFullYear();
var maxWeek = 52;
fj = new Date(year, 0, 1); //1st Jan
tfd = new Date(year, 11, 31); //31st Dec
if(fj.getDay() == 4 || tfd.getDay() == 4){
maxWeek = 53;
}
return maxWeek;
}
</pre>Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-7446952262993647942011-09-25T01:05:00.000-07:002011-09-25T01:05:54.434-07:00Cheats sheaths<pre><div class="box10">
<a href="http://woorkup.com/wp-content/uploads/2011/05/jQuery-1.6-Visual-Cheat-Sheet.pdf">jQuery</a></div>
</pre>
<pre></pre>
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-49317896720332452812011-09-25T01:00:00.000-07:002011-09-25T01:01:30.086-07:00JS Bind methodNot working for some IE versions.<br />
<span class="Apple-style-span" style="background-color: #ffffe1; color: #333333; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Lucida, Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; line-height: 22px;">Introduced in <a href="https://developer.mozilla.org/en/JavaScript/New_in_JavaScript/1.8.5" rel="custom" style="color: #336699; text-decoration: none;">JavaScript 1.8.5</a></span><br />
<br />
Need to rewrite it?<br />
<br />
<br />
<pre class="brush: js">if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") // closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be fBound is not callable");
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
fBound = function () {
return fToBind.apply(this instanceof fNOP ? this : oThis || window, aArgs.concat(Array.prototype.slice.call(arguments)));
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
}
</pre>
Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-77876311688472293592011-09-25T00:58:00.000-07:002011-09-25T00:58:24.510-07:00JS arguments object<span class="Apple-style-span" style="background-color: white; color: #333333; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Lucida, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px;"></span><br />
<h3 class="editable" style="border-bottom-color: rgb(224, 224, 220); border-bottom-style: solid; border-bottom-width: 1px; font-family: Georgia, Times, 'Times New Roman', serif; font-size: 1.142em; margin-bottom: 0.8em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
Summary</h3>
<div style="margin-bottom: 1.286em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
An array-like object corresponding to the arguments passed to a function.</div>
<div style="margin-bottom: 1.286em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<br /></div>
<span class="Apple-style-span" style="background-color: white; color: #333333; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Lucida, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px;"><h3 class="editable" style="border-bottom-color: rgb(224, 224, 220); border-bottom-style: solid; border-bottom-width: 1px; font-family: Georgia, Times, 'Times New Roman', serif; font-size: 1.142em; margin-bottom: 0.8em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
Properties</h3>
<dl style="margin-bottom: 1.286em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<dt style="font-style: normal; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments/callee" rel="internal" style="color: #336699; text-decoration: none;" title="En/Core_JavaScript_1.5_Reference/Functions_and_function_scope/arguments/callee">arguments.callee</a></dt>
<dd style="margin-bottom: 0.5em; margin-left: 22px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 15px; padding-right: 0px; padding-top: 0px;">Reference to the currently executing function.</dd></dl>
<dl style="margin-bottom: 1.286em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<dt style="font-style: normal; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments/caller" rel="internal" style="color: #336699; text-decoration: none;" title="En/Core_JavaScript_1.5_Reference/Functions_and_function_scope/arguments/caller">arguments.caller</a></dt>
<dd style="margin-bottom: 0.5em; margin-left: 22px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 15px; padding-right: 0px; padding-top: 0px;"><span style="background-color: #febcbc; border-bottom-color: rgb(255, 0, 0); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(255, 0, 0); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(255, 0, 0); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(255, 0, 0); border-top-style: solid; border-top-width: 1px; font-size: xx-small; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; white-space: nowrap;" title="">Obsolete</span></dd><dd style="margin-bottom: 0.5em; margin-left: 22px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 15px; padding-right: 0px; padding-top: 0px;">Reference to the function that invoked the currently executing function.</dd></dl>
<dl style="margin-bottom: 1.286em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<dt style="font-style: normal; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments/length" rel="internal" style="color: #336699; text-decoration: none;" title="En/Core_JavaScript_1.5_Reference/Functions_and_function_scope/arguments/length">arguments.length</a></dt>
<dd style="margin-bottom: 0.5em; margin-left: 22px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 15px; padding-right: 0px; padding-top: 0px;">Reference to the number of arguments passed to the function.</dd><dd style="margin-bottom: 0.5em; margin-left: 22px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 15px; padding-right: 0px; padding-top: 0px;"><br /></dd><dd style="margin-bottom: 0.5em; margin-left: 22px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 15px; padding-right: 0px; padding-top: 0px;">(from MDN)</dd></dl>
</span>Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-70334478762788258372011-09-25T00:52:00.001-07:002011-09-25T01:07:24.974-07:00My nice links<a href="http://jsclass.jcoglan.com/">JSClasses </a>, real nice js class manager.<br />
<a href="http://flowplayer.org/tools/demos/index.html">jQuery TOOLS</a>, may be useful.<br />
Cool <a href="http://koschtit.tabere.net/en/">image gallery</a>.<br />
jQuery <a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx#tip2">tips</a>.Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-64294247911103753932011-09-25T00:05:00.000-07:002011-09-25T00:34:05.149-07:00JS Classes<br />
<h2 style="border-bottom-color: rgb(153, 153, 153); border-bottom-style: solid; border-bottom-width: 1px; font-family: Verdana, sans-serif; font-size: 18px; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 2em;">
First step(Basic class definition)</h2>
<ul style="margin-top: 0px;">
<li style="margin-bottom: 0.6em;"><b>private variables</b> are declared with the 'var' keyword inside the object, and can only be accessed by private functions and privileged methods.</li>
<li style="margin-bottom: 0.6em;"><b>private functions</b> are declared inline inside the object's constructor (or alternatively may be defined via <code class="js" style="background-color: #cccccc; color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;"><span class="keyword" style="color: #0000cc;">var</span> functionName=<span class="keyword" style="color: #0000cc;">function</span><span class="paren" style="color: #990000; font-weight: bold;">(){</span>...<span class="paren" style="color: #990000; font-weight: bold;">}</span></code>) and may only be called by privileged methods (including the object's constructor).</li>
<li style="margin-bottom: 0.6em;"><b>privileged methods</b> are declared with <code class="js" style="background-color: #cccccc; color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;">this.methodName=<span class="keyword" style="color: #0000cc;">function</span><span class="paren" style="color: #990000; font-weight: bold;">(){</span>...<span class="paren" style="color: #990000; font-weight: bold;">}</span></code> and may invoked by code external to the object.</li>
<li style="margin-bottom: 0.6em;"><b>public properties</b> are declared with <code class="js" style="background-color: #cccccc; color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;">this.variableName</code> and may be read/written from outside the object.</li>
<li style="margin-bottom: 0.6em;"><b>public methods</b> are defined by <code class="js" style="background-color: #cccccc; color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;">Classname.<span class="keyword" style="color: #0000cc;">prototype</span>.methodName = <span class="keyword" style="color: #0000cc;">function</span><span class="paren" style="color: #990000; font-weight: bold;">(){</span>...<span class="paren" style="color: #990000; font-weight: bold;">}</span></code> and may be called from outside the object.</li>
<li style="margin-bottom: 0.6em;"><b>prototype properties</b> are defined by <code class="js" style="background-color: #cccccc; color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;">Classname.<span class="keyword" style="color: #0000cc;">prototype</span>.propertyName = someValue</code></li>
<li style="margin-bottom: 0.6em;"><b>static properties</b> are defined by <code class="js" style="background-color: #cccccc; color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;">Classname.propertyName = someValue</code></li>
</ul>
<pre class="brush: js">function Mammal(name){
//private var
var id;
//private method
var set_id = function(){
id = Mammal.id++;
}
//public property
this.name=name;
this.offspring=[];
//privileged method
this.getId = function(){
return id;
}
//constructor
set_id();
}
//public methods
Mammal.prototype.haveABaby=function(){
var newBaby=new Mammal("Baby "+this.name);
this.offspring.push(newBaby);
return newBaby;
}
Mammal.prototype.toString=function(){
return '[Mammal "'+this.name+'"]';
}
//static property
Mammal.id = 1;</pre>
<span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;"></span><br />
<h2 style="border-bottom-color: rgb(153, 153, 153); border-bottom-style: solid; border-bottom-width: 1px; font-family: Verdana, sans-serif; font-size: 18px; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 2em;">
<span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;">Second step(Inheritance)</span></h2>
<ul style="margin-top: 0px;">
<li style="margin-bottom: 0.6em;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;">You cause a class to inherit using <span class="Apple-style-span" style="background-color: #cccccc;"><code class="js" style="color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;">ChildClassName.<span class="keyword" style="color: #0000cc;">prototype</span> = <span class="keyword" style="color: #0000cc;">new</span>ParentClass<span class="paren" style="color: #990000; font-weight: bold;">()</span>;</code>.</span></span></li>
<span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal;">
<li style="margin-bottom: 0.6em;">You need to remember to reset the <span class="Apple-style-span" style="background-color: #cccccc;"><code class="js" style="color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;"><span class="keyword" style="color: #0000cc;">constructor</span></code> </span>property for the class using <span class="Apple-style-span" style="background-color: #cccccc;"><code class="js" style="color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;">ChildClassName.<span class="keyword" style="color: #0000cc;">prototype</span>.<span class="keyword" style="color: #0000cc;">constructor</span>=ChildClassName</code>.</span></li>
<li style="margin-bottom: 0.6em;">You can call ancestor class methods which your child class has overridden using the <code class="js" style="background-color: #cccccc; color: #006600; font-family: Courier, 'Courier New', monospace; font-size: 16px;"><span class="keyword" style="color: #0000cc;">Function</span>.call<span class="paren" style="color: #990000; font-weight: bold;">()</span></code> method.</li>
<li style="margin-bottom: 0.6em;">Javascript does not support protected methods .</li>
</span></ul>
<div>
</div>
<br />
<pre class="brush: js">Cat.prototype = new Mammal(); // Here's where the inheritance occurs
Cat.prototype.constructor=Cat; // Otherwise instances of Cat would have a constructor of Mammal
function Cat(name){
this.name=name;
}
Cat.prototype.toString=function(){
return '[Cat "'+this.name+'"]';
}
var someAnimal = new Mammal('Mr. Biggles');
var myPet = new Cat('Felix');
alert('someAnimal is '+someAnimal); // results in 'someAnimal is [Mammal "Mr. Biggles"]'
alert('myPet is '+myPet); // results in 'myPet is [Cat "Felix"]'
myPet.haveABaby(); // calls a method inherited from Mammal
alert(myPet.offspring.length); // shows that the cat has one baby now
alert(myPet.offspring[0]); // results in '[Mammal "Baby Felix"]'
</pre>
Using the .constructor property<br />
<pre class="brush: js">Mammal.prototype.haveABaby=function(){
var newBaby=new this.constructor("Baby "+this.name);
this.offspring.push(newBaby);
return newBaby;
}
...
myPet.haveABaby(); // Same as before: calls the method inherited from Mammal
alert(myPet.offspring[0]);
</pre>
Calling 'super' methods<br />
<br />
<pre class="brush: js">Cat.prototype.haveABaby=function(){
Mammal.prototype.haveABaby.call(this);
alert("mew!");
}
</pre>
<br />
Making your own 'super' property<br />
<br />
<pre class="brush: js">Cat.prototype = new Mammal();
Cat.prototype.constructor=Cat;
Cat.prototype.parent = Mammal.prototype;
...
Cat.prototype.haveABaby=function(){
var theKitten = this.parent.haveABaby.call(this);
alert("mew!");
return theKitten;
}
</pre>
<br />
Spoofing pure virtual classes<br />
<br />
<pre class="brush: js">LivingThing = {
beBorn : function(){
this.alive=true;
}
}
...
Mammal.prototype = LivingThing;
Mammal.prototype.parent = LivingThing; //Note: not 'LivingThing.prototype'
Mammal.prototype.haveABaby=function(){
this.parent.beBorn.call(this);
var newBaby=new this.constructor("Baby "+this.name);
this.offspring.push(newBaby);
return newBaby;
}
</pre>
<br />
Convenient Inheritance<br />
<br />
<pre class="brush: js">Function.prototype.inheritsFrom = function( parentClassOrObject ){
if ( parentClassOrObject.constructor == Function )
{
//Normal Inheritance
this.prototype = new parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject.prototype;
}
else
{
//Pure Virtual Inheritance
this.prototype = parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject;
}
return this;
}
//
//
LivingThing = {
beBorn : function(){
this.alive = true;
}
}
//
//
function Mammal(name){
this.name=name;
this.offspring=[];
}
Mammal.inheritsFrom( LivingThing );
Mammal.prototype.haveABaby=function(){
this.parent.beBorn.call(this);
var newBaby = new this.constructor( "Baby " + this.name );
this.offspring.push(newBaby);
return newBaby;
}
//
//
function Cat( name ){
this.name=name;
}
Cat.inheritsFrom( Mammal );
Cat.prototype.haveABaby=function(){
var theKitten = this.parent.haveABaby.call(this);
alert("mew!");
return theKitten;
}
Cat.prototype.toString=function(){
return '[Cat "'+this.name+'"]';
}
//
//
var felix = new Cat( "Felix" );
var kitten = felix.haveABaby( ); // mew!
alert( kitten ); // [Cat "Baby Felix"]
</pre>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0tag:blogger.com,1999:blog-1061659397956632676.post-67027225013323128342011-09-24T23:42:00.000-07:002011-12-18T07:37:10.471-08:00Adding syntax hilighterFirst things first:<br />
<a href="http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html">Installation</a> and <a href="http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/">brushes</a>. <br />
<br />
This needs adding to the head of the blog html:<br />
<span class="Apple-style-span" style="font-size: x-small;">*Design -> Edit html -> under the "</span><span class="Apple-style-span" style="background-color: black; color: #f3f3f3;"><b><head></b></span><span class="Apple-style-span" style="font-size: x-small;">" tag</span><br />
<pre class="brush: html"><link href="http://sites.google.com/site/bloggermintcom/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://sites.google.com/site/bloggermintcom/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://sites.google.com/site/bloggermintcom/shCore.js" type="text/javascript">
</script>
<script src="http://sites.google.com/site/bloggermintcom/shBrushCss.js" type="text/javascript">
</script>
<script src="http://sites.google.com/site/bloggermintcom/shBrushJScript.js" type="text/javascript">
</script>
<script src="http://sites.google.com/site/bloggermintcom/shBrushXml.js" type="text/javascript">
</script>
<script type="text/javascript">
SyntaxHighlighter.all()
</script>
</pre>
Add this when you want to add code: <br />
<span class="Apple-style-span" style="font-size: x-small;">*You will need to switch to the HTML view when editing the post in order to add the "</span><span class="Apple-style-span" style="background-color: black;"><span class="Apple-style-span" style="color: #f3f3f3;"><b><pre></b></span></span><span class="Apple-style-span" style="font-size: x-small;">" tag</span><br />
<pre class="brush: html"><pre class="brush: brush_name">
Your script here
</pre>
</pre>
<span class="Apple-style-span" style="font-size: x-small;">*brush_name can be js,perl,as3,etc. For a complete list see: <a href="http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/">brushes</a></span><br />
<br />
UPDATE:<br />
<br />
<br />
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 11pt; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;">
I recently installed syntaxhighlighter. The useful JavaScript tool for professional formatting of code blocks for blogs etc. by <a href="http://alexgorbatchev.com/SyntaxHighlighter/" style="color: #465e92; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;">Alex Gorbatchev.</a></div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 11pt; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;">
I followed the installation guide correctly adding the <em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">shCore.js</em> and brush scripts I needed. I also included <em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">shCore.css</em> and <em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">shThemeDefault.css</em> style files, but I kept getting the same JavaScript error: <b style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">XregExp not defined</b> in shCore.js</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 11pt; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;">
It turns out after a lot of trial and error that you do not use the JavaScript files in the "<b style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">/src/</em></b>" folder of the download files. These do not work. You must use the 3 files with the same name in the "<b style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">/scripts/</em></b>" folder.</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 11pt; margin-bottom: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left;">
Just to clarify the 3 files are, <em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">shCore.js, shLegacy.js</em> and <em style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">shAutoloader.js</em></div>Anonymoushttp://www.blogger.com/profile/17765796144441897068noreply@blogger.com0