Skip to content

Instantly share code, notes, and snippets.

View alersenkevich's full-sized avatar
🤔
hard working

01001010011011110100101001101111 alersenkevich

🤔
hard working
  • Yekaterinburg, Russian Federation
View GitHub Profile
@reatexpk
reatexpk / .eslintrc
Last active June 5, 2019 13:45
Typescript eslint config (airbnb)
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"extends": [
"airbnb",
"prettier",
mod sort_fn {
pub fn bubble_sort<T: Ord>(victim: &mut [T]) {
for _ in 0..victim.len() {
for j in 1..victim.len() {
if victim[j - 1] > victim[j] {
victim.swap(j - 1, j);
}
}
}
}
const data = [4, 3, 5, 0, 1, 10, 8, 2, 9]
function insertedSort(data) {
for (let i = 0; i < data.length; i++) {
for (let j = i; j > 0 && data[j] < data[j - 1]; j--) {
[data[j], data[j - 1]] = [data[j - 1], data[j]]
}
}
return data
}
import React from 'react'
import {
View,
TouchableOpacity,
Text,
StyleSheet,
ActivityIndicator,
} from 'react-native'
import LinearGradient from 'react-native-linear-gradient'
import PropTypes from 'prop-types'
const { resolve } = require('path');
const {
LoaderOptionsPlugin,
EnvironmentPlugin,
HotModuleReplacementPlugin,
} = require('webpack');
const merge = require('webpack-merge');
const { config, loadersConfig, DIST } = require('./shared');
@dmitryshelomanov
dmitryshelomanov / .js
Created December 11, 2017 08:19
curry
const getValue = (form, fieldName) => form[fieldName]
const form = {
firstName: 'dima',
lastName: 'shelomanov'
}
const curry = (fn, ...args) =>
(...currentArgs) => {
const allArgs = [...args, ...currentArgs]
const compose = (...funcs) =>
funcs.reduce((a, b) => (...args) => a(b(...args)), arg => arg)
@Shalomeev
Shalomeev / expressSequelize.md
Last active July 3, 2018 12:20
Helps to use sequelize and postgresql in express-js.

db/config.js

module.exports = {
    username: 'postgres',
    password: 'password',
    database: 'diary',
    dialect: 'postgres',
    protocol: 'postgres',
    port: 5432,
    host: '127.0.0.1'
@markerikson
markerikson / connectExample.js
Last active March 5, 2024 01:24
React-Redux connect example
import {action1, action2} from "myActions";
import {bindActionCreators} from "redux";
import {connect} from "react-redux";
const mapStateToProps = (state, ownProps) = {
return {
counter : state.counter,
someComponentValue : state.things[ownProps.someIdProp]
};
}
@alloyking
alloyking / font-exist.js
Created November 27, 2012 14:27
Check if font exists
//
// Call this function and pass in the name of the font you want to check for availability.
//
function doesFontExist(fontName) {
// creating our in-memory Canvas element where the magic happens
var canvas = document.createElement("canvas");
var context = canvas.getContext("2d");
// the text whose final pixel size I want to measure
var text = "abcdefghijklmnopqrstuvwxyz0123456789";