Skip to content

Instantly share code, notes, and snippets.

View ruizfrontend's full-sized avatar
🎯
Focusing

David ruiz lópez ruizfrontend

🎯
Focusing
View GitHub Profile
@ruizfrontend
ruizfrontend / cleanString
Created January 6, 2015 17:09
Limpia string para usar como nombre de archivo (google spreadsheet)
function cleanString( str ) {
var from = "ÃÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛãàáäâèéëêìíïîòóöôùúüûÑñÇç ",
to = "AAAAAEEEEIIIIOOOOUUUUaaaaaeeeeiiiioooouuuunncc_",
mapping = {};
for(var i = 0, j = from.length; i < j; i++ )
mapping[ from.charAt( i ) ] = to.charAt( i );
var ret = [];
str = str.toLowerCase();
video { width: 400px; height: auto; }
h2 { background: red; margin: 0; }
.video2 { display: block; }
@ruizfrontend
ruizfrontend / waypointsSamples.js
Created July 11, 2013 11:45
waypoints samples
$('ELEMENT').waypoint( function(direction) {
if (direction == 'down') {
console.log($(this).attr('id'), 'disappears top');
} else {
console.log($(this).attr('id'), 'appears top');
}
}, { offset: function(){
return -$(this).height();
}, triggerOnce: true, continuous: true})
@ruizfrontend
ruizfrontend / file.tpl.php
Last active December 17, 2015 22:48
Drupal 7 common theme functions
// _-______Basic translatable string_______________________________
<?php print t('STRING !VARIABLE1 @VARIABLE2 %VARIABLE3', array(
'@VARIABLE2' => 'VALUE ESCAPED & FORMATED',
'%VARIABLE3' => 'VALUE ESCAPED',
'!VARIABLE1' => 'VALUE AS IS',
)); ?>
// _-______string translatable with link_______
// _-______Basic link_______________________________
<?php print l(t('TEXT'), 'URL',
@ruizfrontend
ruizfrontend / query.php
Created April 29, 2013 18:15
Drupal 7 basic node query
$query = db_select('node', 'n');
$query ->condition('n.type', 'NODETYPE', '=');
$query ->condition('n.status', '1', '=');
$query->join('SOMEFIELDTABLE', 'l', 'n.nid = l.entity_id');
$query->fields('n', array('title', 'nid'));
$query->fields('l', array('FIELDCOLUMNNAME'));
$query->orderBy('n.title');
$result = $query->execute();
foreach ($result as $record) {
$.validator.addMethod("dniCheck", function(value, element) {
if(/^([0-9]{8})*[a-zA-Z]+$/.test(value)){
var numero = value.substr(0,value.length-1);
var let = value.substr(value.length-1,1).toUpperCase();
numero = numero % 23;
var letra='TRWAGMYFPDXBNJZSQVHLCKET';
letra = letra.substring(numero,numero+1);
if (letra==let) return true;
return false;
}
@ruizfrontend
ruizfrontend / index.html
Last active February 7, 2016 09:37
Some CSS3 Buttons & counters
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script src="./script.js"></script>
<link rel="stylesheet" href="./style.css">
<div class="bg_blue">
<div class="butt butt-orange"><i class="icon-cart"></i>añadir a la cesta</div>
<br/><br/>
<div class="butt ">add to cart</div>
<br/><br/>
<div class="butt butt-orange butt-big">Checkout</div>
<br/><br/>
@ruizfrontend
ruizfrontend / gist:4656770
Last active December 11, 2015 20:38
Drupal 7 common functions & hooks
<?php
// _-______defining menu elements_______________________________
// (Including tpl theme)
/**
* Implements hook_menu().
*/
function MODULE_menu() {
$items['URL PATH'] = array(
'title' => 'TITLE',
'page callback' => 'CALLBACK FUNCTION',
@ruizfrontend
ruizfrontend / a2file styles
Created September 14, 2012 12:08
css url specific links
/* enlaces externos
^= indica que queremos dar estilo a aquellos enlaces que comiencen por http://
*/
a[href^="http://"]{
padding-right: 20px;
background: url(external.gif) no-repeat center right;
}
/* emails
^= indica que queremos dar estilo a aquellos enlaces que comiencen con mailto:
*/
@ruizfrontend
ruizfrontend / drush-cache-disable.sh
Created September 4, 2012 11:44
Drupal disable all caches
drush vset cache 0
drush vset preprocess_css 0
drush vset preprocess_js 0