Skip to content

Instantly share code, notes, and snippets.

View glommer's full-sized avatar

Glauber Costa glommer

View GitHub Profile
$ curl -d '{"title": "my first post", "markdown": "Here is our first post"}' http://localhost:8080/dev/posts
{
"id": "19a43957-ef7f-4ebd-8096-2d7e37494e2a",
"title": "my first post",
"markdown": "Here is our first post"
}
$ curl -d '{"title": "my second post", "markdown": "Here is our second post"}' http://localhost:8080/dev/posts
{
$ npm install # install remix' npm packages
$ cp .env.example .env # uses the example environment variables, good enough for testing
$ npm run dev # runs the Remix development server, and also starts ChiselStrike
import { Post } from "../models/Post.ts";
export default Post.crud();
import { ChiselEntity } from "@chiselstrike/api";
export class Post extends ChiselEntity {
title: string;
markdown: string;
}
#[op]
fn op_chisel_relational_query_create(
op_state: &mut OpState,
op_chain: QueryOpChain,
context: ChiselRequestContext,
) -> Result<ResourceId> {
let query_plan = QueryPlan::from_op_chain(
&RequestContext::new(
current_policies(op_state),
current_type_system(op_state),
import { Client } from "../models/Client";
import { Entry } from "../models/Entry";
import { Space } from "../models/Space";
type UserValue = {
op: 'del';
key: string;
} | {
op: 'put';
key: string;
const todos = useSubscribe(rep, async tx => {
return await tx.scan({prefix: 'todo/'}).toArray();
});
return (
<ul>
{todos.map(todo => (
<li key={todo.id}>{todo.text}</li>
))}
</ul>
);
import {Replicache} from "replicache";
const rep = new Replicache({
pushURL: '/api/replicache-push',
pullURL: '/api/replicache-pull',
...
});
f:
xor eax, eax ; exclusive-or to return register
ret
f:
push rbp ; push register into the stack
mov rbp, rsp ; adjust the stack pointer
mov eax, 0 ; set the return register to 0
pop rbp ; pop the stack
ret ; return