Skip to content

Instantly share code, notes, and snippets.

View PaulRudin's full-sized avatar

Paul Rudin PaulRudin

View GitHub Profile
@PaulRudin
PaulRudin / starwars_schema.py
Created July 12, 2018 16:48
graphene starwars schema: gives "AssertionError: DroidInput.friends field type must be Input Type but got: [Character]."
# modifed from https://github.com/graphql-python/graphene/blob/master/examples/starwars/schema.py
import graphene
from .starwars_data import (
get_character, get_droid, get_hero, get_human,
create_droid, create_human
)
@PaulRudin
PaulRudin / old.py
Last active February 9, 2020 07:18
import requests
def get_responses(n):
with requests.Session() as session:
responses = [
session.post('https://echo.xamaral.com', data=str(i))
for i in range(n)
]
@PaulRudin
PaulRudin / new.py
Last active February 9, 2020 07:18
import asyncio
import aiohttp
async def get_responses(n):
async with aiohttp.ClientSession() as session:
responses = await asyncio.gather(*(
session.post('https://echo.xamaral.com', data=str(i))
for i in range(n)
/*
A function to create a mixin to replace a nested key conditionally. I.e. only
replace if all the keys along the path already exist.
This can be used with std.prune to remove the resulting null elements, but
beware - that also could remove existing empty elements.
*/
# example of getting multiple urls with aiohttp
import asyncio
import aiohttp
async def get_responses(urls):
async with aiohttp.ClientSession() as session:
responses = await asyncio.gather(

Keybase proof

I hereby claim:

  • I am paulrudin on github.
  • I am paulrudin (https://keybase.io/paulrudin) on keybase.
  • I have a public key ASBzDJYwhP7YNx-tWKMYcSPmGTVI2r_ApF-aW1a3EPP-xwo

To claim this, I am signing this object:

@PaulRudin
PaulRudin / main.dart
Last active October 1, 2021 09:02
infinite scroll
// Modified from https://github.com/flutter/flutter/issues/20608#issuecomment-451040159
import 'package:flutter/material.dart';
void main() => runApp(EndlessListExampleApp());
class EndlessListExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
Key forwardListKey = UniqueKey();
import 'package:collection/collection.dart';
void main() {
var a = [{"id": 7},{"id": 5},{"id": 9},{"id": 4},{"id": 8},{"id": 10},{"id": 6}];
var b = [{"id": 5},{"id": 6},{"id": 9},{"id": 7},{"id": 4},{"id": 10},{"id": 8}];
var ab = [for (final pair in IterableZip([a, b])) pair[0]["id"] == pair[1]["id"]];
print(ab);
}
random_id.db_name_suffix: Refreshing state... [id=eXBRag]
random_password.test_pw: Refreshing state... [id=none]
google_datastream_connection_profile.dest: Refreshing state... [id=projects/ismfg-scratch/locations/europe-west2/connectionProfiles/dest_profile]
google_bigquery_dataset.datastream_dataset: Refreshing state... [id=projects/ismfg-scratch/datasets/test_dataset]
google_sql_database_instance.db: Refreshing state... [id=db-7970516a]
google_sql_ssl_cert.datastream_cert: Refreshing state... [id=projects/ismfg-scratch/instances/db-7970516a/sslCerts/076f9e9c5ce597aa792d82b6f3032ebc9e2afcea]
google_sql_user.test: Refreshing state... [id=test//db-7970516a]
google_datastream_connection_profile.source: Refreshing state... [id=projects/ismfg-scratch/locations/europe-west2/connectionProfiles/source_profile]
google_datastream_stream.stream: Refreshing state... [id=projects/ismfg-scratch/locations/europe-west2/streams/stream]