Skip to content

Instantly share code, notes, and snippets.

View mihaitodor's full-sized avatar
:shipit:
Shipit!

Mihai Todor mihaitodor

:shipit:
Shipit!
View GitHub Profile
@fnky
fnky / ANSI.md
Last active May 1, 2024 21:47
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
import mxnet as mx
from mxnet.gluon.model_zoo import vision
import os
import time
batch_shape = (1, 3, 224, 224)
resnet18 = vision.resnet18_v2(pretrained=True)
resnet18.hybridize()
resnet18.forward(mx.nd.zeros(batch_shape))
resnet18.export('resnet18_v2')
def static_var(name, value):
def helper(fun):
setattr(fun, name, value)
return fun
return helper
@static_var("my_var", 0)
@static_var("my_other_var", "HAL")
def foo():
@sinclairtarget
sinclairtarget / bernoulli.c
Created August 17, 2018 20:22
Lovelace's Note G Program in C
#include <stdio.h>
/*
* Calculates what Ada Lovelace labeled "B7", which today we would call the 8th
* Bernoulli number.
*/
int main(int argc, char* argv[])
{
// ------------------------------------------------------------------------
// Data
@mcaleavya
mcaleavya / qos.py
Created July 4, 2018 23:58
cgroup QOS using eBPF
#!/usr/bin/python
# @lint-avoid-python-3-compatibility-imports
#
# qos implement a dynamic qos for using cgroups
# For Linux, uses BCC, eBPF.
#
# USAGE: qos.py [-h] [-qc] [--max] [interval]
# requires a file name qos_setup which can changed with qosfile
# file has format maj:min IOPS
# i.e. 8:0 40000

How to install Node.js applications, if you're not a Node.js developer

While installing a Node.js application isn't difficult in principle, it may still be confusing if you're not used to how the Node.js ecosystem works. This post will tell you how to get the application going, what to expect, and what to do if it doesn't work.

Occasionally an application may have custom installation steps, such as installing special system-wide dependencies; in those cases, you'll want to have a look at the install documentation of the application itself as well. However, most of the time it's safe to assume that the instructions below will work fine.

If the application you want to install is available in your distribution's repositories, then install it through there instead and skip this entire guide; your distribution's package manager will take care of all the dependencies.

Checklist

import ctypes as C
from ctypes.util import find_library
cuda = C.cdll.LoadLibrary(find_library("cudart"))
dev_ct = C.c_int()
dev_ct_addr = C.addressof(dev_ct)
dev_ct_ptr = C.cast(dev_ct_addr, C.POINTER(C.c_int))
error_t = cuda.cudaGetDeviceCount(dev_ct_ptr)
@enricofoltran
enricofoltran / main.go
Last active April 1, 2024 00:17
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@savaki
savaki / main.go
Last active August 22, 2022 09:27
comparison of confluent-kafka-go vs sarama-cluster consumer performance
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
@donmccurdy
donmccurdy / dat-api.md
Created November 29, 2017 16:46
Missing api docs for dat.gui.