Skip to content

Instantly share code, notes, and snippets.

View vovkasm's full-sized avatar

Vladimir Timofeev vovkasm

  • Self employed
  • Budva, Montenegro
View GitHub Profile
@vovkasm
vovkasm / setup.js
Created January 10, 2019 10:06
Jest + react-native mock native modules
// Tune promises (we use Bluebird, but with setImmediate instead of nextTick etc optimizations...)
// It will allow to us call jest.runAllImmediates() to force promises queue flush
global.Promise = require('App/promise').default
global.Promise.setScheduler(function(fn) {
setImmediate(fn)
})
jest.mock('NativeEventEmitter')
const NativeModules = {
@vovkasm
vovkasm / SnapshotHelper.h
Last active June 30, 2021 06:55
Objective C implementation of SnapshotHelper class for Fastline Snapshot tool (https://github.com/fastlane/fastlane/tree/master/snapshot).
/* This SnapshotHelper class should be compatible with SnapshotHelper.swift version 1.2 */
@import Foundation;
@import XCTest;
@interface SnapshotHelper : NSObject
- (instancetype)initWithApp:(XCUIApplication*)app;
- (void)snapshot:(NSString*)name waitForLoadingIndicator:(BOOL)wait;
@vovkasm
vovkasm / KeyboardAvoidingView.tsx
Created November 30, 2018 05:47
Sample of custom analog of KeyboardAvoidingView in "padding" mode, that actually works.
import React from 'react'
import {
EmitterSubscription,
Keyboard,
LayoutAnimation,
LayoutChangeEvent,
LayoutRectangle,
Platform,
StyleSheet,
View,
@vovkasm
vovkasm / upload-sample.ts
Created December 6, 2018 14:57
Sample of uploading file in react-native
type Body = string | FormData | { uri: string } | ArrayBufferLike | ArrayBufferView
interface IUploadOptions {
body?: Body
headers?: { [k: string]: string }
method?: 'GET' | 'POST'
}
function upload(
url: string,
opts: IUploadOptions = {},
@vovkasm
vovkasm / README.md
Last active November 6, 2019 11:34
Android build with additional dimensions (snippets)

Directory structure

dir structure

@vovkasm
vovkasm / sample.jsx
Created September 3, 2019 13:56
Poor RN text overflow behavior :-(
funciton MyComp() {
return (
<View style={{ flexDirection: 'row', borderColor: 'blue', borderWidth: StyleSheet.hairlineWidth }}>
<View style={{ width: 100, height: 100, backgroundColor: 'green' }} />
<Text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ultricies finibus elementum.</Text>
</View>
)
}
@vovkasm
vovkasm / out.txt
Created August 13, 2019 11:41
Properties of Mobx actions.
Increment without transaction
before incrementCounter cnt=0
after incrementCounter cnt=1
reaction computed=1
reaction cnt=1
Two increments with transaction
before incrementCounter cnt=1
after incrementCounter cnt=2
Current immediate value in transaction cnt=2
before incrementCounter cnt=2
@vovkasm
vovkasm / README.md
Created June 24, 2019 20:34
Sample minimal readme for RN project.

MyProject

Prereqs

  • java, ant
  • Xcode
  • ruby

Install deps

@vovkasm
vovkasm / Chat.spec.tsx
Created June 18, 2019 07:35
Sample test (not full, only to show code)
mport 'jest'
import { clock } from 'testing/setupFakeTimers'
import { TestController as Ctrl } from 'testing/testController'
import React from 'react'
import Renderer, { act } from 'react-test-renderer'
beforeEach(() => {
// simplifyed code
@vovkasm
vovkasm / app-build.gradle
Created June 18, 2019 21:04
Some gradle deps for RN 0.59.9
// android/app/build.gradle
// ... some RN stuff
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
implementation "com.android.support:cardview-v7:${rootProject.supportLibVersion}"
implementation "com.android.support:customtabs:${rootProject.supportLibVersion}"