visionaryPeachAspREADME.md1 match
1A proxy that lets Val Town users get some free [SocialData](https://socialdata.tools) Search to power their Twitter Alerts, ie @stevekrouse/twitterAlert
23I reccomend interfacing with this proxy via this helper function: @stevekrouse/socialDataSearch
spectacularAzureAngelfishmain.tsx4 matches
15type UsageData = { username: string; usage_count: number; date: string };
1617function UsageDashboard() {
18const [usageData, setUsageData] = useState<UsageData[]>([]);
1920useEffect(() => {
21async function fetchUsageData() {
22const response = await fetch('/usage-data');
23const data = await response.json();
85}
8687function client() {
88createRoot(document.getElementById("root")).render(<UsageDashboard />);
89}
90if (typeof document !== "undefined") { client(); }
9192export default async function(req: Request): Promise<Response> {
93const url = new URL(req.url);
94
1A proxy that lets Val Town users get some free [SocialData](https://socialdata.tools) Search to power their Twitter Alerts, ie @stevekrouse/twitterAlert
23I reccomend interfacing with this proxy via this helper function: @stevekrouse/socialDataSearch
15// console.log(MEUS_JOGOS);
1617function compareGames(drawnNumbers, userGame) {
18return userGame.filter(num => drawnNumbers.includes(num)).length;
19}
2021function TabelaDistribuicaoPremios({ premios }) {
22if (!premios || premios.length === 0) return null;
2351}
5253function App() {
54const [dadosLoteria, setDadosLoteria] = useState(null);
55const [numeroAtual, setNumeroAtual] = useState(null);
56const [erro, setErro] = useState(null);
5758async function buscarDadosLoteria(numero = null) {
59const url = numero
60? `https://servicebus2.caixa.gov.br/portaldeloterias/api/megasena/${numero}`
195}
196197function client() {
198createRoot(document.getElementById("root")).render(<App />);
199}
200if (typeof document !== "undefined") { client(); }
201202export default async function server(request: Request): Promise<Response> {
203return new Response(
204`
5const schemaVersion = 3;
67function _client() {
8return createClient({
9url: Deno.env.get("WIDE_CLICKHOUSE_URL"),
13}
1415export async function runMigrations() {
16for (
17const migration of [
53}
54}
55export function parseRows(rows: any[]) {
56const processedRows = rows.map(row => {
57const paths: {
65};
6667function processObject(obj: any, currentPath = "") {
68for (const [key, value] of Object.entries(obj)) {
69const newPath = currentPath ? `${currentPath}.${key}` : key;
166* write!
167*/
168export async function write(userId: string, data: any[]) {
169return await writeRowsToClickhouse(userId, parseRows(data));
170}
182* values!
183*/
184export async function values(
185userId: string,
186{ field_name, field_type }: { field_name: string; field_type: FieldType },
218* fields!
219*/
220export async function fields(userId: string, search: string = "") {
221return (await (await _client().query({
222query: `
296* Get the ClickHouse comparison expression for the given operator
297*/
298function getComparisonExpression(
299operator: TStringOperator | TNumberOperator | TBooleanOperator,
300valueRef: string,
325326/**
327* Enhanced search function supporting multiple conditions with different operators
328*/
329export async function search(userId: string, {
330filters,
331start,
412413414function formatDate(date: Date) {
415return String(getUnixTime(date) + (date.getMilliseconds() / 1000))
416}
425}
426427function reconstructObjects(
428results: LogRow[],
429) {
valSessionmain.tsx2 matches
20`;
2122async function newSession(valTownToken: string) {
23const privateKeyPem = `
24-----BEGIN PRIVATE KEY-----
38}
3940function validate(token: string) {
41const decoded = jwt.verify(token, publicKeyPem, { algorithms: ["RS256"] }) as
42& Awaited<
1011type DataFormat = 'object' | 'json' | 'yaml' | 'csv' | 'toml';
12type SelectorType = 'property' | 'index' | 'search' | 'dynamic' | 'append' | 'function';
1314interface Selector {
40selectors.push(this.parseAppend());
41} else if (part.includes('(')) {
42selectors.push(this.parseFunction(part));
43} else {
44// Handle top-level properties without a leading dot
112}
113114private parseFunction(part: string): Selector {
115const [funcName, argsString] = part.split('(');
116const args = argsString.slice(0, -1).split(',').map(arg => arg.trim());
117return { type: 'function', value: funcName, args };
118}
119128129130type FunctionHandler = (data: any, args: string[]) => any;
131132const functions: Record<string, FunctionHandler> = {
133length: (data) => Array.isArray(data) ? data.length : Object.keys(data).length,
134keys: (data) => Object.keys(data),
145146147function applyFunction(funcName: string, data: any, args: string[] = []): any {
148const func = functions[funcName];
149if (!func) {
150throw new Error(`Unknown function: ${funcName}`);
151}
152200201private async stringifyData(data: any, format: DataFormat): Promise<string> {
202// Function to remove undefined values
203const removeUndefined = (obj: any): any => {
204if (Array.isArray(obj)) {
273274275case 'function':
276// If the function is 'length' and current is an array, apply it directly
277if (selector.value === 'length' && Array.isArray(current)) {
278return current.length;
279}
280// Otherwise, apply the function normally
281current = applyFunction(selector.value as string, current, selector.args || []);
282break;
283336result.push(this.traverseSelectorsForPut({}, remainingSelectors, value));
337break;
338case 'function':
339throw new Error('Cannot put to a function selector');
340}
341383case 'append':
384return data;
385case 'function':
386throw new Error('Cannot delete from a function selector');
387}
388
9- **Multi-format Support**: Works with JSON, YAML, CSV, and TOML.
10- **Dynamic Selectors**: Use conditions to filter data dynamically.
11- **Function Support**: Built-in functions for data manipulation (e.g., length, sum, avg).
12- **Easy Integration**: Can be used in both Deno and Val Town environments.
1317import Diesel from "https://esm.town/v/yawnxyz/diesel";
1819async function main() {
20const jsonData = `
21{
1export default async function(req: Request): Promise<Response> {
2return new Response(
3`
valSessionREADME.md1 match
25);
2627function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string {
28const lines = b64.match(/.{1,64}/g) || [];
29return `-----BEGIN ${type}-----\n${lines.join("\n")}\n-----END ${type}-----`;