Skip to content

Instantly share code, notes, and snippets.

@flip111
flip111 / MysqlJoin.php
Created December 8, 2013 14:43
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.
<?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
@flip111
flip111 / Main.hs
Created January 3, 2016 21:20
cropping an image with JuicyPixels
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 / app.py
Last active December 27, 2017 20:06
using aiohttp together with other asyncio
# 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 / lcs.php
Created March 7, 2019 17:24
Longest common substring PHP algorithm benchmark (see comments for results)
<?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 / cartesian.php
Created March 26, 2019 17:45
Cartesian product PHP algorithm benchmark (see comments for results)
<?php
$decimals = 2;
// test iterations
$iterations = 1000;
printf("Iterations: %d\n\n", $iterations);
@flip111
flip111 / main.rs
Created March 22, 2020 18:19
Actix GraphQL over websocket
// 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 / Main.purs
Created November 29, 2021 21:00
trying to get halogen store working with monomorphic Aff instead of polymorphic MonadAff m
module Main where
import Prelude
import Effect (Effect)
import Effect.Aff (launchAff_)
import Halogen.Aff as HA
import Halogen.Store.Monad (runStoreT)
import Halogen.VDom.Driver (runUI)
import Data.Maybe (Maybe(..))
@flip111
flip111 / Main.purs
Created November 29, 2021 21:42
trying to figure out type signature of render and handleAction to work with halogen store
module Main where
import Prelude
import Effect (Effect)
import Effect.Aff (launchAff_)
import Halogen.Aff as HA
import Halogen.Store.Monad (runStoreT)
import Halogen.VDom.Driver (runUI)
import Data.Maybe (Maybe(..))