Skip to content

Instantly share code, notes, and snippets.

View ahacking's full-sized avatar

Andrew Hacking ahacking

  • Brisbane, Australia
View GitHub Profile
@ahacking
ahacking / chatgpt_prompt.txt
Last active September 28, 2023 03:42
ChatGPT prompt for generation of an Ash Framework resource
Your role is a developer.
The result required is to write an Ash Resource using the Ash DSL, Ash framework and elixir supporting code where required.
The Ash DSL is described at the following links:
https://hexdocs.pm/ash/dsl-ash-resource.html
https://hexdocs.pm/ash/dsl-ash-api.html
https://hexdocs.pm/ash_postgres/get-started-with-postgres.html
https://hexdocs.pm/ash_postgres/dsl-ashpostgres-datalayer.html
https://hexdocs.pm/ash_graphql/getting-started-with-graphql.html
@ahacking
ahacking / app.scss
Created February 10, 2015 23:30
Demonstrate node-sass 2.0.0-beta segfault
@import 'bower_components/bourbon/dist/bourbon';
@import 'bower_components/neat/app/assets/stylesheets/neat';
@ahacking
ahacking / gist:7874a49b64a286941fa6
Last active August 29, 2015 14:06
OS X Data loss workaround

The code below demonstrates a solution that is immune to the Data loss on OS X Broccoli issue and demonstrated in this gist

Save the following code to linktest.js:

var fs = require('fs');

// setup structure
fs.mkdirSync(process.cwd() + '/vendor');
fs.mkdirSync(process.cwd() + '/vendor/my_lib');
fs.writeFileSync(process.cwd() + '/vendor/my_lib/foo.js', '// better than nothing');
@ahacking
ahacking / gist:f9f26d86ac9cbce486c2
Last active August 3, 2022 20:14
Avoiding timing based attacks with Token Authentication

By quantising the time taken for failed lookups we can mitigate timing based attacks. This allows a regular DB or cache lookup on the token to be used without revealing information about how good the candidate match is and thus thwarts timing attacks.

def authenticate_user_from_token!
  auth_token = params[Devise.token_authentication_key]
  if auth_token
    t = Time.now
    if (user = User.where(authentication_token: auth_token).first)
      sign_in user, store: false
 else