Skip to content

Instantly share code, notes, and snippets.

View ademilter's full-sized avatar

Adem ilter ademilter

View GitHub Profile
@justincy
justincy / README.md
Last active April 5, 2024 22:19
Configure Storybook to work with Next.js, TypeScript, and CSS Modules

In addition to the Storybook for React setup, you'll also need to install these packages:

npm i -D @babel/core babel-loader css-loader style-loader
@mattdesl
mattdesl / about.md
Last active December 15, 2023 17:45
png + svg export with canvas-sketch and context 2D

PNG + SVG export from canvas-sketch

The helper function canvas-to-svg.js wraps a given render function (or renderer object) so that you can use Canvas2D context methods as usual, but upon single frame export (with Cmd/Ctrl + S) it will produce both a PNG and SVG file.

This uses canvas2svg which is not a perfect solution, as the Canvas2D API was never designed to be translated to SVG. Its best to stick with simple shape and path operations.

Full instructions: first install the canvas-sketch CLI if you haven't already:

npm install canvas-sketch-cli -g
@rsms
rsms / event.ts
Last active January 29, 2020 14:09
type EventHandler<T=any> = (data :T)=>void
export class EventEmitter<EventMap = {[k:string]:any}> {
_events = new Map<keyof EventMap,Set<EventHandler>>()
addListener<K extends keyof EventMap>(e :K, handler :EventHandler<EventMap[K]>) {
let s = this._events.get(e)
if (s) {
s.add(handler)
} else {
@joshuacerbito
joshuacerbito / useScroll.js
Last active January 8, 2024 13:44
Custom React hook for listening to scroll events
/**
* useScroll React custom hook
* Usage:
* const { scrollX, scrollY, scrollDirection } = useScroll();
*/
import { useState, useEffect } from "react";
export function useScroll() {
const [lastScrollTop, setLastScrollTop] = useState(0);
@ibrahima
ibrahima / CodeBlock.jsx
Last active December 3, 2020 10:23
Syntax highlighting for react-markdown
import React from 'react';
import PropTypes from 'prop-types';
import SyntaxHighlighter from 'react-syntax-highlighter';
export default class CodeBlock extends React.PureComponent {
static propTypes = {
value: PropTypes.string.isRequired,
language: PropTypes.string,
}
@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active January 21, 2024 16:28
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@sidferreira
sidferreira / RootNavigator.js
Last active February 8, 2022 13:42
React Navigation + MobX Integration (React Native Based)
// App/RootNavigator.js
import { StackNavigator } from 'react-navigation'
import AScreen from '../Containers/AScreen'
import BScreen from '../Containers/BScreen'
const RootNavigator = StackNavigator(
{
A: { screen: AScreen },
@greyscaled
greyscaled / README.md
Last active September 19, 2022 08:59
Sequelize + Express + Migrations + Seed Starter
@SylarRuby
SylarRuby / userAvatar.js
Last active November 4, 2023 13:53
NodeJs AWS S3 Upload
/**
* This gist was inspired from https://gist.github.com/homam/8646090 which I wanted to work when uploading an image from
* a base64 string.
* Updated to use Promise (bluebird)
* Web: https://mayneweb.com
*
* @param {string} base64 Data
* @return {string} Image url
*/
const imageUpload = async (base64) => {