Skip to content

Instantly share code, notes, and snippets.

View kiranshila's full-sized avatar
🌈

Kiran Shila kiranshila

🌈
View GitHub Profile
@kiranshila
kiranshila / cpp-dev-env-flake.nix
Created January 11, 2025 23:27 — forked from fufexan/cpp-dev-env-flake.nix
C/C++ dev environment in Nix, using Clang
{
description = "C/C++ environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils, ... }@inputs:
utils.lib.eachDefaultSystem (
use hidapi::{HidDevice, HidError};
const PAYLOAD_SIZE: usize = 128;
// Factory-values for the VID and PID
const VID: u16 = 0x1a0d;
const PID: u16 = 0x15d8;
#[derive(Debug, thiserror::Error)]
pub enum Error {
@kiranshila
kiranshila / error
Created March 2, 2024 23:43
enyme error
ERROR: Enzyme execution failed.
Enzyme compilation failed.
Current scope:
; Function Attrs: mustprogress willreturn
define internal fastcc void @preprocess_julia_sqrt_13911([2 x double]* noalias nocapture nofree noundef nonnull writeonly sret([2 x double]) align 8 dereferenceable(16) %0, [2 x double] addrspace(11)* nocapture noundef nonnull readonly align 8 dereferenceable(16) "enzymejl_parmtype"="132501377410576" "enzymejl_parmtype_ref"="1" %1) unnamed_addr #79 !dbg !9095 {
top:
%2 = call noalias nonnull dereferenceable(16) dereferenceable_or_null(16) i8* @malloc(i64 16), !enzyme_fromstack !5228
%3 = bitcast i8* %2 to { double, i64 }*, !enzyme_caststack !68
%4 = call {}*** @julia.get_pgcstack() #81
%ptls_field93 = getelementptr inbounds {}**, {}*** %4, i64 2
@kiranshila
kiranshila / pack_ord_test.c
Created January 31, 2023 23:08
Packet Order Test
#include <arpa/inet.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
const int UDP_PAYLOAD = 8200;
use std::fs;
type FileDescriptor = usize;
type Entries = Vec<FileDescriptor>;
#[derive(Debug, Clone)]
enum FileKind {
RegularFile(usize),
Directory(Entries),
}
using PkgTemplates
t = Template(;
user="kiranshila",
dir="~/Projects/Julia",
julia=v"1.8",
plugins=[
License(;name="MIT"),
Git(;ssh=true,gpgsign=true),
CompatHelper(),
# In external Julia libraries
struct KATCPClient end
struct TAPCPClient end
# In CasperFPGA.jl
abstract type AbstractCasperTransport end
struct KatcpTransport <: AbstractCasperTransport end
struct TapcpTransport <: AbstractCasperTransport end
AbstractCasperTransport(::Type{KATCPClient}) = KatcpTransport()
#include <dada_def.h>
#include <dada_hdu.h>
#include <fcntl.h>
#include <ipcbuf.h>
#include <multilog.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
void print_arr(char *ptr, int len) {
from click import BadParameter
from pyvisa import ResourceManager
from pyvisa.resources import MessageBasedResource
from enum import Enum
import numpy as np
import pandas as pd
# Enums for discrete value selections
class Bandwidth(Enum):
@kiranshila
kiranshila / sexp.rs
Created May 5, 2022 20:08
Combining nom and rowan
use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::{FromPrimitive, ToPrimitive};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, FromPrimitive, ToPrimitive)]
#[allow(non_camel_case_types)]
#[repr(u16)]
enum SyntaxKind {
L_PAREN = 0, // '('
R_PAREN, // ')'
ATOM, // '+', '15'