coding-julia
Julia: multiple dispatch, type system, metaprogramming, Pkg, scientific computing, GPU CUDA.jl
What this skill does
# coding-julia
## Purpose
This skill equips the AI to handle Julia programming tasks, focusing on high-performance scientific computing, data analysis, and GPU acceleration using features like multiple dispatch and metaprogramming.
## When to Use
Use this skill for numerical simulations, data science workflows, GPU-accelerated computations, or when you need efficient type systems and package management. Apply it in scenarios requiring fast prototyping, such as machine learning models or large-scale data processing, especially with libraries like CUDA.jl.
## Key Capabilities
- Multiple dispatch: Define functions that behave differently based on argument types, e.g., for optimized numerical operations.
- Type system: Leverage parametric types and unions for type-safe code, reducing errors in scientific applications.
- Metaprogramming: Use macros to generate code at runtime, like @time for performance profiling.
- Pkg: Manage dependencies with a built-in package manager for easy installation and versioning.
- Scientific computing: Integrate with libraries for linear algebra (e.g., LinearAlgebra.jl) and optimization.
- GPU support: Utilize CUDA.jl for parallel computing on NVIDIA GPUs, enabling high-throughput tasks.
## Usage Patterns
To accomplish tasks, invoke Julia via the REPL or scripts. For interactive sessions, start with `julia` in the terminal. Use project environments for isolation: create one with `julia --project=.` and activate via `using Pkg; Pkg.activate(".")`. For metaprogramming, define macros to automate repetitive code. When handling data, load packages first, e.g., `using DataFrames` for tabular data, then perform operations in a loop or function. Always specify types for performance, like `function compute(x::Float64) ... end`.
## Common Commands/API
- Package management: Use `using Pkg; Pkg.add("CUDA")` to install CUDA.jl; remove with `Pkg.rm("CUDA")`.
- REPL commands: Enter interactive mode with `julia`, then use `?function_name` for help; exit with Ctrl+D.
- CLI flags: Run scripts with `julia --project=env_name script.jl` to use a specific environment; add `-O3` for optimization.
- API examples: For multiple dispatch, write: `function add(a::Int, b::Int) return a + b end; add(1, 2) # Returns 3`.
- Code snippets: Matrix operations: `using LinearAlgebra; A = rand(3,3); eigenvalues = eigen(A).values`.
- Config formats: Edit Project.toml for dependencies, e.g., add `[deps] CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"`; use Manifest.toml for exact versions.
## Integration Notes
Integrate Julia into projects by embedding it in Jupyter notebooks via IJulia.jl: first, install with `using Pkg; Pkg.add("IJulia")`, then launch with `julia -i -e 'using IJulia; notebook()'` from the terminal. For external tools, link Julia with C libraries using ccall, e.g., `ccall((:function_name, "libname"), ReturnType, (ArgTypes,), args...)`. If using GPU, ensure CUDA drivers are installed and set the environment variable for paths, like `$CUDA_PATH=/usr/local/cuda`. For web services, pass API keys via env vars, e.g., `ENV["API_KEY"] = $SERVICE_API_KEY` before making requests with HTTP.jl.
## Error Handling
To handle errors, use try-catch blocks: `try; risky_operation(); catch e; println("Error: ", e) end`. Check assertions with `@assert condition "Message"`, which throws an error if false. For package issues, run `Pkg.status()` to verify dependencies; resolve conflicts by updating with `Pkg.update()`. In GPU code, check CUDA errors via `CUDA.device_synchronize()` after kernel launches. Always log errors for debugging, e.g., use Logging.jl: `using Logging; @info "Starting computation"`.
## Usage Examples
1. **Matrix Multiplication with Multiple Dispatch:** To compute matrix products efficiently, use: `function multiply(A::Matrix, B::Matrix) return A * B end; A = rand(1000,1000); result = multiply(A, A) # Handles large arrays via dispatch`.
2. **GPU-Accelerated Computation:** For parallel summing on GPU, first add CUDA.jl: `using Pkg; Pkg.add("CUDA"); using CUDA; d_a = CuArray([1,2,3]); result = sum(d_a) # Offloads to GPU for speed`.
## Graph Relationships
- Related to: coding-python (shares scientific computing tools like NumPy equivalents), coding-r (common in data science pipelines).
- Linked via tags: julia (direct match), scientific (connects to data-science skills), data-science (overlaps with coding-r and coding-python), coding (cluster relation to all coding-* skills).
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.