Skip to content

Instantly share code, notes, and snippets.

View vovkasm's full-sized avatar

Vladimir Timofeev vovkasm

  • Employed
  • Budva, Montenegro
View GitHub Profile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'Sample' do
project 'Sample', {
'Debug' => :debug,
'Staging' => :release,
'Production' => :release,
}
@vovkasm
vovkasm / KeyboardDismisser.tsx
Last active March 29, 2019 22:31
How to hide keyboard by click outside text field withotu ScrollView
// tslint:disable:object-literal-sort-keys
import React from 'react'
import { GestureResponderEvent, LayoutRectangle, NativeTouchEvent, UIManager } from 'react-native'
// HACK
import { blurTextInput, currentlyFocusedField, isTextInput } from 'App/lib/extendedTextState'
/**
* Touchable states.
@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]