Skip to content

Instantly share code, notes, and snippets.

View hansen1416's full-sized avatar

Longzhen Han hansen1416

  • Brighton, UK
View GitHub Profile
@hansen1416
hansen1416 / cuda_11.8_installation_on_Ubuntu_22.04
Created November 5, 2024 07:45 — forked from MihailCosmin/cuda_11.8_installation_on_Ubuntu_22.04
Instructions for CUDA v11.8 and cuDNN 8.7 installation on Ubuntu 22.04 for PyTorch 2.0.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
@hansen1416
hansen1416 / quaternion2euler.py
Created February 23, 2024 03:37
quaternion to euler, same logic as threejs
"""
python quaternion to euler
same logic as in three.js
"""
import math
class Euler:
def __init__(self, x=0, y=0, z=0):
@hansen1416
hansen1416 / main.dart
Created December 6, 2023 09:34
stomp-dart-client-demo
// dependencies:
// stomp_dart_client: ^1.0.0
import 'dart:async';
import 'dart:convert';
import 'package:stomp_dart_client/stomp.dart';
import 'package:stomp_dart_client/stomp_config.dart';
import 'package:stomp_dart_client/stomp_frame.dart';
"""
`dynprm` is a vector of actuator dynamic parameters that includes the actuator’s mass, damping, and spring constant 1.
`gainprm` is a vector of actuator gain parameters that includes the actuator’s proportional gain, derivative gain, and integral gain 1.
`biasprm` is a vector of actuator bias parameters that includes the actuator’s bias force and bias torque
"""
model = mujoco.MjModel.from_xml_path(xml_path)
data = mujoco.MjData(model)
@hansen1416
hansen1416 / mujoco_joints.py
Last active October 9, 2023 02:29
introduction to 4 joints type in mujoco
import time
import mujoco
import mujoco.viewer
import math
from transforms3d import quaternions
from lib.BaseRender import BaseRender
class BaseRender:
@hansen1416
hansen1416 / run.py
Last active September 7, 2023 05:01
biefly compare pandas/polars load speed
"""
vibration wave data, for a full (100000, 3) file, the size is 1,070,89KB
"""
if __name__ == "__main__":
time_spent = []
for file in os.listdir(WAVE_DATA_DIR):
start = time.time()
@hansen1416
hansen1416 / index.js
Last active June 12, 2022 14:25
Bron-Kerbosch-algorithm
#!/usr/bin/node
// - A group is an array of player names who have recently played with each other.
// - Each member in a group must have played with each other member.
// - Each group must have at least two names, and duplicate groups must be discarded.
// - If a group is entirely contained in a larger group, it must be discarded in favor of the larger group.
/**
* A brutal force solution to this problem is as follows
* 1.find all of the subset of the given players list with minimum size of 2
@hansen1416
hansen1416 / gist:9da9f3b4df1820f32f65409212291155
Created August 17, 2021 01:30
Segment tree, Range sum query
class SegmentTree():
def __init__(self, array):
# first pad array to nearest 2^k
# https://stackoverflow.com/questions/466204/rounding-up-to-next-power-of-2
n = len(array) - 1
n |= n >> 1
n |= n >> 2
n |= n >> 4