Skip to content

Instantly share code, notes, and snippets.

@CemraJC
CemraJC / COMMENTS.txt
Last active February 10, 2024 11:11
Simple Object Oriented Resolvers in Ariadne
ARIADNE + GRAPHQL: ROBUST BASIS FOR A CODE GENERATOR TO MAKE GRAPHQL SERVERS IN PYTHON
This is a simple example to show how a couple of small wrapper classes can take
Ariadne's relatively non-modular approach, and slide a compatibility layer in to
make it possible to declare classes with methods that map directly to resolvers
for fulfilling a GraphQL schema.
The method names are marked with "@resolver", and the class name should exactly match the
type name in the schema. Each class is defined in its own "model" file, and there are two
special classes for the root queries & mutators.
@CemraJC
CemraJC / site-structure-generator.js
Created February 8, 2024 09:05
Wiki.JS Version 2 - Dynamic Page Structure / TOC Generator
<script>
// ^^^
// Keep the <script> tags when copying into Wiki.JS page editor
async function fetchAllPages() {
const graphqlEndpoint = "/graphql";
const query = `
query GetAllPages {
pages{
list(limit: 1000, orderBy: PATH, orderByDirection: ASC) {
@CemraJC
CemraJC / PracticalFour.java
Created August 19, 2021 23:21
Prac4_Wk4_Fri8
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Random;
public class PracticalFour {
/**
* Throw an exception of the given 'type' in the arguments list,
* or print "No problems" if 'NONE'
*
* Work on this until: 8:21
String num(int value) {
// Q1.1 Solution
switch (value) {
case 1:
return "one";
case 2:
return "two";
import java.io.*;
import java.util.*;
public class Schedule {
private List<Flight> flights;
public Schedule(List<Flight> flights) {
this.flights = flights;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 10 columns, instead of 5. in line 8.
row,start_address,end_address,start_lat,start_lon,end_lat,end_lon,duration(seconds),distance(meters),mode
0,Albion QLD 4010 Australia,Ascot QLD 4007 Australia,-27.4319627,153.046257,-27.4320055,153.0654789,309,2523,DRIVING
1,Albion QLD 4010 Australia,Ascot QLD 4007 Australia,-27.4319627,153.046257,-27.4320055,153.0654789,585,2698,TRANSIT
2,Albion QLD 4010 Australia,Auchenflower QLD 4066 Australia,-27.4319627,153.046257,-27.4755681,152.9916783,741,8232,DRIVING
4,Albion QLD 4010 Australia,Balmoral QLD 4171 Australia,-27.4319627,153.046257,-27.4541422,153.0669507,958,10820,DRIVING
5,Albion QLD 4010 Australia,Balmoral QLD 4171 Australia,-27.4319627,153.046257,-27.4541422,153.0669507,5092,15011,TRANSIT
6,Albion QLD 4010 Australia,Bardon QLD 4065 Australia,-27.4319627,153.046257,-27.461372,152.9748871,1011,9963,DRIVING
7,Albion QLD 4010 Australia,Bardon QLD 4065 Australia,-27.4319627,153.046257,-27.461372,152.9748871,3188,11905,TRANSIT
8,Albion QLD 4010 Australia,Brisbane City QLD 4000 Australia,-27.4319627,153.046
@CemraJC
CemraJC / FlowTaskManager.cs
Created September 30, 2019 05:46
FlowTask implementation in C# - see https://decatronics.org/flow_tasks
using System;
using System.Collections.Generic;
namespace flowtasks
{
/// <summary>
/// Manages performing a set of tasks in a well-defined sequence, allowing holdoff to
/// when data or next-state information is available.
///
/// The next task is run by the manager, passed the arguments given to the Step method, and
@CemraJC
CemraJC / server.js
Last active March 1, 2016 03:42
A very simple server for serving 'wget'ed web pages and other static websites - Now includes RegEx Path Munging, for persnickety GET requests
// Super Simple Node Server
var http = require('http');
var fs = require('fs');
var wd = process.cwd();
var serve;
console.log('Current directory: ' + process.cwd());
// Colors! ^.^
var white_c = "\033[1;39m";
cd "$1"
# Make sure they're confident that this is the correct directory
printf "\nAre you sure you want to completely wreck directory '%s'?\n" "$(pwd)"
prompt=b
until [[ "$prompt" =~ (yes|no) ]]; do
read -p "(Yes / No): " prompt
done
if [[ "$prompt" =~ no ]]; then
exit 0;