Skip to content

Instantly share code, notes, and snippets.

View rjzak's full-sized avatar

Richard Zak rjzak

View GitHub Profile
@achimnol
achimnol / cuda.conf
Last active September 25, 2016 15:32
An upstart configuration for NVIDIA CUDA device initialization without X environments (derived from Sangjin Han's init.d script)
description "CUDA initialization without X environments"
start on runlevel [2345]
stop on runlevel [!2345]
pre-start script
DRIVER=nvidia
HOLD_GPU=/usr/local/bin/hold_gpu.py
[ -x "$HOLD_GPU" ] || { echo "$HOLD_GPU is missing or not executable!"; exit 1; }
@stevenvo
stevenvo / numpy-array-sort.py
Last active March 16, 2021 08:23
Sort array by nth column in Numpy
# sort array with regards to nth column
arr = arr[arr[:,n].argsort()]
@ramhiser
ramhiser / one-hot.py
Last active April 7, 2021 06:44
Apply one-hot encoding to a pandas DataFrame
import pandas as pd
import numpy as np
from sklearn.feature_extraction import DictVectorizer
def encode_onehot(df, cols):
"""
One-hot encoding is applied to columns specified in a pandas DataFrame.
Modified from: https://gist.github.com/kljensen/5452382
import torch
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size, n_layers=1):
super(RNN, self).__init__()
self.input_size = input_size
self.hidden_size = hidden_size
@classilla
classilla / qemu-pnv-kvm.diff
Created June 22, 2020 04:09
A desperate attempt to get PowerNV KVM acceleration working. See if you can triumph where I have failed.
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index c9cb6fa3..c1f43310 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -23,16 +23,17 @@
#include "qapi/error.h"
#include "sysemu/sysemu.h"
#include "sysemu/numa.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
@lost-theory
lost-theory / app.py
Created January 12, 2013 23:49
flask: show request time in template
import time
from flask import Flask, request, g, render_template
app = Flask(__name__)
app.config['DEBUG'] = True
@app.before_request
def before_request():
g.request_start_time = time.time()
@Brainiarc7
Brainiarc7 / build-tensorflow-from-source.md
Last active July 29, 2023 21:28
Build Tensorflow from source, for better performance on Ubuntu.

Building Tensorflow from source on Ubuntu 16.04LTS for maximum performance:

TensorFlow is now distributed under an Apache v2 open source license on GitHub.

On Ubuntu 16.04LTS+:

Step 1. Install NVIDIA CUDA:

To use TensorFlow with NVIDIA GPUs, the first step is to install the CUDA Toolkit as shown:

@bridgeythegeek
bridgeythegeek / MyFirstPANDA.md
Last active August 15, 2023 10:48
My First PANDA

My First PANDA

Introduction

Being someone who tries to play a lot with Windows memory, I really wanted to play with PANDA, but I was slightly scared because I'd never touched qemu before - all my experience had been with VirtualBox and VMware.

My goal was to install PANDA into a (relatively) clean install of Debian 8 'Jessie', capture a recording and successfully run a PANDA plugin.

1. Get PANDA

@KodrAus
KodrAus / Profile Rust on Linux.md
Last active November 14, 2023 17:19
Profiling Rust Applications

Profiling performance

Using perf:

$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg

NOTE: See @GabrielMajeri's comments below about the -g option.

@Shaltz
Shaltz / gist:1d65a07a0901a36fb7f1
Created September 16, 2015 09:02
HOW TO fix openLDAP checksum error on config files
(source : http://injustfiveminutes.com/category/openldap)
How to fix “ldif_read_file: checksum error”
Posted on October 28, 2014
15
Well, in spite of you did read a banner saying “# AUTO-GENERATED FILE – DO NOT EDIT!! Use ldapmodify.” you ignored it and made some manual modifications in any of the LDIF files in /etc/ldap/slapd.d/.
Don’t worry it happened to me too :) When you need to quickly setup an openLDAP server for development it is pretty much easier to tweak these files although the recommended way is to use ldapmodify tool. But if you change the LDIF files in cn=config manually, their contents and checksums won’t match, which is not fatal, but is annoying when using tools such as slapcat: