Skip to content

Instantly share code, notes, and snippets.

View ozcanzaferayan's full-sized avatar
⚛️
Overreacting

Özcan Zafer AYAN ozcanzaferayan

⚛️
Overreacting
View GitHub Profile
@ozcanzaferayan
ozcanzaferayan / App.jsx
Last active March 6, 2020 07:30
Simple Dialog for React Native and React Native Web
import React, { useState } from "react";
import { View, StyleSheet, Button, Text, TouchableOpacity } from "react-native";
export const App = () => {
const [isShowing, setShowing] = useState(false);
const toggleDialog = () => {
setShowing(!isShowing);
}
@ozcanzaferayan
ozcanzaferayan / App.tsx
Last active March 3, 2020 09:01
React Native Donut Chart with labels using react-native-svg
import React from 'react';
import { View } from 'react-native';
export const App: React.FC = () => {
return (
<View style={{flexDirection: 'row', justifyContent:'center'}}>
<DonutChart radius={15} percentage={25} width={100}/>
<DonutChart radius={15} percentage={65} width={100}/>
<DonutChart radius={15} percentage={70} width={100}/>
</View>
@ozcanzaferayan
ozcanzaferayan / App.tsx
Last active January 26, 2024 13:39
React Native Donut Chart with react-native-svg
import React from 'react';
import { View } from 'react-native';
export const App: React.FC = () => {
return (
<View style={{flexDirection: 'row', justifyContent:'center'}}>
<DonutChart radius={15} percentage={25} width={100}/>
<DonutChart radius={15} percentage={65} width={100}/>
<DonutChart radius={15} percentage={70} width={100}/>
@ozcanzaferayan
ozcanzaferayan / color_palette_generator.html
Last active March 4, 2020 18:03
Creates color palette from existing color array in JavaScript and HTML. You can get website colors from http://colorhound.net/ by entering css or js text.
<!DOCTYPE html>
<html>
<body>
<script>
function hexToHSV(hex) {
hex = hex.replace(/^#/, '');
hex = hex.length === 3 ? hex.replace(/(.)/g, '$1$1') : hex;
var red = parseInt(hex.substr(0, 2), 16) / 255,
@ozcanzaferayan
ozcanzaferayan / GruntFile.js
Last active February 21, 2020 13:56
How to watch and sync current module to node_modules in Grunt?
module.exports = function(grunt) {
grunt.initConfig({
sync: {
main: {
files: [{
cwd: '.',
src: [
'./*.json',
'./*.js',
'./*.tsx',
@ozcanzaferayan
ozcanzaferayan / rn.bash
Last active February 22, 2020 18:37
React Native Web Monorepo Projesi Oluşturma ve Yapılandırma
# brew install gnu-sed
PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
mkdir monorepo && cd monorepo
create-react-app web --typescript && cd web
yarn add react-native-web
yarn add -D @types/react-native
cd src && rm logo.svg index.css App.css App.test.tsx && cd ..
printf 'import { AppRegistry } from "react-native";\nimport App from "./App";\nAppRegistry.registerComponent("App", () => App);\nAppRegistry.runApplication("App", {\n initialProps: {},\n rootTag: document.getElementById("root")\n});\n' > src/index.tsx
printf 'import * as React from "react";\nimport { Text } from "react-native";\nconst App: React.FC = () => {\n return <Text>Merhaba Dünya</Text>;\n};\nexport default App;\n' > src/App.tsx
cd .. && npx react-native init mobile --template [email protected] && cd mobile
maxId=0
tempUrl=""
for i in {1..100}
do
tempUrl="/1.1/search/tweets.json?tweet_mode=extended&max_id=$maxId&count=100&q=🏫 ⏳ 🏷 🌎 💸"
maxId=$(sudo twurl --bearer $tempUrl | jq '[.statuses[]| {id: .id,text:.full_text,created_at:.created_at,url:.entities.urls[].url,name:.user.name,screen_name:.user.screen_name}]' > "text$i.json" | jq 'min_by(.id).id')
maxId=$(($maxId - 1))
echo $maxId
done
@ozcanzaferayan
ozcanzaferayan / README.MD
Last active August 30, 2024 20:09
React Native SVGR Usage

SVG file (./src/images/ic_youtube.svg):

<?xml version="1.0" ?>
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
  <path d="M21.582,6.186c-0.23,-0.86 -0.908,-1.538 -1.768,-1.768C18.254,4 12,4 12,4S5.746,4 4.186,4.418c-0.86,0.23 -1.538,0.908 -1.768,1.768C2,7.746 2,12 2,12s0,4.254 0.418,5.814c0.23,0.86 0.908,1.538 1.768,1.768C5.746,20 12,20 12,20s6.254,0 7.814,-0.418c0.861,-0.23 1.538,-0.908 1.768,-1.768C22,16.254 22,12 22,12S22,7.746 21.582,6.186zM10,15.464V8.536L16,12L10,15.464z" fill="#000000FF"/>
</svg>

CLI usage:

svgr ./src/images -d ./src/svg --native --icon --svg-props "width=24,height=24"
jsi::Value JSCRuntime::evaluateJavaScript(
const std::shared_ptr<const jsi::Buffer> &buffer,
const std::string &sourceURL) {
std::string tmp(
reinterpret_cast<const char *>(buffer->data()), buffer->size());
JSStringRef sourceRef = JSStringCreateWithUTF8CString(tmp.c_str());
JSStringRef sourceURLRef = nullptr;
if (!sourceURL.empty()) {
sourceURLRef = JSStringCreateWithUTF8CString(sourceURL.c_str());
}
@implementation RCTJavaScriptLoader
RCT_NOT_IMPLEMENTED(- (instancetype)init)
+ (void)loadBundleAtURL:(NSURL *)scriptURL onProgress:(RCTSourceLoadProgressBlock)onProgress onComplete:(RCTSourceLoadBlock)onComplete
{
int64_t sourceLength;
NSError *error;
NSData *data = [self attemptSynchronousLoadOfBundleAtURL:scriptURL
runtimeBCVersion:JSNoBytecodeFileFormatVersion