- A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
- lengths are in any unit (ex: pixels)
- code snippets are in JavaScript
angleRad = angleDeg * Math.PI / 180;
<?php | |
function is_federal_holiday(DateTime $date){ | |
$year = $date->format('Y'); | |
$federal_holidays = array_map(function($date_string) use($year){ | |
$date = new DateTime($date_string . ' ' . $year); | |
if ($date->format('l') === 'Saturday') $date->modify('-1 day'); | |
if ($date->format('l') === 'Sunday') $date->modify('+1 day'); | |
return $date; | |
}, [ | |
"january 1", //new year's day |
<!doctype html> | |
<html> | |
<title>400 Error</title> | |
<style> | |
body{text-align:center;position:absolute;width:100%;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);transform:translate(-50%,-50%);} | |
h2,h3{color:#555;font:bold 200%/100px sans-serif;margin:0} | |
h3,p{color:#777;font:normal 150% sans-serif} | |
p{font-size: 100%;font-style:italic;margin-top:2em;} | |
</style> | |
<h2>we didn't understand the request</h2> |
https://api.instagram.com/oauth/authorize/?client_id=[client_id]&redirect_uri=[redirect_uri]&response_type=code | |
curl -F 'client_id=[client_id]' -F 'client_secret=[client_secret]' -F 'grant_type=authorization_code' -F 'redirect_uri=[redirect_url]' -F 'code=[code]' https://api.instagram.com/oauth/access_token |
CREATE TRIGGER `pages_created_at` BEFORE INSERT ON `pages` FOR EACH ROW SET NEW.created_at = UTC_TIMESTAMP(), NEW.updated_at = UTC_TIMESTAMP(), NEW.deleted_at = IF(NEW.deleted_at = "0000-00-00 00:00:00", NULL, NEW.deleted_at) | |
CREATE TRIGGER `pages_updated_at` BEFORE UPDATE ON `pages` FOR EACH ROW SET NEW.updated_at = UTC_TIMESTAMP(), NEW.created_at = OLD.created_at, NEW.deleted_at = IF(NEW.deleted_at = "0000-00-00 00:00:00", NULL, NEW.deleted_at) |
docker ps -a | |
docker logs 6238c4b20e4c | |
cd /var/lib/dokku/plugins | |
git clone https://github.com/Kloadut/dokku-pg-plugin postgresql | |
dokku plugins-install | |
dokku postgresql:create Joel |
#/usr/bin/env ruby | |
require 'nokogiri' | |
require 'open-uri' | |
doc = Nokogiri::HTML(open('https://medium.com')) | |
urls = doc.at_css('.cover-img')["style"].scan(/\('([^\)]*)'\)/) | |
image_src = 'http:'+urls[0][0] | |
ext = image_src.split('.').last | |
random = rand(2**256).to_s(36)[0..7] | |
download_path = "/tmp/#{random}.#{ext}" |
#!/bin/bash | |
if [ $# -eq 0 ]; then | |
echo -e "Usage: $0 site.com \033[32m'alert'\033[0m js" | |
exit | |
fi | |
if [ ! -d /var/www/${1}/public ]; then | |
echo -e "\033[31mfailed:\033[0m ${1} does not exist" | |
exit |
#!/usr/bin/php -q | |
<? | |
chdir(__DIR__); | |
define('VERSION','0.6.5'); | |
define("SITES_PATH",reset(explode(basename(__DIR__),__DIR__))); | |
define("DB_PW",generate_pw()); | |
define("FTP_PW",generate_pw()); | |
define("EMAIL_PW",generate_pw()); | |
define("FINGERPRINT",strtoupper(generate_pw(20))); | |
define("DEVELOPER",trim(get_current_user())); |