Skip to content

Instantly share code, notes, and snippets.

@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 / 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');
<?php
public function onLogin(LoginRequest $request, ResponseFactory $response, UrlGenerator $url, SessionStore $session)
{
$this->dispatchFrom(LoginCommand::class, $request);
return $response->json(['redirect'=>$url->to($session->pull('url.intended', '/'))]);
}
<?php
class TranslateCron {
/**
* @var string The cron expression.
*/
protected $expression;
// Just a reminder array for the positions in the expression.
The menu element is used to define a list as a menu of commands. The menu element has two specific attributes as well as can accept global and event attributes in HTML.
The '''menu''' element is currently unsupported by major browsers.
===Attributes===
The '''menu''' element will specifically accept the '''label''' attribute whose value is ''text'' and the '''type''' attribute whose value can be ''context'', ''toolbar'', or ''list''. ''list'' is the default value.
The '''menu''' element also accepts [[html/global_attributes | global attributes]] and [[html/event_attributes | event attributes]].