Skip to content

Instantly share code, notes, and snippets.

import { createActions } from 'redux-actions';
const {
auth: {
sendCode,
sendCodeSuccess,
sendCodeError,
checkCode,
checkCodeSuccess,
checkCodeError,
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import Modal from '@material-ui/core/Modal';
import Button from '@material-ui/core/Button';
function rand() {
return Math.round(Math.random() * 20) - 10;
}
@anyley
anyley / dateTimeRangeCalc.js
Last active July 11, 2018 05:19
date time range calculator
export const writeEnums = (n, words, { zero = false, space = ' ' } = {}) => {
if (!zero && n === 0) return ''
const i10 = n % 10
const i100 = n % 100
if (i10 === 1 && i100 !== 11) {
return `${n}${space}${words[0]}`
} else if (i10 !== 0 && i100 !== 0 && i100 !== 11 && (i100 > 21 || i100 < 5) && i10 < 5) {
return `${n}${space}${words[1]}`
const TIMEOUT = 500
patterns = {
's-r': [83, 82]
}
handler = e => {
// console.log(e.which)
clearTimeout(handler.timer)
handler.keys[e.which] = true
def matrix_mult(a, b)
a.map do |ar|
ar.each_index.map do |aci|
b.each_with_index.reduce(0) do |sum, (br, bri)|
sum + ar[bri] * br[aci]
end
end
end
end
@anyley
anyley / gist:c60a408d4b50c165fa72011c7445d60e
Created March 12, 2017 23:35
Mercury baseboard (spartan 3a) counter example
`timescale 1ns / 1ns
module send_number_to_shift_reg(CLK, AN, DOT, A_TO_G);
input CLK;
output reg [3:0] AN;
output reg [6:0] A_TO_G;
output reg DOT;
parameter [31:0] REFRESH = 1024 * 256;
parameter [63:0] TIMEOUT = 4096 * 1024;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.1.2/mocha.css">
</head>
<body>
export const loadState = (storage) => {
try {
const serializedState = localStorage.getItem(storage)
if (serializedState === null)
return undefined
return JSON.parse(serializedState)
} catch (error) {
return undefined
}
}
@anyley
anyley / replace_element.js.erb
Created October 10, 2016 00:32
В ответ на xhr-запрос, заменяет контент элемента по селектору и устанавливает url в браузере
$('<%= selector %>').replaceWith("<%= j content %>");
<% unless location.nil? %>
window.history.pushState(null, null, '<%= location %>');
console.log('<%= location %>');
<% end %>
# Если используется turbolink, запускаем скрипт после каждого обновления страницы
$(document).on 'turbolinks:load', ->
class Draggable
constructor: ->
@drag_element = null
@source_element = null
# Добавляем курсор с рукой для всех элементов с тэгом drag
# .grag { cursor: -webkit-grab }
$('[drag]').addClass('grab')