Skip to content

Instantly share code, notes, and snippets.

View abhijat's full-sized avatar

Abhijat Malviya abhijat

View GitHub Profile
registry = {}
class Meta(type):
def __new__(mcs, name, bases, namespace):
cls_instance = super().__new__(mcs, name, bases, namespace)
registry[getattr(namespace['Meta'], 'system_name')] = cls_instance
return cls_instance
from functools import reduce
from operator import mul
class Solution(object):
def __init__(self):
self.solution = [[None] * 3, [None] * 3, [None] * 3]
self._row = self._column = 0
def row_product(self, i):
@abhijat
abhijat / opam-musl-libc.txt
Created February 13, 2020 10:39
Setting up opam with musl-libc
There are a few steps to be followed when setting up opam to use musl-libc.
1. Install musl-tools - this adds the wrapper musl-gcc to the system.
2. export CC=musl-gcc
3. Any supporting C libraries will need to be compiled with musl and installed in a special prefix, eg
apt-get source libgmp-dev # get the source for libgmp
CC=musl-gcc ./configure --prefix=/usr/local/musl # make sure the libs and headers are compiled with the right compiler and end up in a special path
4. Export the following variables to make sure opam finds them
@abhijat
abhijat / test
Last active March 18, 2019 11:45
Kotlin ==========================================================
fun flipBit(): Long {
val start = System.currentTimeMillis()
var bit = false
for (i in 1..100000000) {
if (i % 7 == 0) {
bit = !bit
}
}
struct Node {
host_name: String,
is_master: bool,
}
enum ParserResponse {
ParseError(usize, usize),
AddNodeCommand(String, bool),
RemoveNodeCommand(Node)
}
DPI mode: per-monitor v2
startup, version: 3176 windows x64 channel: stable
executable: /C/Program Files/Sublime Text 3/sublime_text.exe
working dir: /C/Program Files/Sublime Text 3
packages path: /C/Users/abhijat/AppData/Roaming/Sublime Text 3/Packages
state path: /C/Users/abhijat/AppData/Roaming/Sublime Text 3/Local
zip path: /C/Program Files/Sublime Text 3/Packages
zip path: /C/Users/abhijat/AppData/Roaming/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.299623
@abhijat
abhijat / wiki.go
Last active February 11, 2018 10:09
package main
import (
"net/http"
"log"
"golang.org/x/net/html"
"regexp"
"fmt"
"errors"
"bytes"
@abhijat
abhijat / WebTest.java
Last active September 18, 2017 16:00
autoconfigure spring boot rest doc
package am;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.http.MediaType;
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;