Skip to content

Instantly share code, notes, and snippets.

View adrian-enspired's full-sized avatar

Adrian adrian-enspired

View GitHub Profile

conditions: assume the item is undamaged, in good condition, unless specified otherwise. we're not testing items for functionality beyond powering on and having no obvious damage. if you buy something and it has problems, we'll work it out.

photos: you can find photos online of most items. if you want photos of a specific item let us know.

shipping: we prefer local pickup. we will ship smaller items for friends & family, for actual cost.

terms

  • NYI - not yet inspected. ask and we'll open it up.
  • anyone - price for anyone off the street
  • family - price for family, friends, coworkers
@adrian-enspired
adrian-enspired / git.config
Created September 30, 2020 13:30
Various useful git aliases
# general shortcuts
###################
# status
s = status
# update working tree
u = add -u
# commit
@adrian-enspired
adrian-enspired / password-tips.md
Last active March 7, 2025 02:36
Password Tips

Password Tips

Choose a password that is long enough, and complex enough, to be difficult to guess. Remember, attackers use specialized software to make millions of guesses per second — it's not just one person typing guesses by hand!

USE

  • Long passwords!
  • Long passwords! Passwords should be 16 characters longer.

given

create table foo (a int, b int);
insert into foo values (1,1),(1,2),(2,1),(2,2),(2,3);

I want to order first by a=1 DESC and second by b, ASC if a=1 and DESC if a<>1.

for example,

select a,b from foo order by a=1 DESC, b ASC;
<?php
/**
* Looks up a value at given path in an array subject
*
* @param array $subject The subject
* @param string $path Delimited path of keys to follow
* @param string $delimiter Path delimiter to use (defaults to .)
* @return mixed The value at the given path if it exists; null otherwise
*/

tables foo and bar can be related via x or y.

           foo
          ------
          foo_id

    foox          fooy
   ------        ------
 foo_id foo_id
#!/bin/bash
#Check if path is not specified, not a full path or help requested. Print help and exit
if [ -z "$1" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$(echo "$1" | cut -c 1)" != "/" ]
then
echo "USAGE: ramdisk [PATH] [BUFFER]"
echo ""
echo " PATH: The location of the file/folder. Must be a FULL PATH"
echo "BUFFER: Specify number of Megabytes larger to make ramdisk (default 1)"
echo ""
@adrian-enspired
adrian-enspired / classlister.mixin.js
Last active March 3, 2017 18:24
riot mixin for converting opts.class to a list.
(function(riot) {
/** resets the classlist from tag options. */
var listClasses = function(tag) {
tag.classlist = tag.opts.class ? tag.opts.class.split(/\s+/) : [];
};
var mixin = {
init: function() {
listClasses(this);
this.on('before-update', function() { listClasses(this); }.bind(this));
},

OK, so you have a filepath made from user input; something like

$path = __DIR__ . "/uploads/{$user_input_filename}"

#1: DO NOT DO THIS. Make up your own directory names. The user has no business picking path names on your server.

#2: Filesystem traversal is bad. If you mean for the given $user_input_filename to be inside the __DIR__ . "/uploads/ directory, take a moment to check.

@adrian-enspired
adrian-enspired / array_extend_recursive.md
Last active March 7, 2025 02:39
array_merge|replace_recursive are frustrating.

say you have two arrays, $a1 and $a2, and you want to combine them.

<?php

$a1 = [
  'a' => 'foo',
  'b' => ['bar']
];
$a2 = [
  'a' => 'bar',