Skip to content

Instantly share code, notes, and snippets.

View Mart-Bogdan's full-sized avatar
🤘
|m/

Bohdan Mart Mart-Bogdan

🤘
|m/
View GitHub Profile
@Mart-Bogdan
Mart-Bogdan / Ef_Selects.cs
Created January 9, 2017 20:30
Samples of using selects with entity framework
public async Task<ICollection<Tuple<Site,ICollection<String>>>> GetSitesByUserIdAsync(int userId)
{
StringBuilder sb = new StringBuilder();
Action<string> action = s => sb.Append(s);
_context.Database.Log += action;
var res= await _context.UserSiteAccesses
.Where(p => p.UserId == userId && p.Accsess == "read")
.Select(p => new RwTuple<Site,ICollection<String>>
{
javascript: (function () {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
document.body.appendChild(e)
}
function h() {
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ua.kpi.acts.samuel.agent.inject.modules;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.MapBinder;
import java.util.Set;
@Mart-Bogdan
Mart-Bogdan / keybase.md
Created September 20, 2019 13:23
keybase.md

Keybase proof

I hereby claim:

  • I am mart-bogdan on github.
  • I am winnie_ua (https://keybase.io/winnie_ua) on keybase.
  • I have a public key ASDR4oc_1BmeWWrAYTdggM_czCpD7-ZXFVyOGxsxwe9-dAo

To claim this, I am signing this object:

@Mart-Bogdan
Mart-Bogdan / SmartMigrationsTable.cs
Created September 1, 2020 12:15
EF track migration apply time
public partial class SmartMigrationsTable : Migration
{
protected override void Up(MigrationBuilder builder)
{
builder.Sql("alter table \"__EFMigrationsHistory\" add column IF NOT EXISTS id serial;");
builder.Sql(
"alter table \"__EFMigrationsHistory\" add column IF NOT EXISTS created_ts timestamptz default now();"
);
}
@Mart-Bogdan
Mart-Bogdan / md5chunks.py
Last active October 18, 2020 12:20 — forked from fmarani/md5chunks.py
calculate md5 hashes of chunks of a file, configurable block size
#!/usr/bin/env python
from optparse import OptionParser
from pathlib import Path
import hashlib
import sys
parser = OptionParser()
parser.add_option("-b", "--blocksize", dest="blocksize", type=int, default=1024,
help="Specify blocksize", metavar="blocksize")
@Mart-Bogdan
Mart-Bogdan / test.rs
Created April 10, 2022 20:32
Snippet to run SetUp/TeadDown in Rust Unit Tests
// Kudos Eric Opines https://medium.com/@ericdreichert/test-setup-and-teardown-in-rust-without-a-framework-ba32d97aa5ab
// This is bit modified post from his blog post.
#[cfg(test)]
mod tests {
use std::fs::read_dir;
use std::panic;
#[test]
fn it_works() {
run_test(|| {
@Mart-Bogdan
Mart-Bogdan / experiments.rs
Created November 19, 2022 01:25
windows file size experiments
#![allow(unused_imports, unused)]
use std::error::Error;
use std::ffi::c_void;
use std::fs::{File, OpenOptions};
use std::iter::once;
use std::os::windows::ffi::OsStrExt;
use std::path::Path;
use std::process::exit;
use std::{io, mem};
@Mart-Bogdan
Mart-Bogdan / counting_allocator.rs
Created November 19, 2022 01:27
Rust allocator to debug allocations
use std::alloc::{System, GlobalAlloc};
static SYS_ALLOC: System = System;
struct CountingAlloc {
bytes_allocated: AtomicIsize,
bytes_used: AtomicIsize
}
@Mart-Bogdan
Mart-Bogdan / attch_vs_code.rs
Created November 19, 2022 01:29
Rust snippet to attach VS Code debugger to current running process
// can be used to attach to existing running app.
// If you need to run app from shell, for example, passing in stdin or command line args, or whatever else.
#[allow(unused)]
fn attch_vs_code() {
use std::time::Duration;
let url = format!(
"vscode://vadimcn.vscode-lldb/launch/config?{{'request':'attach','pid':{}}}",
std::process::id()