Skip to content

Instantly share code, notes, and snippets.

View andrewkslv's full-sized avatar

Andrew andrewkslv

  • World
View GitHub Profile
@andrewkslv
andrewkslv / destructuring.js
Created August 2, 2016 09:16
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring Raw copied from https://gist.github.com/mikaelbr/9900818
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () = > {
return [1, 2, 3];
@andrewkslv
andrewkslv / the-bind-problem.jsx
Created November 18, 2016 12:47 — forked from Restuta/the-bind-problem.jsx
React, removeEventListener and bind(this) gotcha
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));
@andrewkslv
andrewkslv / measure.js
Created December 5, 2016 12:39
How to find x,y position / measure height of a component in React native
import { findNodeHandle } from 'react-native';
const RCTUIManager = require('NativeModules').UIManager;
RCTUIManager.measure(findNodeHandle(this.refs.myRef), (x, y, width, height, pageX, pageY) => {
// Got me some dimensions
});
@andrewkslv
andrewkslv / Col.js
Created December 19, 2016 13:38 — forked from rosskevin/Col.js
material-ui `next` responsive layout/grid using JSS (originally based on flexboxgrid.com)
// @flow
import React, {Component, Element, PropTypes} from 'react'
import classNames from 'classnames'
import pure from 'recompose/pure'
import merge from 'lodash/merge'
import {createStyleSheet} from 'jss-theme-reactor'
import Logger from '../../util/Logger'
import {capitalizeFirstLetter} from '../../util/strings'
type DefaultProps = {
@andrewkslv
andrewkslv / .eslintrc.js
Created February 10, 2017 12:30 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@andrewkslv
andrewkslv / AppText.js
Created February 17, 2018 23:49 — forked from necolas/AppText.js
Localized typography with React Native
import i18n from '../../i18n';
import theme from '../../theme';
import { bool, string } from 'prop-types';
import { I18nManager, StyleSheet, Text } from 'react-native';
import React, { Component } from 'react';
/**
* React Component
*/
class AppText extends Component {
@andrewkslv
andrewkslv / animations.js
Created February 28, 2018 14:59
React Native animation without goes outside of the screen
import React, { Component } from 'react';
import { View, StyleSheet, Animated, Dimensions } from 'react-native';
const { width, height } = Dimensions.get('window');
const BOX_DIM = 50;
export default class App extends Component {
componentWillMount() {
this.animation = new Animated.ValueXY(0);
}
@andrewkslv
andrewkslv / server.js
Created June 21, 2018 16:23
server.js
/* eslint-disable no-param-reassign, no-console */
// Server entry point, for Webpack. This will spawn a Koa web server
// and listen for HTTP requests. Clients will get a return render of React
// or the file they have requested.
// ----------------------
// IMPORTS
/* Node */
@andrewkslv
andrewkslv / Index.html
Created March 15, 2019 09:55 — forked from meziantou/Index.html
Javascript - Record audio
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h1>Audio</h1>
@andrewkslv
andrewkslv / sources.list
Created November 17, 2020 21:05 — forked from ishad0w/sources.list
Ubuntu 20.04 LTS (Focal Fossa) -- Full sources.list
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse