Skip to content

Instantly share code, notes, and snippets.

View kidsil's full-sized avatar

Asaf Zamir kidsil

View GitHub Profile
@kidsil
kidsil / convert_grayscale
Created October 29, 2014 20:04
Convert all PNG image files to grayscale (creating a copy named Filename_gray.png)
for f in *.png; do
convert ./"$f" -colorspace Gray ./"${f%.png}_gray.png"
done
@kidsil
kidsil / toTitleCase.js
Created October 31, 2014 17:33
To Title Case function on JS
String.prototype.toTitleCase = function() {
return this.replace(/\b\w+/g, function( str ) {
return str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();
});
jQuery(document).ready(function(){
jQuery( SELECTOR ).text( function( i, text ) { return text.toTitleCase() } );
});
@kidsil
kidsil / math_with_regex.js
Created March 20, 2015 14:04
Regex Increase number by one (Regex + Math Calculation)
'text_2_moretext'.replace( /(text_)(\d+)(_moretext)/, function( $0, $1, $2, $3 ) {
return $1 + String( parseInt( $2 ) + 1 ) + $3;
});
test test test
RewriteEngine On
RewriteBase /sfproject/web/
DirectoryIndex index.php
RewriteRule .* /web/index.php/$0 [PT]
RewriteRule ^(?:sf)\b.* /home/sfproject/lib/vendor/symfony/data/web/sf/$0 [L]
//Add this at the start of preprocess_page to add a JS when you ADD or EDIT a certain content type.
if (arg(0) == 'node' && ((arg(1) == 'add' && arg(2) == 'contenttype') || ($vars['node']->type == 'contenttype' && arg(2) == 'edit'))) {
// Add your js file as usual
drupal_add_js('YOURJAVASCRIPT', 'theme');
$vars['scripts'] = drupal_get_js();
// Ensure that the addition has any effect by repopulating the scripts variable
}
drupal_add_js('misc/jquery.urlParser-1.0.0.js', 'theme');
drupal_add_js('misc/ultimatetable.js', 'theme');
$vars['scripts'] = drupal_get_js();
$thisNode = $element['#node'];
//Finding the Key the Product1 is in
$product1Key = 0;
foreach ($header as $key=>$item) {
if (preg_match('/.*Product1.*/',$item)) {
$product1Key = $key;
}
}
$j=1;
$this->template->styles = array_merge($this->template->styles, ui::styles('dropdownchecklist'));
$this->template->scripts = array_merge($this->template->scripts, ui::scripts('dropdownchecklist'));
$hatedstuff = array('Kohana','Mongo','CenterPiece');
foreach ($hatedstuff as $item) {
echo 'I Hate '. $item;
}