Skip to content

Instantly share code, notes, and snippets.

View drakakisgeo's full-sized avatar

Drakakis George drakakisgeo

View GitHub Profile
clip < ~/.ssh/id_rsa.pub
@drakakisgeo
drakakisgeo / gist:a8bfd7a3f1dddde2cff9
Created July 20, 2015 14:19
RestWs in Drupal Installation ~ Drush
drush dl restws
drush en restws
drush role-add-perm 'anonymous user' 'access resource node'
@drakakisgeo
drakakisgeo / gist:393b7bdff9e1074679ff
Created September 21, 2015 12:24
My deployphp/deployer notes
1. Make sure the ssh public key of your development is added to the live server. This way you won't need a passowrd. Test this by connecting to it directly ssh user@liveserver
2. Login to live server by `ssh user@liveserver` and create a new ssh key by `ssh-keygen`. MAKE SURE NOT TO INSERT A PASSWORD.
3. Add this public key to your bitbucket or github account that your repository is stored.
4. Make sure that the deploy.php script connects to git without https, for example = set('repository', 'git@bitbucket.org:gdrakakis/checkout.git');
5. Run dep deploy production -vvv to see exacty the running comands.
CPANEL users
---------------
If you can't connect to your live server with ssh, make sure that the user can connect to the server with SSH.
To do this go to "Manage Shell Access" of WHM, select the user and assign him "Normal Shell*"
@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 / google-analytics-for-static-sites.sh
Created December 8, 2015 15:22 — forked from stevenscg/google-analytics-for-static-sites.sh
Add Google Analytics tracking to an existing static website
#!/bin/sh
#
# Add a Google Analytics tag to static website files
# @see http://adambuchanan.me/post/26345221717/updating-google-analytics-code-on-many-static-pages
# Tested on MacOS 10.8.X
#
# Usage:
# Set the GA parameters below
# Execute the script from the top-level of the static site
#