Skip to content

Instantly share code, notes, and snippets.

@flip111
flip111 / main.rs
Created Mar 22, 2020
Actix GraphQL over websocket
View main.rs
// Combination of:
// https://github.com/actix/examples/tree/master/juniper
// https://github.com/actix/examples/tree/master/websocket
mod schema;
use crate::schema::{create_schema, Schema};
use actix::prelude::*;
use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer};
use actix_web_actors::ws;
@flip111
flip111 / cartesian.php
Created Mar 26, 2019
Cartesian product PHP algorithm benchmark (see comments for results)
View cartesian.php
<?php
$decimals = 2;
// test iterations
$iterations = 1000;
printf("Iterations: %d\n\n", $iterations);
@flip111
flip111 / lcs.php
Created Mar 7, 2019
Longest common substring PHP algorithm benchmark (see comments for results)
View lcs.php
<?php
// reset && /usr/bin/time php lcs.php
$utf8test = true; // utf8 or ascii test input
$decimals = 2;
// test iterations
// amount is chosen so that each test takes about 10 minutes on my PC (AMD Ryzen 2400G)
// tune: round((10×60) × (iterations / runtime)) for 10 minutes
if ($utf8test) {
@flip111
flip111 / app.py
Last active Dec 27, 2017
using aiohttp together with other asyncio
View app.py
# other stuff before this (imports & other code)
runner = run_app_nonblocking.setup_app(app, host='localhost', port=8080)
# Extra asyncio stuff here
loop = asyncio.get_event_loop()
# maybe add another site
extra_site = web_runner.TCPSite(runner, "127.0.0.1", 8099,
@flip111
flip111 / Main.hs
Created Jan 3, 2016
cropping an image with JuicyPixels
View Main.hs
module Main where
import Codec.Picture
import Codec.Picture.Types
import Debug.Trace
type X = Int
type Y = Int
type Width = Int
type Height = Int
@flip111
flip111 / MysqlJoin.php
Created Dec 8, 2013
Support for STRAIGHT_JOIN in Doctrine. This does not work (yet) because not having a clean way to implement it. But making these changes in Doctrine directly will work.
View MysqlJoin.php
<?php
/**
* DoctrineExtensions Vendor Specific DQL Query Features
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email