Skip to content

Instantly share code, notes, and snippets.

@Garbee
Garbee / gist:6875041
Created October 7, 2013 21:12
Tinker quick tip.

Laravel has an awesome command called "tinker". This is just a really quick way for you to interact with your application in the command line. It has a great use for debugging new models. Let's check out a quick example:

php artisan tinker

You are now dropped into a PHP terminal. Here you can input whatever you want to execute, like the following.

$user = new User;
$user->first_name = Adam;
@Garbee
Garbee / hashTimeTest.php
Created April 11, 2014 18:51
Test PHP password_hash timing
<?php
$timeTarget = 0.2;
$cost = 9;
do {
$cost++;
$start = microtime(true);
password_hash("test", PASSWORD_BCRYPT, ["cost" => $cost]);
$end = microtime(true);
} while (($end - $start) < $timeTarget);
@Garbee
Garbee / install.sh
Last active August 29, 2015 14:00
Install script in progress for vagrant
#!/bin/bash
function upgrade_os {
echo 'Upgrading the OS'
sudo apt-get update > /dev/null
sudo apt-get upgrade -y > /dev/null
}
function essentials {
echo 'Installing essentials'
@Garbee
Garbee / heredoc_var
Created April 29, 2014 17:12
example of conversion
location \/ {
try_files $uri $uri/ /index.php$is_args$args;
}
# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$ {
try_files $uri \/index.php =404;
fastcgi_pass unix:/srv/web/etc/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
@Garbee
Garbee / expires.conf
Last active August 29, 2015 14:02
Server Setup
# Expire rules for static content
# No default expire rule. This config mirrors that of apache as outlined in the
# html5-boilerplate .htaccess file. However, nginx applies rules by location,
# the apache rules are defined by type. A concequence of this difference is that
# if you use no file extension in the url and serve html, with apache you get an
# expire time of 0s, with nginx you'd get an expire header of one month in the
# future (if the default expire rule is 1 month). Therefore, do not use a
# default expire rule with nginx unless your site is completely static
@Garbee
Garbee / 1-global.md
Last active August 29, 2015 14:03
Software compiles

Pre-package setup

This is the stuff to install before you follow any other instructions.

apt install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder checkinstall

build-essential is a meta package for the basics of package building.

@Garbee
Garbee / mariadb_basics.md
Created July 2, 2014 10:18
MariaDB basics

Create Database

CREATE DATABASE {table name};

Create User

CREATE USER '{user name}'@'localhost' IDENTIFIED BY '{pass}';
@Garbee
Garbee / node.sh
Created July 15, 2014 14:21
install node
curl https://raw.githubusercontent.com/creationix/nvm/v0.10.0/install.sh | bash
source ~/.bashrc #.bash_profile,whatever
nvm install 0.10
nvm alias default 0.10
npm install -G nodejs
#complete and happy
@Garbee
Garbee / program.conf
Last active August 29, 2015 14:11
Misc things
[program:{program}]
; command example "php artisan queue:listen --tries=2 --queue=beanstalkd"
command={command}
; Example directory = /srv/web/{site}
directory={directory}
; Example logfile = /srv/web/{site}/storage/logs/supervisor.log
stdout_logfile={logfile}
; Example errlogfile = /srv/web/{site}/storage/logs/supervisor-error.log
stderr_logfile={errlogfile}
redirect_stderr=false
var kuary = new Kuary(window);
kuary.add({
"keys": [
'alt',
'shift',
's'
],
"execute": function() {
window.alert('Alt, Shift, and S pressed');