Calcetines Extreme

Calcetines Extreme
Take care of you using the best socks

Saturday, May 23, 2015

Adding #Charts to a website using javascrip with DataBase connection

Problem:   
You have some data in your DataBase that you would like to explode with Charts to offer Analytics solution to your visitors.

Solution:    
One simple way is to use highcharts, a company that has a collection of utilities to paint Charts using a simple script and of course with data base connecction and much more.

Sample:
$dbcon = mysql_connect("localhost", "bartolo", "******");
mysql_select_db("DATABASE", $dbcon);
$result = mysql_query("SELECT * FROM table");
while ($row = mysql_fetch_array($result)) {
   $data[] = "['".$row['name']."',".$row['tot']."]";
}
?>

...
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'pie',
            options3d: { enabled: true, alpha: 45, beta: 0 }
        },
        title: { text: 'Chosse the best Broker' },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {  allowPointSelect: true, cursor: 'pointer', depth: 35,
                dataLabels: { enabled: true, format: '{point.name}' }}
        },
        series: [{
            type: 'pie',             name: 'Browser share',
            data: [  <?php echo join($data, ','); ?> ]
        }]
    });
});
  </script>

...
Source:

 

Wednesday, May 13, 2015

Web Scraper

$request_url ='https://www.google.es/search?q=Barcelona';

// The Regular Expression filter
 $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";

 function get_domain($url)
 {
  $pieces = parse_url($url);
  $domain = isset($pieces['host']) ? $pieces['host'] : '';
  if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
   return $regs['domain'];
  }
  return false;
 }

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $request_url); // The url to get links from

 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // We want to get the respone

 $result = curl_exec($ch);

 $regex='|<a.*?href="(.*?)"|';
 preg_match_all($regex,$result,$parts);
 $title = preg_match('/title="(.+)">/', $html, $match);
 $links=$parts[1];
 asort($links);

 foreach($links as $link){
  $pos = strpos($link, '://');
  $exclude = strpos($link, 'google');  //remove google own results

  if ($pos!=0 && $exclude==0){
    $posini = strpos($link, 'http');
    $link = substr($link, $posini);
    echo "<a href='".$link."'>".get_domain($link)."</a> -> ".$link."<br>";
  }
 }

 curl_close($ch);


Sample:

Sources:

Friday, May 1, 2015

Update joomla metada keywords from MySQL 'update' query

Problem:   

