Skip to content

Instantly share code, notes, and snippets.

@dedlim
dedlim / claude_3.5_sonnet_artifacts.xml
Last active June 27, 2024 04:41
Claude 3.5 Sonnet, Full Artifacts System Prompt
<artifacts_info>
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity.
# Good artifacts are...
- Substantial content (>15 lines)
- Content that the user is likely to modify, iterate on, or take ownership of
- Self-contained, complex content that can be understood on its own, without context from the conversation
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations)
- Content likely to be referenced or reused multiple times
@virolea
virolea / index.js
Created October 23, 2019 09:40
Configure axios to automatically set the Rails CSRF token
import axios from 'axios'
const tokenEl = document.getElementsByName('csrf-token')[0]
if (tokenEl) {
const token = tokenEl.getAttribute('content')
axios.defaults.headers.common['X-CSRF-Token'] = token
}
axios.defaults.headers.common['Accept'] = 'application/json'
axios.defaults.headers.post['Content-Type'] = 'application/json'

This is a quick sketch of how I think terminology applies to the various kinds of mocking and test doubles that apply in Go.

In practice, the most effective way to mock things in Go is to use an interface, and then to substitute a specialized testing implementation in place of a real one. Wherever a substitute is used, I think this should be called a "double".

There is one specialization of a "double" and that is a "fake" implementation. Fakes can often have real world uses, e.g: "RamDiskDatabase", but are typically

package main
import (
"fmt"
"time"
"github.com/go-redis/redis"
"github.com/kristoff-it/redis-memolock/go/memolock"
)
func main () {
@rupurt
rupurt / host_and_connect.sh
Last active April 30, 2018 20:36
Host & Connect to tmux session
# Hoster
# Serveo
ssh -R 1500:localhost:22 serveo.net
# ngrok
ngrok tcp 22
# tmux
tmux -S /tmp/pair
chmod 777 /tmp/pair
@Deub27
Deub27 / UIStackView+removeAll.swift
Created November 25, 2017 14:00
Remove all arranged subviews from UIStackView at once
import UIKit
extension UIStackView {
func removeAllArrangedSubviews() {
let removedSubviews = arrangedSubviews.reduce([]) { (allSubviews, subview) -> [UIView] in
self.removeArrangedSubview(subview)
return allSubviews + [subview]
}
@mscoutermarsh
mscoutermarsh / .rubocop.yml
Created October 29, 2017 17:42
Example rubocop file
AllCops:
Exclude:
- db/**/*
- Gemfile
- vendor/**/*
- config/environments/*
- bin/**/*
Rails:
Enabled: true
@DennisWeidmann
DennisWeidmann / NSImageExtension.swift
Last active January 9, 2023 10:10
Convert NSImage to CVPixelBuffer
extension NSImage {
func pixelBuffer() -> CVPixelBuffer? {
let width = self.size.width
let height = self.size.height
let attrs = [kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue,
kCVPixelBufferCGBitmapContextCompatibilityKey: kCFBooleanTrue] as CFDictionary
var pixelBuffer: CVPixelBuffer?
let status = CVPixelBufferCreate(kCFAllocatorDefault,
Int(width),
Int(height),
@benjamincharity
benjamincharity / clearCache.sh
Created March 3, 2017 16:44
Clear the cache for a CircleCI project.
curl -X DELETE https://circleci.com/api/v1/project/:username/:project/build-cache?circle-token=:token
@b-r-o
b-r-o / FrameExtractor.swift
Last active December 9, 2019 15:21
TL;DR?
import UIKit
import AVFoundation
protocol FrameExtractorDelegate: class {
func captured(image: UIImage)
}
class FrameExtractor: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate {
private let position = AVCaptureDevicePosition.front