Strongly inspired by https://gist.github.com/heymonkeyriot/9a2f429caff5c091d5429666fa080403.
On Ubuntu :
sudo apt install python3 python3-pip
import anthropic | |
import os | |
import sys | |
from termcolor import colored | |
from dotenv import load_dotenv | |
class ClaudeAgent: | |
def __init__(self, api_key=None, model="claude-3-7-sonnet-20250219", max_tokens=4000): | |
"""Initialize the Claude agent with API key and model.""" |
# this forces Arena into full screen mode on startup, set back to 3 to reset | |
# note that if you go into the Arena "Graphics" preference panel, it will reset all of these | |
# and you will need to run these commands again | |
defaults write com.wizards.mtga "Screenmanager Fullscreen mode" -integer 0 | |
defaults write com.wizards.mtga "Screenmanager Resolution Use Native" -integer 0 | |
# you can also replace the long complicated integer bit with any other scaled 16:9 | |
# resolution your system supports. | |
# to find the scaled resolutions, go to System Preferences --> Display and then | |
# divide the width by 16 and multiple by 9. on my personal system this ends up |
Strongly inspired by https://gist.github.com/heymonkeyriot/9a2f429caff5c091d5429666fa080403.
On Ubuntu :
sudo apt install python3 python3-pip
import fs from 'fs' | |
import { makeExecutableSchema } from 'graphql-tools' | |
import { graphql } from 'graphql' | |
// the actual resolvers | |
import resolvers from '../src/resolvers' | |
// the mock service | |
import mockMovieService from './mocks/mockMovieService' | |
// a nice structure for test cases | |
// found at https://hackernoon.com/extensive-graphql-testing-57e8760f1c25 |
const { Model, AjvValidator } = require('objection'); | |
const pluralize = require('pluralize'); | |
class BaseModel extends Model { | |
/** | |
* Always use timestamps as default | |
*/ | |
static get timestamps() { | |
return true; | |
} |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#ifdef _MSC_VER | |
#include <intrin.h> /* for rdtscp and clflush */ | |
#pragma optimize("gt",on) | |
#else | |
#include <x86intrin.h> /* for rdtscp and clflush */ | |
#endif |
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands) | |
gpg --gen-key | |
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null` | |
# check current keys: | |
gpg --list-secret-keys --keyid-format LONG | |
# See your gpg public key: | |
gpg --armor --export YOUR_KEY_ID | |
# YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333) |
When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).
When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.
Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.
So let's go through the one query that's worth memorizing to handle your eager loading.
Ok, so, you might know about JavaScript regular expressions. Well, here is a tutorial about them, but written by a 13 year old, so it isn't actually any good!
Regular expressions go between /
characters. Here is an exampe, /hi/
.
Ok, now then. Let's learn how to match the string abc
. Well, that's quite simple.
/abc/
. Yey! So putting letters next to each other makes them match one after the other.
Ok, now, after the second /
we can put a g
to make it match globally, that is, we can extract abc
from xyzabcghi
.