Skip to content

Instantly share code, notes, and snippets.

@jamesmurdza
jamesmurdza / Main.java
Created April 13, 2024 04:32
Java game
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Main extends JPanel implements ActionListener, KeyListener {
private Timer timer;
private int playerX, playerY, playerVelocityY;
private boolean isJumping, isMovingLeft, isMovingRight;
private static final int PLAYER_WIDTH = 50;
private static final int PLAYER_HEIGHT = 50;
@jamesmurdza
jamesmurdza / api_key.py
Created April 6, 2024 17:52
Replit Gemini API Key
genai.configure(api_key=os.environ['GOOGLE_API_KEY'])
// Select all forms on the page
const forms = document.querySelectorAll('form');
// Iterate over each form and attach a submit event listener
forms.forEach(form => {
form.addEventListener('submit', event => {
event.preventDefault(); // Prevent the default form submission behavior
// Get form data
const formData = new FormData(form);
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
class MyRequestHandler(BaseHTTPRequestHandler):
def _set_headers(self, status_code=200, content_type='text/html'):
self.send_response(status_code)
self.send_header('Content-type', content_type)
self.end_headers()
def do_GET(self):
import Phaser from "phaser";
function preload() {
this.load.image("sky", "Assets/sky.png");
this.load.image("ground", "Assets/platform.png");
this.load.image("star", "Assets/star.png");
this.load.image("bomb", "Assets/bomb.png");
this.load.spritesheet("dude", "Assets/dude.png", {
frameWidth: 32,
frameHeight: 48,
@jamesmurdza
jamesmurdza / Code.gs
Last active February 4, 2024 15:41
Sticky cells in Google Sheets
// This code takes values put in to column A, and applies a formula to calculate column B.
// The result of the formula, not the formula, is added to column B.
function onEdit(e) {
var range = e.range;
var sheet = range.getSheet();
var row = range.getRow();
var col = range.getColumn();
@jamesmurdza
jamesmurdza / emoji+hash.js
Created December 15, 2023 20:35
Emoji Hash
function stringToNumber(inputString) {
let hash = 0;
for (let i = 0; i < inputString.length; i++) {
const charCode = inputString.charCodeAt(i);
hash = (hash << 5) - hash + charCode;
}
hash = Math.abs(hash);
return hash;
}
@jamesmurdza
jamesmurdza / Code.gs
Created December 15, 2023 19:56
Send an email from Google Sheets (Beginners Apps Script tutorial)
function myFunction() {
let sheet = SpreadsheetApp.getActiveSheet();
let address = sheet.getRange("A1").getValue();
let subject = sheet.getRange("A2").getValue();
let body = sheet.getRange("A3").getValue();
MailApp.sendEmail(address, subject, body);
}
@jamesmurdza
jamesmurdza / sheet_to_map.py
Last active February 18, 2024 11:58
Google Sheet to custom Google Map
import pandas as pd
import requests
import re
def get_final_url(url):
response = requests.get(url, allow_redirects=True)
return response.url
# Load the CSV file
file_path = 'sf housing - list.csv'
@jamesmurdza
jamesmurdza / Firebase+Clerk.ts
Created August 29, 2023 21:09
Firebase and Clerk example hook
import { initializeApp } from "firebase/app";
import { getFirestore, collection, getDocs } from 'firebase/firestore/lite';
import { getAuth, signInWithCustomToken } from "firebase/auth";
import { firebaseConfig } from "../config/firebase"
import { useAuth } from "@clerk/clerk-react";
import { useEffect, useState } from "react";
// Initialize Firebase app with the provided configuration