Skip to content

Instantly share code, notes, and snippets.

View jbrooksuk's full-sized avatar
🧑‍🚀

James Brooks jbrooksuk

🧑‍🚀
View GitHub Profile
@kconner
kconner / macOS Internals.md
Last active April 19, 2024 20:06
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@defenestrator
defenestrator / laravel_envoyer_migrations_like_a_boss.sh
Last active June 9, 2021 08:13
Laravel Envoyer hook to run migrations in a sane manner
# Application base directory
site= "example.com"
# Navigate to the release being deployed.
cd {{ release }}
# Number of migrations in the new release
releaseMigrations= ls database/migrations | wc -l
# Number of migrations in the current production app
@reinink
reinink / query.sql
Last active November 14, 2023 11:08
Text search across multiple tables using MySQL
select
first_name,
last_name
from
users
left join
companies on companies.id = users.company_id
where (
companies.name like 'TERM%' or
first_name like 'TERM%' or
@Thomvis
Thomvis / SwiftUI-Circular.swift
Last active August 4, 2021 21:41
Rough attempt at creating a container view that lays out its children in a circle #SwiftUI
struct ContentView: View {
@State var count: Int = 3
var body: some View {
return NavigationView {
VStack(spacing: 50) {
HStack {
Button(action: { self.count += 1 }) {
Text("Add")
}
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@adamwathan
adamwathan / promise-take-at-least.js
Last active February 26, 2023 14:25
Promise.takeAtLeast
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {
@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@fdcore
fdcore / pearson_correlation.php
Last active December 29, 2021 20:26
Php simple pearson correlation Function
<?php
function pearson_correlation($x,$y){
if(count($x)!==count($y)){return -1;}
$x=array_values($x);
$y=array_values($y);
$xs=array_sum($x)/count($x);
$ys=array_sum($y)/count($y);
$a=0;$bx=0;$by=0;
for($i=0;$i<count($x);$i++){
@browner12
browner12 / ideas.md
Last active September 22, 2020 17:35
Forge and Envoyer Ideas

Forge

  • Option when creating a new site to automatically make the Laravel schedule:run cron job.
  • Move a lot of the 'helper text' into tooltips. Less cluttered design, especially for experienced users, but still provides the info for those who need it.
  • Move all of the 'create' forms into modals (or separate pages). Brings our list of existing sites or servers above the fold. Again, lends towards a cleaner UX.
  • Similar to the Homestead aliases file, allow us to define and save alias files, that we can can include on the server when we build it.
  • Allow us to define and save different deploy scripts, that we can apply to sites. For example, save a custom one for 'production' deploys, and one for 'staging' deploys.
  • autocomplete="one-time-code" for 2FA token on login.
  • Deploy script variables. {{ sha }}
  • Add alias 'Sites'. A domain that points to another project folder. Essentially what this comes down to (I think) is allowing us to override the base part of the ng
@tpavlek
tpavlek / combinations.php
Created June 2, 2016 22:12
Get all combinations of two collections
<?php
/**
* If you have two sets of collections, which you would previously have used a nested foreach to do something to each unique
* combination of items, you can use this macro to get it done instead!
*
* It will return a collection of tuples that represent the combination of the two collections. If you'd like to add keys to the tuple
* you can pass that in as an optional second argument!
*/