Skip to content

Instantly share code, notes, and snippets.

View denisdenes's full-sized avatar
🌴
On vacation

Denis Denes denisdenes

🌴
On vacation
View GitHub Profile
@ramirezsandin
ramirezsandin / useRouterParams.ts
Last active October 23, 2023 07:58
React hook to be used with Next.js, it uses useRouter internally and offers some helper functions to manipulate the url query params.
import { useRouter } from "next/router";
import { ParsedUrlQuery } from "querystring";
interface UseRouterParamsOptions {
method?: "push" | "replace";
shallow?: boolean;
}
const useRouterParams = (options?: UseRouterParamsOptions) => {
const { query, pathname, push, replace } = useRouter();
@didoo
didoo / styleguide-frame.css
Last active February 26, 2020 10:20
styleguide-frame.css
.styleguide-frame {
position: relative;
transform: translate3d(0, 0, 0); /* <-- THIS LINE MAKES THE TRICK! */
outline: 1px solid #eaeaea;
}
@IgorMing
IgorMing / barcodescanner.js
Last active April 13, 2023 19:52
Barcode Scanner on React Native (with expo), stylized with opaque edges
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { BarCodeScanner } from 'expo';
export default class App extends React.Component {
render() {
return (
<BarCodeScanner
onBarCodeRead={(scan) => alert(scan.data)}
style={[StyleSheet.absoluteFill, styles.container]}
@javilobo8
javilobo8 / download-file.js
Last active April 9, 2024 12:01
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);