Skip to content

Instantly share code, notes, and snippets.

View ridvanaltun's full-sized avatar
🐴
prostagma?

Rıdvan Altun ridvanaltun

🐴
prostagma?
View GitHub Profile
@ridvanaltun
ridvanaltun / README.md
Last active October 26, 2024 21:10
Auto-linking configuration for React-Native 0.75.4 IOS App Clip
@ridvanaltun
ridvanaltun / GeneratePackageListTask.diff
Last active October 26, 2024 21:11
Auto-linking configuration for React-Native 0.75.4 Android Instant App
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.tasks
import com.facebook.react.model.ModelAutolinkingConfigJson
@ridvanaltun
ridvanaltun / README.md
Created September 24, 2024 22:28
reorder json file by reference of another json file

Why

I'm using a tool that help me with translations but the tool's output not desirable, json keys are not sorted like input file.

Usage

jq -f reorder-by-reference.jq ./src/locales/en.json ./src/locales/tr.json > reordered_output.json
@ridvanaltun
ridvanaltun / README.md
Created June 2, 2024 11:15
React Query + React Navigation -> Refetch on focus

Refetch the quest on every app state and screen change after 1 minute times up:

 useRefetchOnFocus(refetch);

Refetch on every app state and screen change without wait:

 useRefetchOnFocus(refetch, 0);
@ridvanaltun
ridvanaltun / styling.ts
Last active November 23, 2023 14:44
React-Native responsive StyleSheet
import {Dimensions, PixelRatio, StyleSheet} from 'react-native';
const {width, height} = Dimensions.get('window');
const PROPERTIES_DEPENDING_ON_WIDTH = [
'width',
'marginLeft',
'marginRight',
'marginHorizontal',
'paddingLeft',
@ridvanaltun
ridvanaltun / README.md
Created August 24, 2022 14:04
Shrink PDF

Usage

shrinkpdf.sh in.pdf out.pdf
@ridvanaltun
ridvanaltun / responsive.ts
Created August 24, 2022 00:53
React-Native responsive design utils
import {widthPercentageToDP, heightPercentageToDP} from 'react-native-responsive-screen';
const REFERENCE_WIDTH = 428;
const REFERENCE_HEIGHT = 926;
export const wp = (val: number | string) => {
if (typeof val === 'number') {
return widthPercentageToDP(`${(100 * val) / REFERENCE_WIDTH}%`);
}
@ridvanaltun
ridvanaltun / obj2url.js
Created August 22, 2022 08:24
Extract URLs from objects
const obj = require("./data.json");
function getUrl(obj) {
const ary = [];
helper(obj, ary);
return ary;
}
function helper(item, ary) {
if (typeof item === "string" && isUrl(item)) {
@ridvanaltun
ridvanaltun / README.md
Last active June 25, 2023 17:14
SVGR usage on React-Native

Usage

Add below script to your package.json:

+ "icons:create": "svgr ./assets/icons  -d ./src/components/Icons --config-file svgr-config.json --template svg-template.js",
@ridvanaltun
ridvanaltun / README.md
Last active August 16, 2022 09:25
Extract png from binary file.

Use python3.

python3 bin2png <binary> <destination>

# example -> python3 bin2png testbin .