Skip to content

Instantly share code, notes, and snippets.

@brentworden
brentworden / DataReaderExtensions.cs
Last active March 26, 2025 02:58
System.Data.IDataReader extension method to fully read the bytes from a large binary column
using System.Data;
using System.IO;
namespace Extensions.Data {
public static class DataReaderExtensions {
/*
* Extension method on IDataReader that reads the entire contents of a large binary column using a single method call.
* Sample usage:
# !pip install --upgrade onnx==1.17.0 onnxruntime==1.20.1 onnxslim==0.1.48 optimum==1.24.0 transformers==4.48.3
import torch
import torch.nn as nn
from transformers import AutoProcessor, AutoModelForCausalLM
import os
import onnxslim
from optimum.onnx.graph_transformations import merge_decoders, check_and_save_model
model = AutoModelForCausalLM.from_pretrained(
@scokmen
scokmen / HttpStatusCode.ts
Created April 25, 2017 11:10
Typescript Http Status Codes Enum
"use strict";
/**
* Hypertext Transfer Protocol (HTTP) response status codes.
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
*/
enum HttpStatusCode {
/**
* The server has received the request headers and the client should proceed to send the request body
@asukakenji
asukakenji / 0-go-os-arch.md
Last active March 26, 2025 02:50
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@eneajaho
eneajaho / migrate-material-buttons.js
Created March 25, 2025 21:19
A migration to migrate all material buttons to use the input for the appearance instead of the selector
const fs = require('fs').promises;
const path = require('path');
const { EOL } = require('os'); // End Of Line character
// --- Configuration ---
const PROJECT_ROOT = process.argv[2] || '.'; // Get project root from arg or use current dir
const EXCLUDE_DIRS = ['node_modules', '.angular', 'dist', 'e2e', 'coverage']; // Directories to skip
const HTML_SUFFIX = '.html';
const APPLY_CHANGES = process.argv.includes('--apply'); // Check for --apply flag
// --- End Configuration ---
#!/bin/bash
# quick and dirty bash script to extract .gnu_debugdata section
# from ELF binaries to generate an IDC script that adds these
# names as symbols
# --rpw, 2020-06-21
SYMBOLFILE=debugdata_symbols.elf
if [ $# -lt 1 ]; then
echo "you need to supply a path to a binary"
@zeffron
zeffron / dispatcher.c
Created April 19, 2021 17:33
cilium/ebpf freplace sample
#include "vmlinux.h"
static int (*bpf_trace_printk)(const char* fmt, int fmt_size, ...) = (void *)BPF_FUNC_trace_printk;
__attribute__ ((noinline))
int function1(struct xdp_md *context, int value) {
volatile int ret = value;
char fmt[] = "not implemented";
bpf_trace_printk(fmt, sizeof(fmt));
return ret;
@eneajaho
eneajaho / analyze-components.js
Created March 25, 2025 20:45
Check components on project if they are OnPush
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const ts = require('typescript'); // Requires 'npm install typescript'
// --- Configuration ---
const DEFAULT_PROJECT_PATH = '.'; // Default to current directory
const EXCLUDED_DIRS = ['node_modules', 'dist', '.angular', '.vscode', '.git']; // Directories to skip
const COMPONENT_FILE_SUFFIX = '.component.ts';
@SarbajeetPaul
SarbajeetPaul / C: Nptl: W9-Q4
Created April 2, 2020 19:03
Write a C program to reverse an array by swapping the elements and without using any new array.
#include <stdio.h>
int main() {
int array[100], n, c;
scanf("%d", &n);
for (c = 0; c < n; c++) {
scanf("%d", &array[c]);
}
int j=n-1,t=0;
for(c=0;c<n/2;c++)