Skip to content

Instantly share code, notes, and snippets.

View crishnakh's full-sized avatar
💻
Ey! Listen!

Francisco Gálvez crishnakh

💻
Ey! Listen!
View GitHub Profile
@crishnakh
crishnakh / woocommerce_category_list.sql
Created January 25, 2024 21:36 — forked from tivnet/woocommerce_category_list.sql
WooCommerce category list SQL query
--
-- @author Gregory Karpinsky, http://www.tiv.net/
-- @version 14.05.28
--
SELECT
tp.name Cat,
t.name Subcat
FROM
wp_term_taxonomy tt,
wp_terms t,
@crishnakh
crishnakh / upload.js
Created November 21, 2019 11:51 — forked from iamaddy/upload.js
ajax upload base64 image
function dataURItoBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], { type: 'image/jpeg' });
}
function supportFile (){
# Create background noise profile from mp3
/usr/bin/sox noise.mp3 -n noiseprof noise.prof
# Remove noise from mp3 using profile
/usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21
# Remove silence from mp3
/usr/bin/sox input.mp3 output.mp3 silence -l 1 0.3 5% -1 2.0 5%
# Remove noise and silence in a single command
<?php
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
add_action( 'init', 'register_menu' );
@crishnakh
crishnakh / gist:5115488
Created March 8, 2013 10:08
SQL OsCommerce all zones in one files, contribution somewhere in oscommerce.com. Some ; corrected
INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES
(1, 1, 'BDS', 'Badakhshan'),
(2, 1, 'BDG', 'Badghis'),
(3, 1, 'BGL', 'Baghlan'),
(4, 1, 'BAL', 'Balkh'),
(5, 1, 'BAM', 'Bamian'),
(6, 1, 'FRA', 'Farah'),
(7, 1, 'FYB', 'Faryab'),
(8, 1, 'GHA', 'Ghazni'),
(9, 1, 'GHO', 'Ghowr'),
<?php
function createDateRangeArray($strDateFrom,$strDateTo)
{
// takes two dates formatted as YYYY-MM-DD and creates an
// inclusive array of the dates between the from and to dates.
// could test validity of dates here but I'm already doing
// that in the main script
$aryRange=array();
@crishnakh
crishnakh / gist:4648032
Created January 27, 2013 11:52 — forked from anonymous/gist:4648031
Check email function
<?php
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!preg_match("/^[^@]{1,64}@[^@]{1,255}$/", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
@crishnakh
crishnakh / gist:4615185
Created January 23, 2013 22:42
Save time with SELECT, UPDATE, DELETE queries with PHP Functions. Based on http://www.evoluted.net/thinktank/web-development/time-saving-database-functions
<?php
/*
DATA ARRAY EXAMPLE
$form_data = array(
'first_name' => $first_name,
'last_name' => $last_name,
'email' => $email,
'address1' => $address1,
'address2' => $address2,
'address3' => $address3,
@crishnakh
crishnakh / gist:4526417
Created January 13, 2013 21:59
"This allows you to get contents of any div with ID tag. $matches[0] returns with parent div tag $matches[1] returns with out parent div tag" from http://snipplr.com/view/15302/
<?php
preg_match('/\<div id\=[\"]{0,1}ad_content[\"]{0,1}\>(.*?)\<\/div\>/s', $content['content_body'], $matches);
$content['content_body'] = $matches[1];
?>
@crishnakh
crishnakh / gist:4518055
Created January 12, 2013 13:13
Resta fechas en PHP Formato YYYY-MM-DD
<?php
function restafechas($startDate,$endDate){
list($year, $month, $day) = explode("-", $startDate);
$startDate = mktime(0, 0, 0, $month, $day, $year);
list($year, $month, $day) = explode("-", $endDate);
$endDate = mktime(0, 0, 0, $month, $day, $year);
$totalDays = ($endDate - $startDate)/(60 * 60 * 24);