Skip to content

Instantly share code, notes, and snippets.

View mwrites's full-sized avatar
🔧

mwrites mwrites

🔧
View GitHub Profile
@mwrites
mwrites / cuda_install.md
Created January 19, 2024 02:05 — forked from denguir/cuda_install.md
Installation procedure for CUDA & cuDNN

How to install CUDA & cuDNN on Ubuntu 22.04

Install NVIDIA drivers

Update & upgrade

sudo apt update && sudo apt upgrade

Remove previous NVIDIA installation

cat not_found.txt | xargs -I {} grep {} db/sends.json
@mwrites
mwrites / anchor_deploy.bash
Last active January 28, 2023 04:26
deploy program idl
anchor deploy ... \\
&& anchor idl init -f target/idl/thread_program.json solana address -k $(target/deploy/clockwork_thread_program.json) \\
|| anchor idl upgrade -f target/idl/thread_program.json solana address -k $(target/deploy/clockwork_thread_program.json)
Note the usage of "||"
-> Ideally anchor idl init just need to be run once and can be removed from the script entirely
@mwrites
mwrites / from_str.rs
Last active September 30, 2022 23:17
rust split option to result to value
use std::num::ParseIntError;
use std::str::FromStr;
#[derive(Debug, PartialEq)]
enum ParsePersonError {
// Empty input string
Empty,
// Incorrect number of fields
BadLen,
// Empty name field
@mwrites
mwrites / remove_service.sh
Created January 25, 2022 10:22
Completely Remove a Service
systemctl stop [servicename]
systemctl disable [servicename]
rm /etc/systemd/system/[servicename]
rm /etc/systemd/system/[servicename] # and symlinks that might be related
rm /usr/lib/systemd/system/[servicename]
rm /usr/lib/systemd/system/[servicename] # and symlinks that might be related
systemctl daemon-reload
systemctl reset-failed
@mwrites
mwrites / install_timescaledb.sh
Last active January 25, 2022 08:52
Install TimescaleDB on CentOS8
#!/usr/bin/env bash
# ------------------------------------------ HELP
# https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
# https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-8
# (NOT PRECISE): https://docs.timescale.com/install/latest/self-hosted/installation-redhat/#setting-up-the-timescaledb-extension
# export SYSTEMD_EDITOR=vim
# Logs:
# journalctl -xeu postgresql-14
@mwrites
mwrites / solana-workflow.sh
Last active January 7, 2022 13:18
Solana Workflow
anchor init myproj; cd myproj; anchor build
# Open a new tab and run a local ledger
solana-test-validator --no-bpf-jit
# Go back to main tab
anchor deploy `solana address -k target/deploy/bouteilles-keypair.json`
# After our first deploy we now have a keypair and we can use the public address as the programID.
sed -i '' "s/Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS/$(solana address -k target/deploy/bouteilles-keypair.json)/g" Anchor.toml
@mwrites
mwrites / MyEpicNFT.sol
Last active December 18, 2021 10:52
Buildspace - Ethereum NFT - Section 2 - Create Our SVG
pragma solidity ^0.8.0;
// We first import some OpenZeppelin Contracts.
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "hardhat/console.sol";
// We inherit the contract we imported. This means we'll have access
// to the inherited contract's methods.
contract MyEpicNFT is ERC721URIStorage {
@mwrites
mwrites / chainClient.js
Last active January 4, 2022 14:00
Web3 Anchor Client
import { Connection, PublicKey } from '@solana/web3.js';
import { Program, Provider, web3, BN } from '@project-serum/anchor';
import { programAddress, pdaSeed, network, connectionsOptions } from './config';
// SystemProgram is a reference to the Solana runtime!
const { SystemProgram } = web3;
@mwrites
mwrites / linkedlist.py
Last active September 10, 2021 06:53
Python - LinkedList
# ******* Structures
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):