Skip to content

Instantly share code, notes, and snippets.

@dps
dps / db.js
Created September 2, 2024 05:38
useItemsByOwner with async updates
import {
useQuery,
useQueryClient,
QueryClient,
QueryClientProvider as QueryClientProviderBase,
} from "react-query";
import { useEffect } from "react";
import supabase from "./supabase";
import os
from bs4 import BeautifulSoup, Comment
import re
def clean_html(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
soup = BeautifulSoup(file, 'html.parser')
# Remove <script> and <style> tags
@dps
dps / short-sudoku.scala
Created September 5, 2015 09:15
A short Sudoku solver in Scala. By Muntis Grube
def s(l:String):Unit={val i=l indexOf '0'
if(i<0)println(l)else
for{c<-'1'to'9'
if(0 to 80).forall(n=>((n-i)%9*(n/9^i/9)*(n/27^i/27|n%9/3^i%9/3)|l(n)^c)!=0)}
s(l.replaceFirst("0",""+c))}
s(args(0))
from piui import PiUi
ui = PiUi()
page = ui.new_ui_page(title="Hello")
title = page.add_textbox("Hello, world!")
import RPi.GPIO as gpio
import sys
import time
from webalert import WebAlert
class RelayListener(object):
def __init__(self):
gpio.setmode(gpio.BCM)
$*.map{|a|(i=a=~/0/)?(v=*?1..?9).fill{|j|v-=[a[j+i-k=i%9],a[
k+j*=9],a[j%26+i-i%3-i%27+k]]}+v.map{|k|$*.<<$`<<k<<$'}:p(a)}
@dps
dps / sudoku.py
Created December 29, 2012 17:00
def r(a):
i=a.find('0')
if i<0:print a
[m in[(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)or a[j]for
j in range(81)]or r(a[:i]+m+a[i+1:])for m in`14**7*9`]
r(raw_input())
$_=$`.$_.$'.<>;split//;${/[@_[map{$i-($i="@-")%9+$_,9*$_+$i%
9,9*$_%26+$i-$i%27+$i%9-$i%3}0..8]]/o||do$0}for/0/||print..9
open String let rec s p=try let rec(%)=(mod)and i=index p '0'and b
j=i<>j&(i/9=j/9||i%9=j%9||i/27=j/27&i%9/3=j%9/3)&p.[i]=p.[j]||j<80&b(j+1)in
iter(fun c->p.[i]<-c;b 0||()=s p;())"948721536";p.[i]<-'0'with
_->print_string p;;s(read_line())
z""a=a
z('0':b)t=foldr(++)""[z b$t++[x]|x<-['1'..'9'],notElem x
d]where{d=[h$m`mod`9+i*9|i<-a]++[h$m-j 9+i|i<-a]++[h$i*9`mod`26+m-j 3-j
27+j 9|i<-a];j=mod m;m=length t;h=(!!)$t++'0':b;a=[0..8]}
z(c:b)a=z b$a++[c]
main=do
a<-getLine
putStr$z a""