Skip to content

Instantly share code, notes, and snippets.

View alexesDev's full-sized avatar

Alexey Yurchenko alexesDev

  • Digital Nomad
View GitHub Profile
@alexesDev
alexesDev / benchmark.html
Last active July 11, 2017 17:23
styled-components (300ms) vs plain className (100ms)
<style type="text/css">
.block {
border: 1px solid red;
min-height: 1px;
}
</style>
<div id="mount"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js"></script>
@alexesDev
alexesDev / api.js
Last active April 19, 2017 10:32
Redux api utils example
import { makeActionCreator, makeMergeReducer } from './helpers';
import 'whatwg-fetch';
const endpoint = process.env.ENDPOINT;
const makeAction = makeActionCreator(endpoint, fetch);
export default {
actions: {
// make action for redux-thunk
clusters: makeAction('clusters', 'clusters/'),
import React from 'react';
const Count = ({ value, ...props }) => {
if (value === 0) {
return <noscript />;
} else {
return <span {...props}>({value})</span>;
}
};
setxkbmap -layout dvp,ru
setxkbmap -option grp:caps_toggle
xrdb ~/.Xresources
sudo netctl start wlp5s1-FRESH_OFFICE &
chromium &
telegram-desktop &
@alexesDev
alexesDev / actionable.js
Created February 13, 2017 12:52
Call an item event handler with the item data without bind or lambda functions...
import React, { PropTypes } from 'react';
const Actionable = React.createClass({
propTypes: {
component: PropTypes.any.isRequired,
eventName: PropTypes.string.isRequired,
handler: PropTypes.func.isRequired,
},
handle() {
@alexesDev
alexesDev / example.js
Last active February 7, 2017 07:57
LocationSubscriber for react-router v4 (use withRouter instead this code)
function render(location, props) {
return <span>{location.pathname}</span>;
}
const ShowPathname = (props) => (
<LocationSubscriber {...props} render={render} />
);
@alexesDev
alexesDev / shake.c
Created February 3, 2017 19:58
arduino shake
#include "LedControl.h"
#define FIELD_SIZE 8
#define MAX_LENGTH 16
LedControl lc(12, 10, 11, 1);
typedef struct {
byte x, y;
} Position;
@alexesDev
alexesDev / gist:33d4bceb0d2669e8a963ca66d1afbc93
Created January 27, 2017 10:38 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
javascript:!function(b){var c=[].map.call(document.querySelectorAll("tbody.order-item-wraper"),function(a){var b=a.querySelector(".first-row .info-body").innerHTML.trim(),c=a.querySelector(".baobei-name").innerHTML.trim(),d=a.querySelector(".order-status .f-left").innerHTML.trim(),e=parseFloat(a.querySelector(".amount-num").innerHTML.match(/[0-9,]+/)[0]);return[b,'"'+c+'"',e,d].join(",")});data=localStorage.getItem(b)||"",data+=c.join("\n")+"\n",localStorage.setItem(b,data),document.querySelector(".ui-pagination-next").click()}("aliData");
require 'pg'
stock_conn = PG.connect(dbname: ARGV[0] || 'inventoring_development')
entrepot_conn = PG.connect(dbname: ARGV[1] || 'organic_development')
stock_conn.exec('select id, name, ignore_in_reports from reasons').each do |c|
entrepot_conn.exec_params('insert into write_off.reasons (id, name, ignore_in_reports) values ($1, $2, $3)', c.values)
end
stock_conn.exec('select id, name, description, COALESCE(status, 0) from vendors').each do |c|