Skip to content

Instantly share code, notes, and snippets.

View colbyford's full-sized avatar
🧬

Colby T. Ford colbyford

🧬
View GitHub Profile
@f0k
f0k / cuda_check.py
Last active December 5, 2024 13:35
Simple python script to obtain CUDA device information
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Outputs some information on CUDA-enabled devices on your computer,
including current memory usage.
It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1
from C to Python with ctypes, so it can run without compiling anything. Note
that this is a direct translation with no attempt to make the code Pythonic.
@dcomtois
dcomtois / r_c.txt
Last active January 10, 2024 19:08
Linking R internal & primitive C functions with appropriate source files. --- printname = R function name ; c.entry = C function ; sourcefile = relevant C source file; line_no: line featuring fn definition (not all checked)
printname c.entry file line_no
- do_arith R-4.0.3\src\main\arithmetic.c 411
! do_logic R-4.0.3\src\main\logic.c 40
!= do_relop R-4.0.3\src\main\relop.c 51
$ do_subset3 R-4.0.3\src\main\subset.c 1206
$<- do_subassign3 R-4.0.3\src\main\subassign.c 2081
%% do_arith R-4.0.3\src\main\arithmetic.c 411
%*% do_matprod R-4.0.3\src\main\array.c 1228
%/% do_arith R-4.0.3\src\main\arithmetic.c 411
& do_logic R-4.0.3\src\main\logic.c 40
@pkuczynski
pkuczynski / LICENSE
Last active March 14, 2025 14:12
Read YAML file from Bash script
MIT License
Copyright (c) 2014 Piotr Kuczynski
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWAR
@vvinichenko
vvinichenko / life.r
Created February 23, 2012 19:48
Game of Life in R
shiftMatrix <- function(mx, dr, dc) {
#Shift the matrix by dr (delta r) rows and dc columns
#by adding e.g. dr rows of zeros and removing dr rows from the other side
nr <- nrow(mx)
nc <- ncol(mx)
#If the matrix is shifted by more than its nrow or ncol, we get a matrix of zeros
if (abs(dr) >= nr || abs(dc) >= nc) {
mx <- matrix(0, nrow = nr, ncol = nc)