You are too lazy to update keywords from article manager in the backend, and need a quick option to do that without installing any random plugin that do that for you (I found that plugins don't works as you except).

 Solution:    

Go to MySQL administrator page and open your SQL windows to write a new SQL query to update your keywords, the joomla table / field where are stored meta about SEO keywords is _content , and the fieldname is "metakey".
Now with that you only need to run that sample SQL query to update SEO keywords.

SQL Query:
UPDATE *_content SET metakey = 'keyword1,'keyword2,'keyword3,'keyword4,'keyword5'
*Take careful that this query will update all your articles, if you would like to make some filter remember to use SQL conditions like WHERE id=x...

 

Sunday, April 26, 2015

how to rollover on CSS Image

Problem:   

You need to make a rollover on a sprite css image.

 Solution:    

You only need to make a ":rollover" class on your master css file like this:
 ...
.buttons{background-image:url('../images/sprite.png');background-position:-13px -21px}
.buttons:hover{background-image:url('../images/sprite.png');background-position:-13px -21px}
 ...
The tip is to add ":hover" to a different css class, that class will be loaded when the mouse pass over your css image sprite.

Your HTML code remains as:
...
<li class="buttons">&nbsp;</li>
...
 

Monday, February 9, 2015

joomla web too slow load

Problem:   

Your joomla web site spend a lot of time to load, too much time...

 Solution:    


Check if your site has been hacked, look at "include" folder file "joomla_rss.php" and rename it of just delete it.

Saturday, January 17, 2015

Connect Excel 32 Bits to MySQL ODBC in 32 BIts under Windows 64 Bits

Problem:   
You are using Windows 7 in 64 bits and MS Excel in 32 Bits, and you are not able to connect Excel to MysQL trought ODBC DNS 64 Bits.

 Solution:    
You need to create a ODBC for MySQL in 32 Bits to avoid architecture problems while connection Excel and DS over ODBC.
The Solution is full documented on the next link:

Source:
http://stackoverflow.com/questions/25039573/how-to-connect-ms-excel-2007-with-mysql

Friday, January 2, 2015

Adobe JavaScript to sign PDF files

Problem:   
Think that you need to sign a PDF file and add the signed date, you need a quick method to add a digital signature and some text with the date in the PDF file.
To avoid using Acrobat or Photoshop manually to import the image signature and the text label for the date, could be great to make a little script to sign and add variables with the current date.

 Solution:    
If you work with Adobe CSx, you will find some smaple scripts on path that will allow you code a litle script to open source PDF file, import a external image with your signature and add labels to source PDF with current date or some else:
<install path>/Adobe Photoshop CSx/scripting/samples/JavaScript...
You will find next files:
ActiveLayer.jsx
ApplyFilters.jsx
ApplyLayerStyle.jsx
CompareColors.jsx
...

Lets Go to see my Script:

( I edit sample javascript file "OpenDocument.jsx" for make mi own one)

Code:
---
// Copyright 2002-2007. Adobe Systems, Incorporated. All rights reserved. // Open a Photoshop document located in the Photoshop samples folder on the Photoshop CD. // You must first create a File object to pass into the open method.
// enable double clicking from the Macintosh Finder or the Windows Explorer #target photoshop // in case we double clicked the file app.bringToFront(); // on localized builds we pull the $$$/Strings from a .dat file, see documentation for more details $.localize = true; // units for move and scale imported image var strtRulerUnits = app.preferences.rulerUnits; var strtTypeUnits = app.preferences.typeUnits; app.preferences.rulerUnits = Units.INCHES; app.preferences.typeUnits = TypeUnits.POINTS; // Display File Open Dialog filePath = File.openDialog(); var docRef = open( File( filePath )); // suppress all dialogs app.displayDialogs = DialogModes.NO; var textColor = new SolidColor; textColor.rgb.red = 0; textColor.rgb.green = 0; textColor.rgb.blue = 0; // LAYER 1 var doc = open( File("<path to signature image>") ); //select all activeDocument.selection.selectAll() //copy image activeDocument.selection.copy(); //close that document without saving app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); // select the source image activeDocument = docRef; //paste app.activeDocument.paste(); // move var startRulerUnits = app.preferences.rulerUnits; app.preferences.rulerUnits = Units.PIXELS; var cm = 100;//activeDocument.resolution/2.45; var LB = activeDocument.activeLayer.bounds;
activeDocument.activeLayer.translate(-200,1930); app.preferences.rulerUnits = startRulerUnits; // LAYER 2 var myDate = new Date(); myDate = myDate.getDate()+"/"+(myDate.getMonth()+1)+"/"+ myDate.getFullYear(); var newTextLayer = docRef.artLayers.add(); newTextLayer.kind = LayerKind.TEXT; newTextLayer.textItem.contents = myDate; newTextLayer.textItem.position = Array(0.15, 8.6); newTextLayer.textItem.size = 18; newTextLayer.textItem.color = textColor; // SAVE NEW PDF SIGNED var savefname = "<path to new signed pdf files>";
str = filePath.toString(); saveas = str.substr(1,str.length-5) + "signed"; filename = saveas.split("/"); longi = filename.length - 1; savefname = savefname + filename[longi]; var pngFile = new File(savefname ); pngSaveOptions = new PDFSaveOptions(); pngSaveOptions.embedColorProfile = true; pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; pngSaveOptions.matte = MatteType.NONE; pngSaveOptions.quality = 1; activeDocument.saveAs(pngFile, pngSaveOptions, false, Extension.LOWERCASE); app.preferences.rulerUnits = strtRulerUnits; app.preferences.typeUnits = strtTypeUnits;
//free
docRef = null; textColor = null; newTextLayer = null; app.activeDocument.close()

Sources needed: