Skip to content

Instantly share code, notes, and snippets.

View decebal's full-sized avatar
🥑

Decebal Dobrica decebal

🥑
View GitHub Profile
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
@decebal
decebal / remote.php
Created January 27, 2012 15:40
display errors on dev ip
if($_SERVER['REMOTE_ADDR'] == '86.120.211.231'){
ini_set("display_errors", 'On');
error_reporting(E_ALL ^ E_NOTICE);
}else{
ini_set("display_errors", 'Off');
}
@decebal
decebal / gist:2404772
Created April 17, 2012 09:09
Sorting values separately as string or numeric
SELECT test_col, SUBSTRING_INDEX(test_col, '', 1) as test_col_str,
SUBSTRING_INDEX(test_col, ' ', -1) + 0 as test_col_num FROM test ORDER
BY test_col_str, test_col_num;
@decebal
decebal / gist:2870495
Created June 4, 2012 19:58 — forked from irobinson/gist:1990828
User File Manager Knockout View
<div id="dnnUserFileManager" class="dnnFileManager dnnClear">
<div class="fm-explorer-wrap dnnLeft">
<div class="fm-breadcrumb">
<p>
<span data-bind="foreach: currentBreadcrumbs">
<!-- ko if: id === $root.chosenFolderId() -->
<span data-bind="text: name"></span>
<!-- /ko -->
<!-- ko if: id !== $root.chosenFolderId() -->
<a href="#" data-bind="text: name, click: $root.goToFolder"></a> /
@decebal
decebal / unzip.php
Created July 2, 2012 14:11
Unzip with php
<?php
function unzip($location,$newLocation){
if(exec("unzip $location",$arr)){
mkdir($newLocation);
for($i = 1;$i< count($arr);$i++){
$file = trim(preg_replace("~inflating: ~","",$arr[$i]));
copy($location.'/'.$file,$newLocation.'/'.$file);
unlink($location.'/'.$file);
}
return TRUE;
@decebal
decebal / gist:3653407
Created September 6, 2012 09:05
Grant privileges
GRANT ALL PRIVILEGES ON db_base.* TO db_user @'%' IDENTIFIED BY 'db_passwd';
@decebal
decebal / gist:3691546
Created September 10, 2012 15:30
no suggestion
sprintf("%04s",$value) leading 0's 4--numar de cifre
@decebal
decebal / gist:3720107
Created September 14, 2012 06:07
Lilly
usort($result, function($a, $b){
if($a['sortkey'] == $b['sortkey']){
return 0;
}else{
return ($a['sortkey'] > $b['sortkey']) ? 1: -1;
}
});
@decebal
decebal / change_collation.sql
Created October 1, 2012 12:14
Change table collation
alter table csshop_products_prospect convert to character set utf8 collate utf8_general_ci
@decebal
decebal / gist:3832373
Created October 4, 2012 09:04
exclude rsync
--exclude 'cs-photos/products'