Skip to content

Instantly share code, notes, and snippets.

import curses
import os
import random
import sys
def get_cell(row_index: int, column_index: int, player: tuple[int, int], target: tuple[int, int]):
if player == (row_index, column_index):
return '¤'
if target == (row_index, column_index):
import { cookies } from "next/headers"
import { db } from "~/server/db/client"
import { procedureFactory } from "~/server/rpc/procedureFactory"
import { z } from "zod"
const getAuthContext = async () => {
const cookie = cookies().get("auth")
if (!cookie) {
return { user: null }
}
@aq1
aq1 / actions.ts
Last active November 22, 2023 21:42
Next Server Action with generic Zod validator
"use server";
// inspired by tRPC
import z from "zod";
const action = <T>(schema: z.Schema<T>) => {
return {
do:
<R>(callback: ({ data }: { data: T }) => Promise<R>) =>
// ==UserScript==
// @name Remove ads
// @namespace whatevernamespace
// @include https://vk.com/
// @version 1
// @grant none
// ==/UserScript==
var removeAdds = function () {
var adsLeft = document.getElementById('ads_left');
if (adsLeft) {
import requests
import random
def get_ip():
return '{}.{}.{}.{}'.format(*[random.randint(1, 255) for _ in range(4)])
for i in range(100):
@aq1
aq1 / itsg.py
Last active February 13, 2017 22:27
import os
from datetime import datetime
from twisted.names.client import lookupPointer
from twisted.web.server import Site
from twisted.web.resource import Resource
from twisted.internet import reactor, utils
class View(Resource):
for i in db.SESSION.query(db.Item).all():
for t in db.SESSION.query(db.Template).filter_by(item_id=i.id):
self._show(i, t)
self.save(event=None)
# Game of life
# Dead cell comes alive only if 3 neighbor cells are alive
# Live cell stays alive only if there are 2 or 3 live neighbor cells, else it dies
# dynamic grid size
from tkinter import *
from tkinter import font
import time
import random
@aq1
aq1 / pr.py
Created September 6, 2016 16:58
import os
import sqlite3
# try:
# os.remove('db.sqlite3')
# except FileNotFoundError:
# pass
conn = sqlite3.connect('db.sqlite3')
cursor = conn.cursor()
@aq1
aq1 / map.py
Last active August 31, 2016 16:47
map_ = {'ginekologiia': {'GI_DIAMETER': 'ginekologiia[]',
'GI_ENDOM': 'ginekologiia[]',
'GI_LENGTH_1': 'ginekologiia[]',
'GI_LENGTH_2': 'ginekologiia[]',
'GI_LENGTH_3': 'ginekologiia[]',
'GI_LENGTH_4': 'ginekologiia[]',
'GI_THICKNESS_1': 'ginekologiia[]',
'GI_THICKNESS_3': 'ginekologiia[]',
'GI_THICKNESS_4': 'ginekologiia[]',
'GI_VOLUME_1': 'ginekologiia[]',