Skip to content

Instantly share code, notes, and snippets.

View Yidaotus's full-sized avatar
🎯
Focusing

Daniel Voigt Yidaotus

🎯
Focusing
View GitHub Profile
@Yidaotus
Yidaotus / gatsby-config.js
Created February 25, 2022 16:34
Gatsby Config
{
resolve: `gatsby-plugin-layout`,
options: {
component: require.resolve(`./src/components/Layout.tsx`),
},
},
@Yidaotus
Yidaotus / SpotifyCurrentlyPlaying.css
Created February 25, 2022 16:27
Spotify Currently Playing Styles
.eq-container {
pointer-events: none;
}
.bar {
display: inline-block;
position: relative;
margin-right: 3px;
width: 10px;
height: 1px;
@Yidaotus
Yidaotus / SpotifyCurrentlyPlaying.tsx
Created February 25, 2022 16:25
Currently Playing Widget
const SpotifyCurrentlyPlaying: React.FC = () => {
const [playingItem, fetching] = useCurrentlyPlaying();
const isPlaying = playingItem && playingItem.isPlaying;
return isPlaying ? (
<div className="fixed bottom-4 right-4 bg-white rounded p-2 drop-shadow-md flex justify-start items-center dark:bg-brand-dark min-w-[250px]">
<div className="relative">
<div className="pr-2">
<a href={playingItem.item.uri}>
<img
@Yidaotus
Yidaotus / fetch.ts
Created February 25, 2022 16:17
Fetch Function
const fetchSpotifyPlayer = async () => {
const URL = "./.netlify/functions/CurrentlyPlaying";
const OPTIONS = {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json;charset=UTF-8",
},
};
const response = await fetch(URL, OPTIONS);
@Yidaotus
Yidaotus / useCurrentlyPlaying.ts
Last active February 25, 2022 16:16
Currently Playing Custom Hook
type PollingMode = "STATIC" | "CALCULATED";
const BUFFER_TIME = 5000;
const WAIT_ON_ERROR = 60000;
const POLLING_RATE = 10000;
const POLLING_MODE: PollingMode = "CALCULATED";
const useCurrentlyPlaying = () => {
const [playingItem, setPlayingItem] = useState<SpotifyPlayer>();
const [fetching, setFetching] = useState(false);
@Yidaotus
Yidaotus / currentlyPlayingTypes.ts
Created February 25, 2022 16:01
Currently Playing Types
export interface SpotifyImage {
height: number;
width: number;
url: string;
}
export interface SpotifyAlbum {
images: Array<SpotifyImage>;
name: string;
}
@Yidaotus
Yidaotus / CurrentlyPlaying.ql
Created February 25, 2022 14:16
Currently Playing
query CurrentlyPlaying {
me {
spotify {
player {
progressMs
isPlaying
repeatState
shuffleState
item {
name

A step by step cheat sheet on how I usually deploy my fullstack application to a linux server for the initial alpha test.

Update the package list

sudo apt update

Install the mysql-server

@Yidaotus
Yidaotus / ecb.py
Created April 17, 2020 13:17
Break ecb
import requests
import math
flag = []
bytestocrunch = 32 # Get it with a block_size long pattern. bytes to crunch will be the (responce - (block_size*2))/2. *2 because we get a hexstring
block_size = 16 # Get it by appending n bytes until the output increases. Ater it increased count the bytes until it increases again
apattern = [0x61] * math.ceil(bytestocrunch/block_size) * block_size # Any byte will be sufficient
for y in range(1, bytestocrunch+1):
pattern = ''.join([hex(b)[2:].zfill(2) for b in apattern[:-y]]) # Convert 0:-y to a hex string
@Yidaotus
Yidaotus / adriens.py
Last active April 20, 2023 07:19
ADRIEN'S SIGNS
message = [67594220461269, 501237540280788, 718316769824518, 296304224247167, 48290626940198, 30829701196032, 521453693392074, <...> ]
p = 1007621497415251
exponent = int((p-1)/2)
bresult = [1 if pow(m, exponent, p) == 1 else 0 for m in message]
bresultgroup = [''.join(str(y) for y in bresult[x:x+8]) for x in range(0, len(bresult), 8)]
''.join([chr(int(x, 2)) for x in bresultgroup])