Skip to content

Instantly share code, notes, and snippets.

View ctongfei's full-sized avatar
:octocat:

Tongfei Chen ctongfei

:octocat:
View GitHub Profile
@meased
meased / pangocairoexample.py
Created February 8, 2018 18:20
PangoCairo text rendering with python3
#!/usr/bin/python3
#-*- coding:utf8 -*-
import cairo
import gi
gi.require_version('Pango', '1.0')
gi.require_version('PangoCairo', '1.0')
from gi.repository import Pango, PangoCairo
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 600, 100)
@alexlee-gk
alexlee-gk / configure_cuda_p70.md
Last active March 10, 2025 15:31
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04

This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)

A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly. In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers. This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.

@non
non / half.scala
Last active June 10, 2022 03:11
Scala implementation of 16-bit floating point numbers. Also, a test prgoram.
package half
import scala.math.{pow, round, signum}
import scala.util.Random.nextInt
import java.lang.{Float => JFloat}
/**
* Float16 represents 16-bit floating-point values.
*
* This type does not actually support arithmetic directly. The
@karpathy
karpathy / gist:587454dc0146a6ae21fc
Last active May 14, 2025 00:08
An efficient, batched LSTM.
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@paulp
paulp / The Signs of Soundness
Last active June 17, 2021 06:48
The Signs of Soundness
Hello scala, my old friend
I've come to take you home again
Because a feature slowly creeping
left me plagued with doubts and weeping
and the version that was tagged in the repo
just has to go
it lacks the signs of soundness
On sleepless nights I hacked alone
applying ant and other tools of stone