Skip to content

Instantly share code, notes, and snippets.

View yhunko's full-sized avatar
🇺🇦

Yehor Hunko yhunko

🇺🇦
View GitHub Profile
@yhunko
yhunko / PreviewBlogPost.page.tsx
Created December 26, 2023 09:17
Sanity CMS setup steps
import { q } from 'groqd';
import { useLiveQuery } from 'next-sanity/preview';
import { BlogPostPage } from './BlogPost.page';
type PreviewBlogPostPageProps = {
initialData: PostSelection;
};
const PreviewBlogPostPage: FC<PreviewBlogPostPageProps> = ({ initialData }) => {
@yhunko
yhunko / _app.tsx
Created July 3, 2023 10:37
Next.js + MUI + Emotion server cache
// imports ...
const clientSideEmotionCache = createEmotionCache();
export type CustomAppProps = AppProps & {
Component: NextPageWithLayout<any>;
emotionCache?: EmotionCache;
};
function MyApp({ Component, pageProps, emotionCache = clientSideEmotionCache }: CustomAppProps) {
@yhunko
yhunko / calc.js
Last active April 23, 2021 13:35
Fun solution for a task on Codewars. https://www.codewars.com/kata/525f3eda17c7cd9f9e000b39
var numbers = [
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
@yhunko
yhunko / dynamicPrivateMethodCall.py
Last active April 23, 2021 13:44
This example shows how dynamically defined ptotected method could call private one in Python
class Test():
# This method defines a dynamic method
def _method1(self, name):
# Creating a dynamic protected method
# which calls the potected `method2`
exec("self._%s = self._%s__method2" % (name, __class__.__name__))
def __method2(self):
print("from method2")
def _method3(self):
# Calling a dynamically defined
const extendedEuclidAlgorithm = (p, q, kv) => {
let out = ''
const Fe = (p - 1) * (q - 1)
let uPrev = 1,
vPrev = 0,
u = 0,
v = 1,
rPrev = kv,
r = Fe