Snippets

Some little pieces of code that will help you solve your problems faster.


Check if file exists in Symfony2

Check if file exists in Symfony2 If you want want to check if file exists in Symfony2 and which is not a twig template, you have to create a Twig Extension service and add a file_exists() function or whatever you want to call it in twig. This tutorial is more specific to the issue we have at hand,

How to dump variables in perl

snippets

How to dump variable in perl Have you guys ever needed to dump variables in perl and see its exact contents? I had and was really tricky. The print function is alright for printing scalar variables, but when you try to print a hash and maybe with multiple levels you start to have headaches trying

Read and write and delete a file in perl

snippets

Read and write and delete a file in perl In this article I’m going to try and show you some operation examples to read, write and delete a file in perl using a few methods, like the saying goes … There’s more ways to skin a cat … So yes, more ways to work on a file.

Drag and drop on mobile devices

Drag and drop on mobile devices I had a problem in the past with a draggable and droppable calendar with jQuery and ajax. When you add drag and drop to a web page using JavaScript, such as jQuery UI draggable and droppable, you obtain a problem. The dragging and dropping are intercepted by the phone

How to select all anchors with display block jquery

snippets

How to select all anchors with display block jquery Very often or not, you need to select all the elements from within the DOM, that have their display property set to “block”. Solution

Filter function from jQuery to the rescue. Description: Reduce the set of matched elements to those that match the selector or pass

PHP Simple HTML DOM Parser

domTree

PHP Simple HTML DOM Parser In this tutorial I will show you a great way to parse a webpage with plain PHP, in the same way you do with jquery. The syntax is very native and natural, and you will feel like home using it but first let’s thank the author of this library S.C. Chen

Disable jqueryui calendar days EXCEPT the mondays of every week

datepicker

Disable jqueryui calendar days EXCEPT the mondays of every week Let’s say you want the user to be able to see all days from within the month, but to be able to select only the mondays of every week.

Here is a DEMO. You can disable all “Sundays” by switching from “day == 1”

Transform a csv file to associative array in PHP

csv

 Transform a csv file to associative array in PHP There are a lot of  examples on how to take a CSV file and put it in an array, but the main problem about them is that the header and the rest of the content from the csv are placed on separate keys, both on the

How to do a batch insert in MySQL?

mysql feature

How to do a batch insert in MySQL? In this tutorial, I will present you how to do a batch insert in mysql. Let’s say you want to insert some informations from an array into the database. In order for this to work efficient, you should have more than one information in that array. Why

Disable temporary a foreign key constraint in MySQL

snippets

Disable temporary a foreign key constraint in MySQL Were you in the situation of having a mysql table and wanted to delete some records from it, but you were not allowed due to the constraints of that table? Don’t worry, me too. Or if you use foreign keys in your database tables, you’ll probably have problems

Request an article ←