Skip to content

Instantly share code, notes, and snippets.

View V13Axel's full-sized avatar

Alex Dills V13Axel

View GitHub Profile
@V13Axel
V13Axel / insert_property.py
Created August 6, 2015 13:52
(Naively) Simplifies injecting a property into the constructer as a property, setting it in the constructor, and defining the class property in PHP using Sublime Text. Add {"keys": ["ctrl+i"], "command": "insert_property"} to your sublime keymap, then simply place your cursor on a constructor variable and hit "Ctrl+I"! In-action: http://i.imgur.…
View insert_property.py
import sublime, sublime_plugin
class InsertPropertyCommand(sublime_plugin.TextCommand):
def run(self, edit):
beginningOfClass = self.view.find_all(r"<\?php(.*\n)*class(.*\n*)\{")[0].end()
constructorFirstLinePos = self.view.find_all(r"__construct(.*\n*).*\{")[0]
constructorPos = self.view.find_all(r"__construct(.*\n*){1,10}?\}")[0]
selectionWordPosition = self.view.word(self.view.sel()[0])
constructorFirstLineStr = self.view.substr(constructorFirstLinePos)
@V13Axel
V13Axel / insert_property.py
Created August 6, 2015 13:39
Simplifies injecting a property into the constructer as a property, setting it in the constructor, and defining the class property. I add
View insert_property.py
import sublime, sublime_plugin
class InsertPropertyCommand(sublime_plugin.TextCommand):
def run(self, edit):
beginningOfClass = self.view.find_all(r"<\?php(.*\n)*class(.*\n*)\{")[0].end()
constructorFirstLinePos = self.view.find_all(r"__construct(.*\n*).*\{")[0]
constructorPos = self.view.find_all(r"__construct(.*\n*){1,10}?\}")[0]
selectionWordPosition = self.view.word(self.view.sel()[0])
constructorFirstLineStr = self.view.substr(constructorFirstLinePos)
@V13Axel
V13Axel / setup.sh
Last active August 29, 2015 14:16
Setup a basic Apache server with Laravel
View setup.sh
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
apt-get update
apt-get -y upgrade
apt-get --yes --force-yes install apache2 php5 libapache2-mod-php5 postgresql php5-pgsql php5-mcrypt curl openssh-server git