Skip to content

Instantly share code, notes, and snippets.

View suranyami's full-sized avatar

David Parry suranyami

View GitHub Profile

Developing on an M1 Mac

Lots of our commonly-used OSX development tools have been updated to support Apple's new bespoke silicon, but a few remain incompatible, and it's challenging to work around them individually. In my recent experience several approaches were attempted to work around this - below is the approach we found most consistently successful.

The terminal-based, full emulation approach

Apple provides a tool called Rosetta2 which provides a full emulation layer for any Intel code you might want to run on their new architecture. It's awkward to run each tool we use under emulation individually, though - our approach here is to start our top level process (a terminal app) under emulation, and run all our tools and processes subordinate to that.

  1. Install Rosetta2. softwareupdate --install-rosetta.
  2. Choose / Install a suitable terminal program. OSX comes with the Terminal application - but consider using the much more fully featured `
@carterbryden
carterbryden / AddPostgresTriggerAndFunctionForAllTables.exs
Last active December 18, 2023 08:10
Elixir Phoenix Postgresql migration to add triggers for pubsub to run on every CRUD operation on every table. If a new table is added, it'll automatically add a trigger to that table too.
defmodule MyApp.Repo.Migrations.AddPostgresTriggerAndFunctionForAllTables do
use Ecto.Migration
def up do
# Create a function that broadcasts row changes
execute "
CREATE OR REPLACE FUNCTION broadcast_changes()
RETURNS trigger AS $$
DECLARE
current_row RECORD;
@davesag
davesag / testing_js_promises.md
Created July 27, 2016 00:40
Testing Javascript Promises

Here we have a simple class to be tested that returns a Promise based on the results of an external ResponseProcessor that takes time to execute.

For simplicty we'll assume that the processResponse method won't ever fail.

import {processResponse} from '../utils/response_processor';

const ping = () => {
  return new Promise((resolve, _reject) => {
    const response = processResponse(data);
    resolve(response);
@fran-worley
fran-worley / _form.html.erb
Last active October 23, 2017 23:42
A working example of nested forms just using Reform.
#views/users/_form.html.erb
<%= simple_form_for @form do |f| %>
<%= f.error_notification %>
<%= f.input :name %>
<%= f.input :email %>
<h4>
<%= link_to_add_fields icon(:plus),
@tareksamni
tareksamni / sidekiq.config
Last active March 8, 2016 08:59
AWS Elastic BeansTalk configuration to run Sidekiq after each deployment
## For more details refer to: http://tsamni.com/post/84515089035/sidekiq-performing-background-or-delayed-jobs-with
## .ebextensions/sidekiq.config
commands:
create_post_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq":
mode: "000777"
content: |
@adamico
adamico / collection_check_boxes_input.rb
Last active April 28, 2020 15:12 — forked from mattclar/simple_form.rb
This fork adds a custom horizontal form wrapper and merges append/prepend in a 'group' wrapper
#app/inputs/collection_check_boxes_input.rb
class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
def item_wrapper_class
"checkbox-inline"
end
end
@freshtonic
freshtonic / gist:1390291
Created November 24, 2011 00:00
Run Postgres Specs in Ramdisk
  • This creates a 560mb ramdisk. Adjust the size accordingly. I think the number at the end of the command is the number of disk blocks. They are 2kb in size for me.
  • Restarting postgres is not necessary; you can create the ramdisk and tablespace while postgres is running.
  • You will lose all data in the ramdisk tablespace when you shut your machine down

  $ diskutil erasevolume HFS+ "postgres_ramdisk" `hdiutil attach -nomount ram://1165430`
  Started erase on disk1
  Unmounting disk
  Erasing
 Initialized /dev/rdisk1 as a 569 MB HFS Plus volume
@eric1234
eric1234 / 0_instructions.txt
Created April 9, 2011 01:12
Using Sprockets 2 in Rails 3.0.x with CoffeeScript & SASS
UPDATE: Please see some of the forks for an updated version of this guide. I
myself have moved onto the Rails 3.1 betas to get the asset pipeline. But if
you want to stay on stable there are other folks who are keeping this guide
relevant despite the changes constantly occurring on Sprockets 2. The comments
on this gist will lead you to the right forks. :)
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the