Skip to content

Instantly share code, notes, and snippets.

Avatar

Tomasz Czajęcki tchayen

View GitHub Profile
View Cards.js
import React from 'react';
import {View, Dimensions} from 'react-native';
import Animated, {
useAnimatedScrollHandler,
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated';
const BORDER_RADIUS = 10;
@tchayen
tchayen / script-calculator.js
Last active Sep 10, 2021
Javascript calculator using Reverse Polish notation and Shunting-yard algorithm
View script-calculator.js
// function connecting algorithm with outer world
function updateCalculator(event) {
var expression = document.getElementById("calculator").value;
var result = calculate(expression);
document.getElementById('calculatorResult').innerHTML = result;
}
function calculate(expression) {
View main.js
/**
* Usage:
* 1. Paste this into a main.js file in some empty directory.
* 2. Run: `yarn add web3 ethers abi-decoder`.
* 3. Go to contract's page
* https://etherscan.io/address/0x25ed58c027921E14D86380eA2646E3a1B5C55A8b
* and then to code and then copy "Contract ABI" and save it in the same dir
* as abi.json.
* 4. Create empty file backup.txt.
* 5. Download CSV data with transactions from etherscan page and save as
View barycentric.js
const vertex = `
attribute vec2 a_position;
attribute vec3 a_barycentric;
uniform mat3 u_matrix;
varying vec3 vbc;
void main() {
vbc = a_barycentric;
gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1);
}`
View reg.js
const fetch = require("node-fetch");
const SERVICE_ID = "e5e795f2-7f35-4b11-ba7d-d1c45cbec182";
const YEAR = 2020;
const getWeekNumber = (date) => {
const firstDayOfYear = new Date(date.getFullYear(), 0, 1);
const pastDaysOfYear = (date - firstDayOfYear) / 86400000;
return Math.ceil((pastDaysOfYear + firstDayOfYear.getDay() + 1) / 7);
};
View Dismiss3.js
import React, {useState} from 'react';
import Animated, {
useAnimatedScrollHandler,
useSharedValue,
useAnimatedStyle,
withTiming,
} from 'react-native-reanimated';
import {Image, Pressable, Dimensions} from 'react-native';
import FastImage from 'react-native-fast-image';
View Instagram.js
import React from 'react';
import {ScrollView, View, Text, Dimensions} from 'react-native';
import Animated, {
useAnimatedGestureHandler,
useSharedValue,
useAnimatedStyle,
withTiming,
} from 'react-native-reanimated';
import {PinchGestureHandler} from 'react-native-gesture-handler';
View Bedtime.js
import React from 'react';
import {Dimensions, PixelRatio, StyleSheet, Text, View} from 'react-native';
import Animated, {
useSharedValue,
useAnimatedGestureHandler,
useAnimatedStyle,
useAnimatedProps,
useDerivedValue,
} from 'react-native-reanimated';
import {PanGestureHandler, TextInput} from 'react-native-gesture-handler';
View Snackbar.tsx
import React, { Component, createContext, useState } from "react";
import {
Animated,
TouchableOpacity,
View,
Text,
StyleSheet,
Platform
} from "react-native";
import { borderRadius, colors } from "./consts";
View machine.js
const machine = Machine({
id: "authentication",
initial: "signIn",
context: {
name: "",
email: "",
password: "",
errors: {}
},
states: {