Skip to content

Instantly share code, notes, and snippets.

@jamesmurdza
jamesmurdza / detect-programming-lang.ts
Created August 3, 2023 00:32
Detect the programming language from a snippet
function detectPopularLanguages(codeSnippet: string): string[] {
const languageKeywords: { [key: string]: RegExp } = {
JavaScript: /\b(?:var|let|const|function|if|else|for|while|switch|case|break|return)\b/g,
Python: /\b(?:def|if|elif|else|for|while|break|continue|return)\b/g,
Java: /\b(?:public|private|protected|class|void|static|if|else|for|while|switch|case|break|return)\b/g,
CSharp: /\b(?:public|private|protected|class|void|static|if|else|for|while|switch|case|break|return)\b/g,
C: /\b(?:int|float|char|void|if|else|for|while|switch|case|break|return)\b/g,
Ruby: /\b(?:def|if|else|elsif|unless|end|for|while|case|when)\b/g,
PHP: /\b(?:public|private|protected|function|if|else|for|while|switch|case|break|return)\b/g,
Swift: /\b(?:class|func|var|let|if|else|for|while|switch|case|break|return)\b/g,
@jamesmurdza
jamesmurdza / MyToken.sol
Last active March 29, 2023 16:46
Example of a smart contract
pragma solidity ^0.8.0;
contract MyToken {
mapping(address => uint) public balanceOf;
constructor(uint _initialSupply) {
balanceOf[msg.sender] = _initialSupply;
}
function transfer(address _to, uint _value) public {
@jamesmurdza
jamesmurdza / JS+TS.md
Last active March 23, 2023 09:55
JavaScript and TypeScript comparison

JavaScript and TypeScript comparison

Variable Declarations

JavaScript:

var x = 10;
@jamesmurdza
jamesmurdza / create_github_repo.sh
Last active March 18, 2023 09:29
GitHub create new repo using access token
GITHUB_USERNAME=username
REPO_NAME=repo
# Get a token from here: https://github.com/settings/tokens
GITHUB_TOKEN=token
mkdir $REPO_NAME
cd $REPO_NAME
git init
@jamesmurdza
jamesmurdza / Dockerfile
Created March 17, 2023 09:22
Dockerfile for a scheduled Python script
FROM amancevice/pandas:1.4.4
WORKDIR /app
# Copy the Python application.
COPY requirements.txt .
COPY app.py .
# Install all dependencies for the Python application.
RUN pip install -r requirements.txt
@jamesmurdza
jamesmurdza / characters.txt
Last active March 14, 2023 15:41
Special characters for coding
" quote
' single quote
^ carrot
& ampersand
/ slash
\ backslash
- dash/hyphen
_ underscore
` backtick
~ tilde
[
{
"eventDate": "03/31/2021",
"description": "Solana's mainnet beta launch."
},
{
"eventDate": "06/08/2021",
"description": "Solana raised $314 million in a token sale led by Andreessen Horowitz and Polychain Capital."
},
{
[
{"eventDate": "03-12-2020", "description": "Solana Labs, the team behind Solana, announced a $1.76 million fund to support Solana-based projects."},
{"eventDate": "21-04-2021", "description": "Solana announced the launch of 'Wormhole,' a decentralized bridge connecting Solana to other blockchains, including Ethereum."},
{"eventDate": "09-09-2021", "description": "Solana reached an all-time high price of $215.96, following a period of rapid price increases."},
{"eventDate": "26-09-2021", "description": "Solana experienced a sudden and brief outage, which caused the price to drop significantly and led to concerns about the stability of the network."},
{"eventDate": "01-10-2021", "description": "FTX, a major cryptocurrency exchange, announced a $150 million fund to support the development of the Solana ecosystem."}
]

Standards for data representation

Character sets and encodings

A character set is a standardized set of characters. It is often used to define which characters are supported by a particular format or software program. These characters include printable characters and control characters. Unicode is a character set with 149,186 characters. ASCII has a character set of 128 characters.

A character encoding is a mapping between a character set and binary values.

Text Encoding Binary
@jamesmurdza
jamesmurdza / Python-list-functions.md
Created January 3, 2023 13:55
Important Python functions for working with lists