Skip to content

Instantly share code, notes, and snippets.

from collections import OrderedDict
from pathlib import Path
lines = Path('README.md').read_text().split('\n')
for line in lines:
if line.startswith('###'):
break
@Arseny-N
Arseny-N / costum_engine.py
Created April 25, 2018 10:00
Costum iginte engine example
from ignite.engines import Events, Engine
from enum import Enum
from ignite._utils import _to_hours_mins_secs
class CostumEvents(Enum):
EPOCH_STARTED = "epoch_started"
EPOCH_COMPLETED = "epoch_completed"
STARTED = "started"
COMPLETED = "completed"
@Arseny-N
Arseny-N / decoders.py
Created March 22, 2018 15:21
Code for pytorch forums question
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import collections
class Dummy(nn.Module):
def forward(self, x): return x
@Arseny-N
Arseny-N / auto_import.py
Created February 3, 2016 10:05
Import a module and reimport it every time it changes.
from importlib import reload, import_module
from os import stat
class auto_import(object):
"""
auto_import(mod, pkg = None, brute = False, verbose=False) :
Description:
Import a module and reimport it every time it changes.
Useful in a REPL, when debugging some functions from a file.
@Arseny-N
Arseny-N / ALL.c
Last active August 29, 2015 14:21
Graphs
8<------------------------ graphs.c ------------------------
#include <stdlib.h>
@Arseny-N
Arseny-N / main.c
Created November 11, 2014 19:29
Casts to anonymus structures
#include <stdio.h>
#include <stdlib.h>
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef char s8;
struct byte {
@Arseny-N
Arseny-N / json-zero.c
Created October 15, 2014 12:17
Callback based (zero-copy) JSON C parser
#include <stdarg.h>
#include "generic-json-zero-copy.h"
void print_xjson(char *prefix, char *postfix, xjson *b, offset off, int len)
{
int i;
printf("len=%d,off=%d ",len, off);
printf("%s", prefix);
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define stringify(s) #s
#define genb_printf(var, cast) printf( "| %d:%6s: %3d to %3d\n", __LINE__,stringify(cast), var,(cast) var);
#define do_print(i, from, to, cast ) for( i = from; i < to; i++) { genb_printf(i, cast); }
#define assert(var, cast, res) (((cast)var) == (res))