Skip to content

Instantly share code, notes, and snippets.

View DimitryDushkin's full-sized avatar
😀
RxJS!

Dimitry DimitryDushkin

😀
RxJS!
View GitHub Profile
@DimitryDushkin
DimitryDushkin / new_gist_file
Created May 7, 2013 12:01
Erlang get current time in milliseconds
-spec get_timestamp() -> integer().
get_timestamp() ->
{Mega, Sec, Micro} = os:timestamp(),
(Mega*1000000 + Sec)*1000 + round(Micro/1000).
{
"metadata": {
"name": "agadganov"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "data analysis"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "data analysis"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
$('body').append('<div id="log" style="position: fixed; color: red; left:0;top:0;right:0; z-index: 100000"></div>');
window.consoleLog = function(text) {
$('#log').append('<p>' + text + '</p>');
};
@DimitryDushkin
DimitryDushkin / delayedResponse.js
Created February 16, 2016 08:29
node.js delayed web-server response example
var http = require('http');
var s = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello\n');
setTimeout(function() {
res.end(' World\n');
}, 5000);
});
@DimitryDushkin
DimitryDushkin / resposive-typography-basics.styl
Last active June 7, 2016 09:07
Example of basic mixins for Stylus to make typography on site responsive
$default-font-size = 16px
mobile()
@media (max-width: 800px)
{block}
small-mobile()
@media (max-width: 450px)
{block}
@DimitryDushkin
DimitryDushkin / react-shadow-dom-fix.js
Last active December 23, 2020 07:48
React v15 Shadow Dom events fix. Based on http://stackoverflow.com/a/37891448/297939. Unnecessery events removed and fix for multiple dispatches added.
export default function retargetEvents(el) {
// Here include necessary events' name to track
['onClick', 'onChange'].forEach(eventType => {
const transformedEventType = eventType.replace(/^on/, '').toLowerCase();
el.addEventListener(transformedEventType, event => {
for (let i in event.path) {
const item = event.path[i],
internalComponent = findReactInternal(item);
@DimitryDushkin
DimitryDushkin / get_random_array_elements_limit.js
Created September 22, 2016 12:54
Get random array elements from array with limit
function getRandomArrayElements(arr, count) {
var sliceStart = getRandomInt(0, arr.length - count),
randomSlice = arr.slice(sliceStart, sliceStart + count);
return shuffleArray(randomSlice);
}
/**
* Returns a random integer between min (inclusive) and max (inclusive)
* Using Math.round() will give you a non-uniform distribution!
*/
import React, { Component, PropTypes} from 'react';
import ReactInfinite from 'react-infinite';
// @copy-paste https://github.com/Radivarig/react-infinite-any-height
// refactored and optimized
/**
* How it works: long story short it adds elements' height on rendering in react-infinite
*/
class InfiniteAnyHeight extends Component {