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 / ScreenWithTabs.tsx
Created January 19, 2019 17:40
Defer render of main content after decoration
import { observable } from 'mobx'
import { observer } from 'mobx-react/native'
import React from 'react'
import { LayoutRectangle, StyleSheet, View } from 'react-native'
interface IProps {
headerTitle?: string
tabActive: 'tab1'|'tab2'|'tab3'
}
@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 / MainScreen.tsx
Created December 16, 2018 18:27
Defer content of screen until screen will be shown.
const s = StyleSheet.create({
content: {
flex: 1,
},
screen: {
backgroundColor: theme.bgColor2,
},
})
@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 = {},
// tslint:disable:max-classes-per-file
import { Client, FileImageResponse, Node } from 'figma-js'
import * as fs from 'fs'
import * as https from 'https'
import * as mkdirp from 'mkdirp'
import * as path from 'path'
import * as request from 'request'
const TOKEN = 'xxxx-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
@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,
import React from 'react'
import { Keyboard, LayoutAnimation, View } from 'react-native'
class KeyboardSpacer extends React.Component {
constructor (props, ctx) {
super(props, ctx)
this.subscriptions = []
this.state = {
height: 0,
}
Sampling process 25086 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling ruby (pid 25086) every 1 millisecond
Process: ruby [25086]
Path: /usr/local/Cellar/ruby/2.4.3_1/bin/ruby
Load Address: 0x10646e000
Identifier: ruby
Version: 0
Code Type: X86-64
Parent Process: zsh [15045]
@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 / storable-leaks.pl
Created July 5, 2013 11:23
leaks: 5.16 no leaks: 5.14
#!perl
{
package Test;
sub new { bless pop||{}, shift; }
sub STORABLE_freeze {
my ($self) = @_;
delete $self->{a};