Skip to content

Instantly share code, notes, and snippets.

View akmur's full-sized avatar

Alessandro Muraro akmur

View GitHub Profile
@akmur
akmur / removedata.js
Created November 3, 2014 10:35
Remove All Data Attributes
$('div').each(function(index, el) {
// Fetch an array of all the data
el = $(el);
var data = el.data(),
i;
// Fetch all the key-names and put them in a variable called keys
var keys = $.map(data , function(value, key) { return key; });
// Loop through the keys, remove the attribute if the key contains "lorem".
for(i = 0; i < keys.length; i++) {
@akmur
akmur / Get Image Field ACF
Last active August 29, 2015 14:08
Get Image Field ACF
<?php
// WP_Query arguments
$args = array (
'post_type' => 'page',
'posts_per_page' => '4',
'post_parent' => 9
);
// The Query
$query = new WP_Query( $args );
@akmur
akmur / virtualhost.txt
Last active December 30, 2023 04:49
Virtualhost Example
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/alex/Web
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
@akmur
akmur / pagenavi - customloop
Last active August 29, 2015 14:01
Pagination of custom loops with pagenavi
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
// WP_Query arguments
$args = array (
'post_status' => 'published',
'paged' => $paged,
'post_per_page' => 10
);
// The Query
@akmur
akmur / touchstart.js
Last active August 29, 2015 14:00
Touchstart
var eventClick = (navigator.userAgent.match(/(iPad|iPhone|Android)/i)) ? "touchstart" : "click";
$('.myselector').bind(eventClick, function(event) {
// do stuff
});
@akmur
akmur / Linux Commands.txt
Last active December 22, 2015 17:59 — forked from barek2k2/Most used linux command
Useful Linux Commands in collaboration with Abdul Barek
Copy directory to remote server from remote server
scp -r sourcedir/ user@dest.com:/dest/dir/
Run a scheduled rake task(lets say update sphinx indexing on every 30 min periodically) on Lunux crontab:
# find where is your rake(which rake)
#m h dom mon dow user command
*/30 * * * * root /bin/bash -l -c 'searchd --stop -c /var/rails/project/current/config/production.sphinx.conf && cd /var/rails/project/current && RAILS_ENV=production /usr/local/bin/rake ts:rebuild && chmod -R 777 tmp/'
Create Symbolic link(Short cut)
ln -s /source/dir destination/dire/short_cut_name
@akmur
akmur / Resursive Callbak.js
Last active December 11, 2015 22:48
funzione che quando chiamata fa una animazione sul primo item, poi in sequenza come callback sui seguenti
function glowNext(jq){
jq.eq(0).animate({"color": "#FFC000"}, 75, function(){
(jq=jq.slice(1)).length && glowNext(jq);
});
};
glowNext($('span.tag'));
@akmur
akmur / Simple email validation.js
Last active December 11, 2015 10:09
Simple email validation
$('input#submit').click(function(){
var email = $('input#email').val();
var flag = true;
$('input.req').each(function(){
// if the input.req is empty...
if ($(this).val() == "") {
$(this).nextAll('span:first').fadeIn();
flag = false;
} else {
// if the input#email field has no @ sign...