Skip to content

Instantly share code, notes, and snippets.

View flangofas's full-sized avatar
🎯
Focusing

Antonis Flangofas flangofas

🎯
Focusing
View GitHub Profile
@flangofas
flangofas / gist:dcbb0cdc3bc4d795c1c1
Last active August 29, 2015 14:02
Find replace bash executable PHP script
#!/usr/bin/php
<?php
/**
* Find replace tool
* Place it in the executable folder "/usr/local/sbin/"
* Also, add an alias in the ~/.bashrc
* Option should be -e for execute
* Otherwise view the files only that contain the search term
* Author: Antonis Flangofas
* Date: 01/06/2014
@flangofas
flangofas / Fibonacci
Created August 3, 2014 20:21
Fibonacci sequence
<?php
echo fibonacciCode($argv[1]) . PHP_EOL;
/**
* This function returns the fibonacci sequence
*
* @param mixed sequence
* @return int total
*/
@flangofas
flangofas / .vimrc
Created August 10, 2014 18:39
My .vimrc
syntax on
set number
set wrap
set laststatus=2 " Always show the statusline
set title " Set the title of the window in the terminal to the file
set history=500 " History
set backup
"Followin cmd must be configure with X11
set clipboard+=unnamed " Yank to system clipboard
set showcmd " Display an incomplete command in the lower right corner of the Vim window
@flangofas
flangofas / FindReplace.php
Last active August 29, 2015 14:05
Find and Replace using CSV
<?php
class FindReplace{
const TOKEN = '&&';
const HYPHEN = '-';
const TARGETDIR = 'modified';
const TEMPLATESDIR = 'templates';
public $data = array();
public $filename;
@flangofas
flangofas / wordcounter.php
Created August 17, 2014 23:39
Count words from text file
<?php
/*
* Count number of words from the given txt file
* @author Antonis Flangofas
* @date 18/08/2014
*/
class WordCounter
{
const ASC = 2;
const DESC = 4;
@flangofas
flangofas / observers.php
Last active August 29, 2015 14:12 — forked from mt3o/observers.php
<?php
class MyObserver implements SplObserver {
public function update(SplSubject $subject) {
echo __CLASS__ . ' - ' . $subject->getName();
}
}
class MySubject implements SplSubject {
private $_observers;
@flangofas
flangofas / last_segment
Created January 29, 2015 14:57
Get last segment from URL
/**
* Get last segment from URL
* @note array.filter browser support: IE.9+, Firefox 1.5 +
* @return string URL last segment
*/
function getLastSegmentFromUrl() {
path = window.location.pathname;
segments = path.split('/');
//remove empty spaces
segments = segments.filter(function(item) {
<?php
// CORE/app/models/datasources/json_source.php
/**
* JSON Source module for CakePHP.
*
* @package cake
*/
@flangofas
flangofas / local-storage.html
Created March 12, 2015 22:17
Simple example of local storage - HTML5 API
<!DOCTYPE html>
<html lang="en">
<head>
<title>Web Storage Example</title>
<meta charset="UTF-8" />
<script>
window.addEventListener('load', function(event) {
var key = document.getElementById('key');
var value = document.getElementById('value');
var add = document.getElementById('add');
@flangofas
flangofas / aliases.sh
Last active August 29, 2015 14:22
Favorite aliases
#Bring current branch up to date with master one
alias git-sync="git checkout master && git pull origin master && git checkout - && git merge master"