Skip to content

Instantly share code, notes, and snippets.

@sunapi386
sunapi386 / compress_cardano_db.sh
Created December 19, 2023 00:16
Compressing the Cardano node database to reduce storage space, for systems with limited storage capacity.
#!/bin/bash
# This script compresses the Cardano node's 'immutable' directory to reduce storage usage.
# It creates directories for archives, indexes, and a write-overlay within the db path.
# The script groups files by their name prefixes, compresses them using pixz, and checks for existing archives to avoid reprocessing.
# After compression, original files are deleted, and new files are moved to the write-overlay.
# Ratarmount is used to mount a virtual directory combining the read-only archives and the write-overlay for operational continuity.
# Variables
CARDANO_DB_PATH=~/cnode/db # Replace with your actual Cardano db path
RATAR_PATH="$CARDANO_DB_PATH/ratar"
@sunapi386
sunapi386 / cuda_11.7_installation_on_Ubuntu_22.04
Last active June 1, 2023 15:27 — forked from primus852/cuda_11.7_installation_on_Ubuntu_22.04
Instructions for CUDA v11.7 and cuDNN 8.5 installation on Ubuntu 22.04 for PyTorch 1.12.1
#!/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
@sunapi386
sunapi386 / CMakeLists.txt
Created May 14, 2020 00:18
ros publish subscribe test
project(rosexample)
cmake_minimum_required(VERSION 3.1)
add_compile_options(-std=c++17)
find_package(catkin REQUIRED COMPONENTS roscpp rospy rostest std_msgs message_generation)
add_message_files(FILES ack.msg)
generate_messages(DEPENDENCIES std_msgs)
include_directories(${catkin_INCLUDE_DIRS})
add_rostest_gtest(tester tester.test tester.cpp)
add_dependencies(tester ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(tester ${catkin_LIBRARIES} ${rostest_LIBRARIES} gtest)
@sunapi386
sunapi386 / curl.sh
Created May 9, 2020 20:25
mailgun example sending
curl -s --user 'api:key-YOURAPIKEYHERE' \
https://api.mailgun.net/v3/mg.example.co/messages \
-F from='Excited User <postmaster@mg.example.co>' \
-F to=j@example.co \
-F subject='Hello' \
-F text='Testing some Mailgun awesomeness!'
@sunapi386
sunapi386 / download_vimeo_video.fish
Created October 26, 2019 23:02
Fish shell script to download Vimeo video
#!/usr/bin/env fish
# Script to download videos from vimeo
# Vimeo streams the video to you in segments of m4s and so this script
# downloads all the segments until failure, then combines the segments
# into a single mp4 file.
function download_vimeo_video
if test (count $argv) -ne 2
echo "Require a topic and url"
@sunapi386
sunapi386 / analysis.md
Last active October 26, 2019 01:15
stack smash with copy_elision and lying to c++ compiler

Looking at the difference between the generated assembly.

Foo::Foo() [base object constructor]:                         <
        pushq   %rbp                                          <
        movq    %rsp, %rbp                                    <
        movq    %rdi, -8(%rbp)                                <
        movq    -8(%rbp), %rax                                <
        pxor    %xmm0, %xmm0                                  <
        movss   %xmm0, (%rax)   ; 1.                          <
        nop                                                   <
@sunapi386
sunapi386 / mysterious.json
Created July 1, 2019 06:33
What kind of JSON is this, webGL?
{
"mesh": {
"vertices": [53812],
"indices": [300426],
"components": {
"normals": false,
"texCoords": 2
},
"data": [
"t4E9w+P2S0JG1IDCLENcPtBEuL46IjzDOcVLQhbqn8KvA2c+9Uq5vskFPcOQMTZClVSawkHxYz5j7rq+y4E7wxjVZkJCAIPCrWlePv32tb5EyjvDnq9aQt6RlsKKjmQ+orS3vtD1PcNQfCpClqOIwlFJXT4+V7u+n5w+w9IAPUKIY23CYhBYPtk9ub5KSz7DTcRQQrCyW8Lh6VU+xku3vnOnO8Mn8TFCS+iuwp7Naj6jAby+dPQ8w+l3DkIm857C",
Entwine 9f6d9cc compiles with PDAL 58c77bc4
curl localhost:4000 \
-F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", "variables": { "file": null } }' \
-F map='{ "0": ["variables.file"] }' \
-F 0=@yarn.lock
curl localhost:4000 \
-F operations='{ "query": "mutation ($files: [Upload!]!) { multipleUpload(files: $files) { id } }", "variables": { "files": [null, null] } }' \
-F map='{ "0": ["variables.files.0"], "1": ["variables.files.1"] }' \
-F 0=@yarn.lock \
-F 1=@package.json
@sunapi386
sunapi386 / pipeline.hjson
Created April 24, 2019 01:52
Use PDAL to create a ground surface model from point cloud input
# This is a hjson file, https://hjson.org/
# Linux bash
#GET=https://github.com/hjson/hjson-go/releases/download/v3.0.0/linux_amd64.tar.gz
# macOS bash
#GET=https://github.com/hjson/hjson-go/releases/download/v3.0.0/darwin_amd64.tar.gz
# Install
#curl -sSL $GET | sudo tar -xz -C /usr/local/bin
# Translate to Json
#hjson -j pipeline.hjson > pipeline.json
#pdal pipeline pipeline.json --verbose 8