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 / 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 .
@ridvanaltun
ridvanaltun / README.md
Last active November 2, 2021 23:08
Bugsnag React-Native bundle uploader

manual

# use for production
node bugsnag.upload.js

# use for development
node bugsnag.upload.js --dev
@ridvanaltun
ridvanaltun / README.md
Created September 28, 2021 07:24
Commitlint limit scopes per type via scope-enum
@ridvanaltun
ridvanaltun / esm-package.md
Created September 25, 2021 10:58 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@ridvanaltun
ridvanaltun / README.md
Created September 9, 2021 08:09
Metasyntactic Variables