Skip to content

Instantly share code, notes, and snippets.

View YKalashnikov's full-sized avatar
:electron:
Life is Good 🥇

Iurii Kalashnikov YKalashnikov

:electron:
Life is Good 🥇
View GitHub Profile
@YKalashnikov
YKalashnikov / Ruby
Last active April 5, 2017 00:07
# Write a method that converts an array of ten integers into a phone number in the format "(123) 456-7890".
WHAT'S WRONG WITH THE CODE?
# Write a method that converts an array of ten integers into a phone number in the format "(123) 456-7890".
def to_phone_number(arr)
chunk_one = arr[0..2].join
chunk_two = arr[3..5].join
chunk_three = arr[6..9].join
"(" + chunk_one + ")" + " " + chunk_two + "-" + chunk_three
end
function booWho(bool) {
// the fastet way to solve this problem
return typeof bool==="boolean";
}
booWho(null);
/* another way to solve it
@YKalashnikov
YKalashnikov / gist:6a2d2c13fd49a21ecec591b06a7d61ff
Created January 27, 2018 20:16
REACT...I am having a problem to convert time ("YYYY-MM-DD HH:mm:ss")..I would appreciate any help
https://codepen.io/AK-47/pen/goVORq
@YKalashnikov
YKalashnikov / gist:d87abfd5989006ac57531c363b3fea33
Created February 8, 2018 02:47
Having problem with a state
class Box extends React.Component{
constructor(props){
super(props)
var c = []
for(var i=0; i<100; i++){
c.push( <Cell key={i} id={i} cells={c} /> )
}
this.state={cells:c}
[
{"_id":1,"title":"Unlocking Android","isbn":"1933988673","publishedDate":{"$date":"2009-04-01T00:00:00.000-0700"},"shortDescription":"Unlocking Android: A Developer's Guide provides concise, hands-on instruction for the Android operating system and development tools. This book teaches important architectural concepts in a straightforward writing style and builds on this with practical and useful examples throughout.","longDescription":"Android is an open source mobile phone platform based on the Linux operating system and developed by the Open Handset Alliance, a consortium of over 30 hardware, software and telecom companies that focus on open standards for mobile devices. Led by search giant, Google, Android is designed to deliver a better and more open and cost effective mobile experience. Unlocking Android: A Developer's Guide provides concise, hands-on instruction for the Android operating system and development tools. This book teaches important architectural concepts in a straightforward writing st
import React, {Component} from 'react';
class App extends Component {
render() {
return (
<h1>Redux Form</h1>
)
}
}
export default App;
import React, {Component} from 'react';
import {Field, reduxForm} from 'redux-form';
class LoginForm extends Component {
render () {
const {handleSubmit} = this.props;
return (
<form onSubmit={handleSubmit}>
<Field
mport React, {Component, Fragment} from 'react';
import LoginForm from '../components/LoginForm';
class App extends Component {
submit = values => {
window.alert (JSON.stringify (values));
};
render () {
import React from 'react';
export const myInput = props => {
return (
<input {...props.input} type={props.type} placeholder={props.placeholder} />
);
};
export const validate = inputs => {
const errors = {};
if (!inputs.username) {
errors.username = 'Введите имя пользователя';
} else if (inputs.username !== 'Юрчик') {
errors.username = 'Имя пользователя неверно';
}
if (!inputs.password) {
errors.password = 'Введите ваш пароль';
}