Skip to content

Instantly share code, notes, and snippets.

@PEM-FR
PEM-FR / widget.custom.MorphBox.js
Created March 1, 2011 16:03
[enhancement] - dijit.form.ValidationTextBox : MorphTextBox with an example of textArea
dojo.provide("widget.custom.MorphBox");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.form.Textarea");
dojo.declare(
"widget.custom.MorphBox",
dijit._Contained,
{
// morphValidationTest : function
@PEM-FR
PEM-FR / widget.dnd.MultiAreaManager.js
Created March 14, 2011 15:18
[enhancement] - dojox.mdnd.areaManager : A class to add support of multiple nested areas
// Author : PEM-FR (on github), PEM on #dojo on freenode, PEM_FR on dojofoundation
dojo.provide("widget.dnd.MultiAreaManager");
dojo.require("dojox.mdnd.AreaManager");
dojo.require("dojox.mdnd.DropIndicator");
//Attention : for instance this code only work for OverDropMode :)
dojo.require("dojox.mdnd.dropMode.OverDropMode");
dojo.declare(
@PEM-FR
PEM-FR / Grid_connect_on_Row_Clicks.js
Created April 5, 2011 09:11
Grid connect on Row Clicks
this.connect(
this.someGrid,
"onRowDblClick",
this,
function(e){
var grid = this.someGrid;
var rowIndex = grid.selection.selectedIndex;
var myStoreItem = grid.getItem(rowIndex);
this.someCallbackFunction(myStoreItem);
}
@PEM-FR
PEM-FR / hex_color_generator.js
Created May 20, 2011 14:36
Hex color generator
dojo.style(
zone,
"border",
"2px solid #" + ("00000"+(Math.random()*16777216<<0).toString(16)).substr(-6)
);
@PEM-FR
PEM-FR / gist:1044970
Created June 24, 2011 15:07
Find and select the tab of a TabContainer parent of currentWidget
// this, is the tabContainer
findAndSelectTab : function(currentWidget){
var tabContainerId = this.get('id');
var parent = null;
var tab = null;
if(undefined != currentWidget.getParent
&& undefined != typeof(currentWidget.getParent())){
parent = currentWidget.getParent();
}else{
@PEM-FR
PEM-FR / onStyleRow.js
Created July 15, 2011 10:35
example of onStyleRow
styleRow : function (inRow){
with(inRow){
customStyles += " color: orange;";
dojox.grid.DataGrid.prototype.onStyleRow.apply(this.grid, arguments); // here the function is called through a hitch, hence this.grid
}
},
@PEM-FR
PEM-FR / unCacheItem.js
Created September 22, 2011 14:12
A function to clean an item from a dojox.data.JsonRestStore without sending a delete req to the server
unCacheItem: function(item){
// summary:
// deletes item and any references to that item from the store.
// No request will be issued serverside
// extend dojox.data.JRS, and put this function in
// item:
// item to delete
//
// If the desire is to delete only one reference, unsetAttribute or
@PEM-FR
PEM-FR / biasedMonty.php
Created October 28, 2011 14:17
biasedMonty
<?php
$results = array();
$wrongs = array();
for ($i = 0; $i < 100000; $i++) {
$result[$i] = mt_rand(1,3);
$wrongs[$i][0] = ($result[$i] - 1 == 0) ? 3 : $result[$i] - 1;
$wrongs[$i][1] = 6 - $result[$i] - $wrongs[$i][0];
}
@PEM-FR
PEM-FR / lolcatz.php
Created June 28, 2012 08:49
dep injection
protected $_serviceFactory;
/**
*You can inject a mock factory here for unit testing
*
*/
public function setServiceFactory(ServiceFactory $serviceFactory)
{
$this->_serviceFactory = $serviceFactory;
}
@PEM-FR
PEM-FR / meeting_summary.py
Created September 7, 2012 18:37
meeting summary module for phenny
#!/usr/bin/env python
"""
meeting_summary.py - Phenny meeting_summary Module
"""
import datetime as dt
from tools import deprecated
startTime = 0
stopTime = 0