Skip to content

Instantly share code, notes, and snippets.

View victorteokw's full-sized avatar
🎮
Playing

Victor Teo victorteokw

🎮
Playing
View GitHub Profile
@victorteokw
victorteokw / Ribbon.swift
Created April 8, 2025 05:58
Ribbon on Darwin with SwiftUI
import SwiftUI
struct RibbonShapeTop: Shape {
var extend: CGFloat = .s17
func path(in rect: CGRect) -> Path {
Path { path in
path.move(to: CGPoint(x: rect.minX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.maxX - extend, y: rect.minY))
@victorteokw
victorteokw / main.rs
Created September 4, 2023 09:05
RabbitMQ and TEO
app.setup(|teo: Teo| async {
run_lapin(teo).unwrap();
Ok(())
})?;
fn run_lapin(teo: Teo) -> LapinResult<()> {
let addr = std::env::var("AMQP_ADDR").unwrap_or_else(|_| "amqp://127.0.0.1:5672/%2f".into());
tokio::spawn(async move {
let conn = Connection::connect(
&addr,
@victorteokw
victorteokw / themes.xml
Created July 27, 2023 01:10
Android transparent activity theme
<style name="Theme.Transparent" parent="Theme.AppCompat">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowAnimationStyle">@null</item>
</style>
@victorteokw
victorteokw / cla-teo.md
Last active March 15, 2023 03:41
CLA for TEO

Contributing to TEO

Thank you for contributing code to Teo! Like many projects, we need a contributor license agreement from you before we can merge in your changes.You only need to fill out this agreement once. In brief, by submitting your code to the Teo project, you are granting us a right to use that code under the terms of this Agreement, including providing it to others. You are also certifying that you wrote it, and that you are allowed to license it to us. You are not giving up your copyright in your work. Contributor License Agreements are important because they define the chain of ownership of a piece of software. Some companies won't allow the use of free software without clear agreements around code ownership. That's why many open source projects collect similar agreements from contributors. Please read this document carefully before signing and keep a copy for your records. (You'll get an email confirmation when you electronically sign the CLA.) If you have questions about these terms, or if y

@victorteokw
victorteokw / hello-go-server.go
Created January 10, 2023 05:10
hello-go-server.go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"github.com/gorilla/mux"
@victorteokw
victorteokw / ref_to_mut_ref.rs
Created January 5, 2023 02:54
Turn rust immutable ref into mutable ref
unsafe fn ref_to_mut_ref<T>(reference: &T) -> &mut T {
let const_ptr = reference as *const T;
let mut_ptr = const_ptr as *mut T;
&mut *mut_ptr
}
@victorteokw
victorteokw / toggle.jsx
Created August 22, 2022 15:14
toggle.jsx
import { css } from '@linaria/core'
import React, { FC } from 'react'
import { transformGreenEnd } from '../styles/theme'
interface ToggleProps {
isOn: boolean
toggle?(on: boolean): void
disabled?: boolean
}
@victorteokw
victorteokw / useQueryMutation.ts
Last active August 22, 2022 15:12
useQueryMutation.ts
import { useState, useEffect, useReducer } from "react";
import { Cache } from "webpack";
const refreshers: {[key: string]: (() => void)[]} = {}
interface QueryOptions<T> {
initial?: T
cache?: string
dependencies?: any[]
disabled?: boolean
@victorteokw
victorteokw / aggregate with where.js
Created August 6, 2022 10:01
aggregate with where.js
db.users.aggregate([{
"$lookup": {
"from": "favorites",
"as": "products",
"let": {
"userId": "$_id"
},
"pipeline": [{
"$match": {
"$expr": {
@victorteokw
victorteokw / todo-demo-entry-new-decorator.py
Created November 10, 2021 08:13
todo-demo-entry-new-decorator.py
@jsonclass(
can_create=types.getop.isobj(types.this.fobj('todo_list').fval('owner')),
can_update=types.getop.isobj(types.this.fval('owner')),
can_delete=types.getop.isobj(types.this.fval('owner')),
can_read=types.getop.isobj(types.this.fval('owner'))
)