Skip to content

Instantly share code, notes, and snippets.

@inre
inre / gpio.rs
Created July 31, 2015 20:18
Blink led on raspberry pi 9 (Rust lang)
#![feature(core_intrinsics)]
#[warn(dead_code)]
//#[warn(unused_assignments)]
extern crate mmap;
extern crate libc;
use libc::*;
use std::ffi::CString;
use std::path::Path;
use mmap::{MemoryMap,MapOption};
@shirriff
shirriff / main.c
Last active March 16, 2024 13:51
Example code using a timer with the BeagleBone Black's PRU microcontroller. This code generates 5 pulses with 100ns width.
/*
* Demonstration of the BeagleBone's PRU, using a timer.
* Ken Shirriff, http://righto.com
*/
#include <stdint.h>
#define DELAY_NS 100 // Use 500000000 for 0.5 second delay
#define WRITE_PIN 15 /* P8_11, Ethernet output data, pr1_PRU0_pru_r30_15 */
// PRU Interrupt control registers
@taylorpaul
taylorpaul / README.md
Last active November 20, 2023 10:27
Tensorboard on SLURM

Environment:

Tensorflow: v0.11.0rc2 OS: CENTOS 6.8 (No root access)

Description:

  1. The tensorboardSLURM.sh can be run with the following command to start a tensorboard server on a SLURM cluster:
sbatch --array=0-0 tensorboardSLURM.sh 
@vihari
vihari / tf_print.py
Last active April 10, 2019 09:06
Tensorflow's tf.Print to stdout instead of default stderr
"""
The default tf.Print op goes to STDERR
Use the function below to direct the output to stdout instead
Usage:
> x=tf.ones([1, 2])
> y=tf.zeros([1, 3])
> p = x*x
> p = tf_print(p, [x, y], "hello")
> p.eval()
hello [[ 0. 0.]]
@tholden
tholden / NearestKroneckerProduct.m
Last active December 29, 2023 11:11
Matlab Code for finding the nearest Kronecker product to a matrix
function [ B, C, D ] = NearestKroneckerProduct( A, SizeB, SizeC, Hermitian ) %#codegen
% https://doi.org/10.1007/978-94-015-8196-7_17
m = size( A, 1 );
n = size( A, 2 );
m1 = SizeB( 1 );
n1 = SizeB( 2 );
m2 = SizeC( 1 );
n2 = SizeC( 2 );
if nargin < 4
@RobinJadoul
RobinJadoul / README.md
Created January 20, 2023 13:08
HEPL - a simple repl integration for the helix editor

HEPL

This is a simple repl integration for the helix editor. It relies on on tmux to show the repl in a separate pane and on jupyter (jupyter-console and whatever jupyter kernels you might like) to run the actual repl.

Features

  • Works with any jupyter kernel
  • Code is dedented to the highest common level, so you can send python code from the middle of a function to the repl too
  • No issues with multiline pieces of code or blank lines inside of a function body, it works as you'd expect it to
@bilalmughal
bilalmughal / ec2_graviton_dl_bootstrap.sh
Last active April 10, 2024 19:36
This script automates the setup of an Amazon EC2 Graviton ARM-based instances for deep learning tasks. It takes care of installing essential utilities, setting up latest Nvidia drivers and CUDA 12.2 toolkit and cuDNN library, and build PyTorch from source. The step-by-step guided can be checked here. https://jumpshare.com/blog/deep-learning-on-a…
#!/bin/bash
set -e # Exit on any error
# Check if required arguments are provided
if [ -z "$REGION" ] || [ -z "$SECURITY_GROUPS" ] || [ -z "$KEY_PAIR" ] || [ -z "$SUBNET" ]; then
echo "Error: You must provide REGION, SECURITY_GROUPS, KEY_PAIR, and SUBNET as environment variables."
echo "Example:"
echo " export REGION=us-east-1"
echo " export SECURITY_GROUPS=sg-12345678,sg-87654321"
echo " export KEY_PAIR=my-key-pair"