Skip to content

Instantly share code, notes, and snippets.

View topherPedersen's full-sized avatar
💭
Rolling my katamari ball

Christopher Pedersen topherPedersen

💭
Rolling my katamari ball
View GitHub Profile
@topherPedersen
topherPedersen / App.tsx
Created April 7, 2024 20:52
React-Native Timeline Component Built with CSS (Prototype/Example)
import React from 'react';
import {
SafeAreaView, View,
} from 'react-native';
function App(): React.JSX.Element {
return (
<SafeAreaView style={{ flex: 1 }}>
<View>
<View style={{ flexDirection: 'row' }}>
@topherPedersen
topherPedersen / strip_newline.go
Created February 3, 2020 20:56
How to Strip Newline Characters from a String in Golang
package main
import (
"fmt"
"strings"
)
func main() {
var string_a string = "My super \nsweet \nstring has \nmany newline\n characters"
@topherPedersen
topherPedersen / lib.rs
Last active January 7, 2024 16:40
Solana 101: Hello, World Rust/Solana Program (from Figment.io's Solana 101 Course)
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint,
entrypoint::ProgramResult,
msg,
program_error::ProgramError,
pubkey::Pubkey,
};
@topherPedersen
topherPedersen / no-flash-on-button-click.html
Last active November 30, 2023 11:35
How to Prevent a Button from Changing its Border and Background Color in CSS When Clicked
<!DOCTYPE html>
<html>
<head>
<style>
.noFlash {
/* Remove onclick Background Color Change */
/* REFERENCE: https://bit.ly/2Yc95wR */
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
@topherPedersen
topherPedersen / MainActivity.java
Created October 12, 2023 20:23
Display a Toast Message on Android (using Java)
package com.example.toastapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
@topherPedersen
topherPedersen / DetectCollisionsBetweenHumanoids.lua
Created September 10, 2023 02:28
Detect Collisions Between Humanoids in Roblox
-- DisplayTextModule is some code I use to display text on screen for testing, if you see this in a code snippet, ignore this part
local DisplayTextModule = require(script.Parent.Parent.StarterGui.ScreenGui.Frame.TextLabel.DisplayTextModuleScript)
local Players = game:GetService("Players")
-- Works for R15, not sure if this works for R6 or not
local function partIsHumanoid(part)
if part.Name == "Head" then
return true
elseif part.Name == "UpperTorso" then
@topherPedersen
topherPedersen / changeHumanoidsAppearance.lua
Last active September 10, 2023 00:52
Changing a Roblox Humanoid's Appearance
local Players = game:GetService("Players")
local function alterPlayer(player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local userId = player.UserId
local humanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(userId)
humanoidDescription.HeadColor = Color3.fromHex("#39FF14")
humanoidDescription.LeftArmColor = Color3.fromHex("#39FF14")
humanoidDescription.RightArmColor = Color3.fromHex("#39FF14")
local DisplayTextModule = require(script.Parent.Parent.StarterGui.ScreenGui.OnScreenLogger.TextLabel.DisplayTextModuleScript)
DisplayTextModule.Display("hello, world")
local module = {}
function Display(text)
local textLabel = script.Parent
textLabel.Text = text
end
module.Display = Display
return module
@topherPedersen
topherPedersen / on_duplicate_key_update.py
Created December 10, 2019 21:57
ON DUPLICATE KEY UPDATE (with python and mysql.connector)
import mysql.connector
# Create MySQL Database Connection
database_connection = mysql.connector.connect(
host="99.111.11.99", # dummy ip address
user="your-super-sweet-admin-name",
passwd="y0uRpAsSw0Rd",
database="your_db"
)
cursor = database_connection.cursor()