const shade = 100;
type Shade = 100;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# ansible 2.9.0 | |
- name: Deploy to production | |
hosts: production | |
remote_user: user | |
vars: | |
app_root: /home/user/apps/my_app | |
tasks: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def join_game(user_id, game_id) do | |
with {:ok, user} <- Users.get(user_id), | |
{:ok, game} <- Games.get(game_id), | |
false <- Game.is_full?(game), | |
false <- Game.is_started?(game), | |
true <- User.has_permission?(user, game) | |
do | |
Game.add_user(game, user) | |
else | |
# Don't care what specific thing failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- (This code was run in PostgreSQL 9.6.1) | |
-- Demonstration of how serializable isolation for PostgreSQL, which detects possible | |
-- interference between concurrent transactions, can produce false positives | |
-- in psql, create the following table | |
CREATE TABLE users( | |
id SERIAL NOT NULL PRIMARY KEY, | |
username VARCHAR NOT NULL | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function cif_validation ($cif) { | |
$cif = strtoupper($cif); | |
if (preg_match('~(^[XYZ\d]\d{7})([TRWAGMYFPDXBNJZSQVHLCKE]$)~', $cif, $parts)) { | |
$control = 'TRWAGMYFPDXBNJZSQVHLCKE'; | |
$nie = array('X', 'Y', 'Z'); | |
$parts[1] = str_replace(array_values($nie), array_keys($nie), $parts[1]); | |
$cheksum = substr($control, $parts[1] % 23, 1); | |
return ($parts[2] == $cheksum); | |
} elseif (preg_match('~(^[ABCDEFGHIJKLMUV])(\d{7})(\d$)~', $cif, $parts)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ErrorDocument 503 /index.html | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule .* /index.html [R=503,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AddDefaultCharset utf-8 | |
ErrorDocument 503 /maintenance.html | |
RewriteEngine On | |
RewriteBase / | |
# uncomment and set your ip to allow your ip to enter | |
#RewriteCond %{REMOTE_ADDR} !1\.2\.3\.4 | |
# block requests to site, but allow let's encypt generation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Strip the namespace from the class to get the actual class name | |
* | |
* @param string $obj Class name with full namespace | |
* | |
* @return string | |
* @access public | |
*/ |
So one of the painful points of using docker
on OS X is that you need to run a virtualbox VM, which often suffers from performance issues. With xhyve, a OS X virtualization system, and docker-machine-xhyve you can now have docker
use the native OS X hypervisor to run containers.
No more dealing with virtualbox shenanigans!
In this script, I've also set up a way to autoconfigure terminal sessions to load docker's environment vars (dependent on docker-machine
) so you do not have to run eval $(docker-machine env whatever)
every time you open a new terminal window.