Skip to content

Instantly share code, notes, and snippets.

@brandoncc
brandoncc / creating_rails_app.md
Last active December 11, 2024 05:19
Creating a new Rails app with nix and devenv
  1. mkdir hello_world
  2. cd hello_world
  3. devenv init
  4. devenv inputs add nixpkgs-ruby github:bobvanderlinden/nixpkgs-ruby --follows nixpkgs
  5. direnv allow .
  6. echo ruby-3.3.6 > .ruby-version (use most recent version of Ruby)
  7. Change the content of devenv.nix to:
    { pkgs, lib, config, inputs, ... }:
@brandoncc
brandoncc / how to install mysql2 gem in devenv.md
Last active November 27, 2024 02:17
mysql2 ruby gem nix devenv config

Option 1

Make sure these are in devenv.nix

  packages = with pkgs; [
    libmysqlclient
  ];

 services.mysql = {

Add this to devenv.nix

env.NIX_CFLAGS_COMPILE = "-I ${libxml2.dev}/include/libxml2"
@brandoncc
brandoncc / woocommerce_sales_by_year_and_state.php
Created September 19, 2023 14:25
Generate a page of tables containing sales totals for all US sales in WooCommerce, grouped by year then state
<?php
function format_as_currency( $amount ) {
return '$' . number_format( $amount, 2 );
}
function get_sales_by_year( $orders ) {
$sales_by_year = array();
foreach ( $orders as $order_id ) {
const rules = require('./webpack.rules');
const plugins = require('./webpack.plugins');
rules.push({
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
});
module.exports = {
module: {
@brandoncc
brandoncc / install_vips.sh
Created October 22, 2020 17:44
Install libvips on ubuntu
apt-get update && apt-get install -y \
build-essential \
autoconf \
automake \
libtool \
intltool \
gtk-doc-tools \
unzip \
wget \
git \
import React from "react";
import { LandingPad } from "./Portal";
export default function Article() {
return (
<div>
<LandingPad />
<h1>Here is a latin article</h1>
<p>
import React from "react";
import { Portal } from "./Portal";
export default function FlashMessage() {
return (
<Portal>
<div class="alert alert-primary" role="alert">
This is a special announcement, be sure and read it!
</div>
import React, { useRef, useEffect } from "react";
import ReactDOM from "react-dom";
export function LandingPad() {
return <div id="portal-root" />;
}
export function Portal (props) {
const elRef = useRef(document.createElement("div"));
const rootRef = useRef();
import React, { useRef, useEffect } from "react";
import ReactDOM from "react-dom";
export default function Portal (props) {
const elRef = useRef(document.createElement("div"));
const rootRef = useRef();
useEffect(() => {
rootRef.current = document && document.getElementById("portal-root");
rootRef.current && rootRef.current.appendChild(elRef.current);