Skip to content

Instantly share code, notes, and snippets.

View drakakisgeo's full-sized avatar

Drakakis George drakakisgeo

View GitHub Profile
@drakakisgeo
drakakisgeo / gist:3596588
Created September 2, 2012 10:33 — forked from hileon/gist:1311735
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Windows)

General

Ctrl+KB toggle side bar
Ctrl+Shift+P command prompt
Ctrl+` python console
Ctrl+N new file

Editing

@drakakisgeo
drakakisgeo / mysql_load_data_func
Created September 4, 2012 17:32
Function to mysql LOAD DATA
function create_load_data_file($arrayofdata,$numcolumns,$pathtofile,$dbtable){
// Create the txt structure
$i = 0;
foreach($arrayofdata as $column){
$txtcontent .= $column."\t";
++$i;
if(($i % $numcolumns) == 0){ $txtcontent .= "\r\n";}
}
@drakakisgeo
drakakisgeo / gist:3783103
Created September 25, 2012 16:52
Laravel:Grab any input that starts with a $string and create validation rules array
function get_jsfields($input,$begins_with,$numpos,$validation_string){
$jsfields = array();
$getkeys = array_keys($input);
for($i=0;$i<sizeof($getkeys);$i++){
if(preg_match("/$begins_with/i", trim($getkeys[$i]))){
$jsfields[$begins_with.$getkeys[$i][$numpos-1]] = ''.$validation_string.'';
}
}
return $jsfields;
}
@drakakisgeo
drakakisgeo / is_date.php
Created September 25, 2012 18:45
Checks value IF is a valid date
function is_date($date){
// date example mm-dd-year -> 09-25-2012
$datechunks = explode("-",$date);
if(sizeof($datechunks)==3){
if(is_numeric($datechunks[0]) && is_numeric($datechunks[1]) && is_numeric($datechunks[2]))
{
// now check if its a valid date
if(checkdate($datechunks[0], $datechunks[1], $datechunks[2])){
return true;
}else{
@drakakisgeo
drakakisgeo / gist:3874690
Created October 11, 2012 18:54
Random quote without DB from a csv file
<?php
/*
----FEATURES----
1. DOESN'T NEED A DATABASE
2. EASY TO SHARE WITH ANYBODY - ITS JUST A CSV FILE SO MANY PEOPLE CAN GIVE YOU QUOTES!
3. STRIPS ANY PROBLEMATIC CHARACTER SO YOU CAN PLAY WITH YOUR OWN QUOTE SYMBOLS ( VIA CSS)
4. CAN STYLE IT BY CSS
@drakakisgeo
drakakisgeo / gist:4183073
Created December 1, 2012 16:17
Csv File to multidimentional Array
function csv2array($file,$head=true,$delim=",",$len=1000) {
$return = false;
$handle = fopen($file, "r");
if ($head) {
$header = fgetcsv($handle, $len, $delim);
}
while (($data = fgetcsv($handle, $len, $delim)) !== FALSE) {
if ($head AND isset($header)) {
foreach ($header as $key=>$heading) {
$row[$heading]=(isset($data[$key])) ? $data[$key] : '';
@drakakisgeo
drakakisgeo / gist:4694360
Created February 1, 2013 21:43
PHPUnit Xml setup
<phpunit bootstrap="vendor/autoload.php"
colors = "true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxcheck="false"
>
<testsuites>
<testsuite name="App Tests">
@drakakisgeo
drakakisgeo / gist:4721560
Created February 6, 2013 10:00
Virtuemart 2.0.18a: Short Manufacturers by Name ASC in dropdown list @ product listing view
# Filter Manufacturers shorting by name ASC
FILE : administrator\components\com_virtuemart\models\manufacturer.php
LINE: around 103
REPLACE:
$query = "SELECT `virtuemart_manufacturer_id` AS `value`, `mf_name` AS text, '' AS disable
FROM `#__virtuemart_manufacturers_".VMLANG."`";
@drakakisgeo
drakakisgeo / gist:4751649
Created February 11, 2013 00:15
Snippets for new projects
##########################################
# NEW HTML5 DOC
##########################################
<!doctype html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Default Page Title</title>
<link rel="shortcut icon" href="favicon.ico">
@drakakisgeo
drakakisgeo / .htaccess
Created July 5, 2013 15:38
Joomla .htaccess for extra security
###############################################################################
## The Master .htaccess
##
## Version 2.5 (proposed) - May 16th, 2011
##
## ----------
## This file is designed to be the template .htaccess file to put on your new
## sites, increasing your site's security and performance. It is not meant to
## be just dropped in your site, though. You should go through all of its
## sections and modify it to match your site. Most notably, all instances of