Skip to content

Instantly share code, notes, and snippets.

View ddavaham's full-sized avatar
🎯
Focusing

David Davaham ddavaham

🎯
Focusing
View GitHub Profile
@ddavaham
ddavaham / distance.php
Created October 5, 2017 16:35
Calculate the Distance between two points in space with x,y,z values
$distance = sqrt(pow($x2-$x1,2)+pow($y2-$y1,2)+pow($z2-$z1,2))/9.4605284e15
@ddavaham
ddavaham / id_ranges.md
Created December 1, 2017 08:48 — forked from a-tal/id_ranges.md
EVE Online ID ranges
from to description
0 10,000 System items (including junkyards and other special purpose items
500,000 1,000,000 Factions
1,000,000 2,000,000 NPC corporations
3,000,000 4,000,000 NPC characters (agents and NPC corporation CEO's)
9,000,000 10,000,000 Universes
10,000,000 11,000,000 NEW-EDEN Regions
11,000,000 12,000,000 Wormhole Regions
20,000,000 21,000,000 NEW-EDEN Constellations
@ddavaham
ddavaham / macro.md
Created December 2, 2017 17:59 — forked from brunogaspar/macro.md
Recursive Laravel Collection Macros

What?

If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.

Setup

@ddavaham
ddavaham / create-mysql.bash
Created January 8, 2018 15:58 — forked from askz/create-mysql.bash
Simple bash script to create mysql db, user with generated password
#!/bin/bash
# The script will fail at the first error encountered
set -e
PASS=`pwgen -s 40 1`
mysql -uroot <<MYSQL_SCRIPT
CREATE DATABASE $1;
CREATE USER '$1'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost';
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
// remove font size
$formattedMessage = preg_replace('/size="[^"]*[^"]"/', "", $reponse->body);
// remove wrong color
$formattedMessage = preg_replace('/(color="#)[a-f0-9]{2}([a-f0-9]{6}")/', '', $formattedMessage);
// link to kms
$formattedMessage = preg_replace('/<a href="killReport:(\d+):(\w+)">/', '<a href="' . config('base.kmUrl') . 'kill/\1/" target="_blank">', $formattedMessage);
// link fits
$formattedMessage = preg_replace('/<a href="fitting:([\d:;]+)">/', '<a href="' . config('base.osmiumUrl') . 'loadout/dna/\1" target="_blank">', $formattedMessage);
// link system/station
$formattedMessage = preg_replace('/<a href="showinfo:(?:5|3867)\/\/(\d+)">/', '<a href="' . config('base.dotlanUrl') . 'search?q=\1">', $formattedMessage);
$tidy = tidy_parse_string($testString, [
'doctype' => "omit",
'show-body-only' => true
]);
$dom->loadHtml($tidy->value, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
foreach ($dom->getElementsByTagName('font') as $anchor) {
if ($anchor->hasAttribute('size')) {
$anchor->removeAttribute('size');
}
if ($anchor->hasAttribute('color')) {
<?php
namespace SUN\Models;
use SUN\Traits\HasPermissionsTrait;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use SUN\Models\ESI\{Character, Contract, MailHeader, MailingList, Station, Structure, Type};
<?php
namespace SUN\Models\ESI;
use Illuminate\Database\Eloquent\Model;
use SUN\Models\{AccessList,CorporationWallet,Member,MailRecipient};
class Corporation extends Model
{
<?php
namespace SUN\Models\ESI;
use Illuminate\Database\Eloquent\Model;
use SUN\Models\{Member, AccessList};
use SUN\Models\SDE\{Ancestry, Bloodline, Race};
class Character extends Model