Skip to content

Instantly share code, notes, and snippets.

@HViktorTsoi
HViktorTsoi / Argsort.cpp
Created June 21, 2020 07:23
C++ STL implementation of Argsort
#include <vector>
#include <algorithm>
/**
* Argsort(currently support ascending sort)
* @tparam T array element type
* @param array input array
* @return indices w.r.t sorted array
*/
template<typename T>
"""Pseudocode description of the AlphaZero algorithm."""
from __future__ import google_type_annotations
from __future__ import division
import math
import numpy
import tensorflow as tf
from typing import List
@wangruohui
wangruohui / intel-nvidia.md
Last active July 27, 2024 14:14
Intel for display, Nvidia for computing

Intel for display, NVIDIA for computing

This guide will show you how to use Intel graphics for rendering display and NVIDIA graphics for CUDA computing on Ubuntu 18.04 / 20.04 desktop.

I made this work on an ordinary gaming PC with two graphics devices, an Intel UHD Graphics 630 plus an NVIDIA GeForce GTX 1080 Ti. Both of them can be shown via lspci | grep VGA.

00:02.0 VGA compatible controller: Intel Corporation Device 3e92
01:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
@reywood
reywood / how-to.md
Last active September 18, 2023 01:35
How to get a stack trace from a stuck/hanging python script

How to get a stack trace for each thread in a running python script

Sometimes a python script will simply hang forever with no indication of where things went wrong. Perhaps it's polling a service that will never return a value that allows the program to move forward. Here's a way to see where the program is currently stuck.

Install gdb and pyrasite

Install gdb.

# Redhat, CentOS, etc
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active July 27, 2024 14:45
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mcastelino
mcastelino / iptables-cheatsheet.md
Last active July 10, 2024 08:51
iptables-cheatsheet

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal
@mnespor
mnespor / NSNotificationCenter+Promise.swift
Created May 7, 2016 03:45
Exploration of PromiseKit issue 415
import Foundation.NSNotification
#if !COCOAPODS
import PromiseKit
#endif
/**
To import the `NSNotificationCenter` category:
use_frameworks!
pod "PromiseKit/Foundation"
@samba
samba / ubuntu-vnc-activate-remote.sh
Last active January 24, 2024 00:56
Activate VNC support in Ubuntu, from command-line (for active sessions)
#!/bin/sh
# This assumes you have access to the system via SSH already, and need
# remote VNC access as the same user, and you want only the primary display.
export DISPLAY=:0
# Encoded password with http://www.motobit.com/util/base64-decoder-encoder.asp
export VNC_PASSWORD="dm5jX3Bhc3N3b3JkNzE=" # vnc_password71
export VNC_PASSWORD="dm5jX3Bhc3M=" # vnc_password (a character limit is enforced?)
# Sadly many common VNC clients don't support encryption.
//
// SimpleScrollingStack.swift
// A super-simple demo of a scrolling UIStackView in iOS 9
//
// Created by Paul Hudson on 10/06/2015.
// Learn Swift at www.hackingwithswift.com
// @twostraws
//
import UIKit
@ralfebert
ralfebert / swift-kvo-example.swift
Last active October 18, 2020 21:41 — forked from correia/swift-kvo-example.swift
Swift 1.1: dynamic for observable properties neccessary, observeValueForKeyPath signature changed
//
// Swift-KVO
//
// Created by Jim Correia on 6/5/14.
// Copyright (c) Jim Correia. All rights reserved.
//
// Update: 6/17/2014
//
// KVOContext has gone away; use the same idiom you'd use from Objective-C for the context