Skip to content

Instantly share code, notes, and snippets.

gubser

Block or report user

Report or block gubser

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View The following generators are available on this platform: Unix Makefiles = Generates standard UNIX makefiles. Ninja = Generates build.ninja files (experimental). Watcom WMake = Generates Watcom W
The following generators are available on this platform:
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files (experimental).
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
CodeLite - Ninja = Generates CodeLite project files.
CodeLite - Unix Makefiles = Generates CodeLite project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles
View preliminary pathspider analyisis.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View AutoReloadConfig.py
import json
import time
import logging
from collections import UserDict
class AutoReloadConfig(UserDict):
"""
A dictionary that automatically reloads itself from a file.
On each call to __getitem__(), check if config is older than reload_period and if yes then reload from file.
@gubser
gubser / pathScanContext.fsx
Created Oct 11, 2018
A variant of pathScan that also passes HttpContext to the handler
View pathScanContext.fsx
#r "<path/to/Suave.dll>"
open Suave
open Suave.Successful
open Suave.RequestErrors
/// <summary>
/// Same as pathScan but also passes the HttpContext to the handler h.
/// See pathScan: https://github.com/SuaveIO/suave/blob/0524552a876526ae6623ba6fdf4ca3a06feaf510/src/Suave/Combinators.fs#L413
/// </summary>
let pathScanContext (pf : PrintfFormat<_,_,_,_,'t>) (h : HttpContext -> 't -> WebPart) : WebPart =
@gubser
gubser / TaskResultBind.fs
Last active Nov 6, 2018
Helper function to chain TaskResult producing functions
View TaskResultBind.fs
type TaskResult<'a,'b> = Task<Result<'a,'b>>
module TaskResult =
let bind (f: 'a -> TaskResult<'b,'e>) (x: TaskResult<'a,'e>): TaskResult<'b,'e> = task {
match! x with
| Ok success -> return! f success
| Error failure -> return Error failure
}
// should it be called bindResult or bindTask?
View text-symbol-halo.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>TextSymbol with Halo - 4.9</title>
<style>
html,
body,
#viewDiv {
@gubser
gubser / space-delimited-int-array-column.py
Created Jan 30, 2019
This python snippet parses the `vector` column as a list of integers delimited by space and adds it as a new column
View space-delimited-int-array-column.py
"""
| frame | which | center-x | center-y | vector | vector_array |
| 44 | 0 | 55.5 | 29.3 | "49 44 31 22 26 22 44 ..." | [49, 44, 31, 22, 26, 22, 44, ...] |
"""
import pandas as pd
df = pd.read_csv(r"C:\Users\egubser\Downloads\blobs.csv", sep=';')
df['vector_array'] = df.vector.apply(lambda v: [int(k) for k in v.split(' ')])
@gubser
gubser / AsyncBoundedCacheTests.fs
Created Jan 30, 2019
Unit tests for bounded caching. Needs more.
View AsyncBoundedCacheTests.fs
module AsyncBoundedCacheTests
open System
open Xunit
[<Fact>]
let ``insert items`` () = async {
let f = fun x -> async {
do! Async.Sleep(1)
return x
@gubser
gubser / AsyncBoundedCache.fs
Last active Jan 31, 2019
A bounded cache for async operations in F#
View AsyncBoundedCache.fs
module AsyncBoundedCache
open System
open System.Collections.Concurrent
open System.Threading
open System.Threading.Tasks
let startTime = DateTime.UtcNow.Ticks / 10000000L
let now () = int ((DateTime.UtcNow.Ticks / 10000000L) - startTime)
@gubser
gubser / analyzer.py
Last active Jun 22, 2019
Walk the abstract syntax tree to find the data dependencies of a python script
View analyzer.py
"""
Given the python code:
out.p = inp.x + inp.y
out.q = inp.y + 1
It finds these dependencies:
inputs are x, y
outputs are p, q
"""
You can’t perform that action at this time.