Skip to content

Instantly share code, notes, and snippets.

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
@dblencowe
dblencowe / distributed-mediasoup.js
Created September 25, 2020 16:05 — forked from gurupras/distributed-mediasoup.js
mediasoup horizontal scaling
onServerStartup () {
const { serverId, ip } = getServerInfo() // serverId does not change across restarts
this.serverId = serverId
// We don't have any routers or producers (yet). Clear any value that exists in the DB related to our serverId
clearSharedDB(serverId, 'routers')
clearSharedDB(serverId, 'producers')
// Update the DB with our serverId and ip so that others will know how to reach us
registerServerInDB(serverId, ip)
@dblencowe
dblencowe / cdk\bin\backend.ts
Created August 13, 2020 09:32
Load objects from Amplify for use in CDK
import {TableNames} from "../tables.json"
const applicationTables: {[id: string]: string} = {}
for (const DynamoTable of TableNames) {
applicationTables[DynamoTable.split('-')[0]] = DynamoTable
}
console.log(applicationTables.MyGraphqlTable)
# .deploy/terraform/static-site/variables.tf
variable "domain_name" {
type = string
}
# .deploy/terraform/static-site/s3.tf
resource "aws_s3_bucket" "website_bucket" {
bucket = var.domain_name
acl = "public-read"
policy = data.aws_iam_policy_document.website_policy.json
website {
index_document = "index.html"
error_document = "index.html"
}
}

Coding standards

It's really important to follow the guidelines, it saves lots of times when checking PR's...

For php coding guidelines we use this:

Naming conventions

  • use camelCase for variables (ex. $numberOfColumns)
  • use underscores in column names (ex. @ORM\Column(name="number_of_columns"))
@dblencowe
dblencowe / download-humble-bundle.js
Created June 1, 2017 06:44
Download all ebooks from Humble Bundle
# Paste in to console when on download page
$('a').each(function(i){
if ($.trim($(this).text()) == 'MOBI' || $.trim($(this).text()) == 'PDF' || $.trim($(this).text()) == 'EPUB') {
$('body').append('<iframe id="dl_iframe_'+i+'" style="display:none;">');
document.getElementById('dl_iframe_'+i).src = $(this).data('web');
}
});
@dblencowe
dblencowe / update-ip.sh
Created January 9, 2017 10:33
Get a public IP and write it to /etc/hosts
#!/usr/bin/env bash
IP=`aws ec2 describe-instances --profile lfc-staging --filters "Name=tag:machinetype,Values=web" | grep -m 1 PrivateIpAddress | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'`
sed -i -e "s/.*lfc-staging$/$IP lfc-staging/g" /etc/hosts
@dblencowe
dblencowe / SilexServerValetDriver.php
Created September 8, 2016 14:52
A Laravel Valet Driver for running Silex installations
<?php
class SilexServerValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@dblencowe
dblencowe / AnchorCmsValetDriver.php
Created May 14, 2016 10:09
Anchor CMS driver for Valet from Laravel
<?php
class AnchorCmsValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri