Skip to content

Instantly share code, notes, and snippets.

View delneg's full-sized avatar
💭
Worck overflow

Denis delneg

💭
Worck overflow
View GitHub Profile
@delneg
delneg / intervals.fsx
Created January 9, 2022 20:07
Intervals merge problem in F#, run with `dotnet fsi intervals.fsx`
//Run with `dotnet fsi intervals.fsx`
let intervals = [|
(1,3)
(12,15)
(23, 41)
(8,10)
(2,6)
(13,21)
(20,21)
(14,22)
#! /usr/bin/env bash
# More info at: https://github.com/elitak/nixos-infect
set -e -o pipefail
makeConf() {
# Skip everything if main config already present
[[ -e /etc/nixos/configuration.nix ]] && return 0
# NB <<"EOF" quotes / $ ` in heredocs, <<EOF does not
@delneg
delneg / Summary.md
Created December 19, 2020 23:09
Small benchmark of differenet immutable sets perfomance

BenchmarkDotNet=v0.12.1, OS=macOS Catalina 10.15.4 (19E287) [Darwin 19.4.0] Intel Core i9-9980HK CPU 2.40GHz, 1 CPU, 16 logical and 8 physical cores .NET Core SDK=3.1.301 [Host] : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT DEBUG DefaultJob : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT

Method Mean Error StdDev
FSSet 331.9 ms 5.82 ms 9.73 ms
module Bench
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
[<SimpleJob(launchCount = 3, warmupCount = 3, targetCount = 5)>]
[<GcServer(true)>]
[<MemoryDiagnoser>]
[<MarkdownExporterAttribute.GitHub>]
type Benchmarks () =
[<Benchmark>]
@delneg
delneg / f.html
Created April 12, 2017 18:00
Django 'active' for navbar
# In this example I make difference for 3 urls, this can be messy if you have an URL that is like /posts/whatever/contacts because there is 2 places that will return True (2nd and 3rd li)
# So here is the better option for handling this:
{% with request.resolver_match.url_name as url_name %}
<ul id="menu">
<li class="{% if url_name == 'home' %}active{% endif %}">Home</li>
<li class="{% if url_name == 'blog' %}active{% endif %}">Posts</li>
<li class="{% if url_name == 'contact' %}active{% endif %}">Contact</li>
</ul>
@delneg
delneg / user_agents.py
Created March 7, 2017 20:05
Popular user agents for Python requests
def user_agent():
'''
Popular user agents, randomized
:return: {'User-Agent':'some_agent'}
'''
headers = ['Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.56 (KHTML, like Gecko) Version/9.0 Safari/601.1.56',