Skip to content

Instantly share code, notes, and snippets.

View thekarel's full-sized avatar

Charles Szilagyi thekarel

View GitHub Profile
@thekarel
thekarel / caseInsensitiveFilter.ts
Created July 15, 2021 16:25
antd Cascader case-insensitive search
import {CascaderOptionType, FilledFieldNamesType} from 'antd/lib/cascader'
export const caseInsensitiveFilter = (inputValue: string, path: CascaderOptionType[], names: FilledFieldNamesType) =>
path.some((option) => option[names.label].toLowerCase().includes(inputValue.toLowerCase()))
@thekarel
thekarel / validate_and_squash_this_branch.sh
Created August 31, 2020 08:27
Validate and squash this branch
validate_and_squash_this_branch () {
BRANCH=`git branch --show-current`
yarn validate && \
git checkout master && \
git merge --squash $BRANCH && \
git commit -v -a
}
@thekarel
thekarel / native-mobile-share.js
Created May 3, 2020 10:47
Native mobile share experience on mobile browsers
// Share Url
shareUrl = function() {
if (!navigator.share) return;
navigator.share({
url: "https://mywebsite.com",
title: "Sharing Cool things",
text: "Checkout my really cool website."
})
.then(() => { console.log("Shared YEEEE!!!!!"); })
@thekarel
thekarel / fetchOnceAndSaveToDiskWithBuffer.js
Created March 2, 2020 12:48
fetchOnceAndSaveToDiskWithBuffer
async function fetchOnceAndSaveToDiskWithBuffer(url, filename) {
return new Promise(resolve => {
if (fs.existsSync(filename)) {
resolve(readFile(filename));
return;
}
const file = fs.createWriteStream(filename);
@thekarel
thekarel / cropUnsplashImage.js
Last active March 5, 2020 15:12
Crop image on Unsplash bookmarklet. Popups need to be enabled for the site.
javascript:fetch(`https://unsplash.com/photos/${document.location.href.split('/').pop()}/download`).then(({url}) => window.open(`${url.split('?')[0]}?w=2048&h=1024&fit=crop`))
@thekarel
thekarel / README.md
Created February 14, 2020 07:04
Firebase Functions in Monorepo

The firebase.json should be in the root of the workspace and it only shows the relevant bits.

Put the webpack config into modules/firebase/

Before deploying the functions, build the function bundle with webpack (it will end up in dist/).

@thekarel
thekarel / graphql.ts
Created January 23, 2020 23:32
Apollo Server on Firebase Functions
import * as functions from 'firebase-functions'
import {ApolloServer, gql} from 'apollo-server-cloud-functions'
const typeDefs = gql`
type Query {
hello: String
}
`
const resolvers = {
@thekarel
thekarel / reindex.sh
Created September 8, 2019 21:01
Reindex media on Synology NAS
synoindex -R {all|photo|music|video|thumb}
@thekarel
thekarel / launch.json
Created September 7, 2019 17:43
Debug Cucumber tests
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Cucumber",
"program": "${workspaceRoot}/node_modules/.bin/cucumber-js",
"args": [],
"internalConsoleOptions": "openOnSessionStart",