(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| find . -name "*.js" | while read i; do js2coffee "$i" > "${i%.*}.coffee"; done |
| require 'connection_pool' | |
| class ReactRenderer | |
| mattr_accessor :pool | |
| def self.setup! | |
| size = ::Rails.configuration.react.max_renderers || 10 | |
| timeout = ::Rails.configuration.react.renderer_timeout || 20 #seconds | |
| @@pool ||= ConnectionPool.new(:size => size, :timeout => timeout) { ReactRenderer.new } |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| var xhr = new XMLHttpRequest(); | |
| xhr.open('GET', url); | |
| xhr.onload = function() { | |
| if (xhr.status === 200) { | |
| var workerSrcBlob, workerBlobURL; | |
| workerSrcBlob = new Blob([xhr.responseText], { type: 'text/javascript' }); | |
| workerBlobURL = window.URL.createObjectURL(workerSrcBlob); | |
| var worker = new Worker(workerBlobURL); |
| The MIT License (MIT) | |
| Copyright (c) 2014 Tomas Kafka | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: |
Note: if you want to skip history behind this, and just looking for final result see: rx-react-container
When I just started using RxJS with React, I was subscribing to observables in componentDidMount and disposing subscriptions at componentWillUnmount.
But, soon I realised that it is not fun to do all that subscriptions(that are just updating property in component state) manually, and written mixin for this...
Later I have rewritten it as "high order component" and added possibility to pass also obsarvers that will receive events from component.
| function getTranslate(item: HTMLElement): number | number[] | undefined { | |
| const transArr = []; | |
| if (!window.getComputedStyle) { | |
| return; | |
| } | |
| const style = window.getComputedStyle(item); | |
| const transform = style.transform || style.webkitTransform; | |
| let mat = transform.match(/^matrix3d\((.+)\)$/); | |
| if (mat) { | |
| return parseFloat(mat[1].split(', ')[13]); |
| class Identifiable<T> { | |
| Id<T> id; | |
| } | |
| class Id<T> {} | |
| class Person extends Identifiable<Person> {} | |
| class Animal extends Identifiable<Animal> {} |
| cmake_minimum_required(VERSION 3.19) | |
| project(OpenMPdemo LANGUAGES C) | |
| find_package(OpenMP COMPONENTS C REQUIRED) | |
| add_executable(hello hello_openmp.c) | |
| target_link_libraries(hello PRIVATE OpenMP::OpenMP_C) |
| @addrSpaceCast(ptr: anytype) anytype | Pointer conversion to another address space | |
|---|---|---|
| @addWithOverflow(a: anytype, b: anytype) struct { @TypeOf(a, b), u1 } | Addition with overflow detection | |
| @alignCast(ptr: anytype) anytype | Pointer alignment | |
| @alignOf(comptime T: type) comptime_int | Alignment for the current target in bytes | |
| @as(comptime T: type, expression) T | Safe type coercion | |
| @atomicLoad(comptime T: type, ptr: *const T, comptime ordering: AtomicOrder) T | Atomic dereference of pointer | |
| @atomicRmw(comptime T: type, ptr: *T, comptime op: AtomicRmwOp, operand: T, comptime ordering: AtomicOrder) T | Atomic modify and return previous value | |
| @atomicStore(comptime T: type, ptr: *T, value: T, comptime ordering: AtomicOrder) void | Atomic store of value at address | |
| @bitCast(value: anytype) anytype | Type cast at compile time | |
| @bitOffsetOf(comptime T: type, comptime field_name: []const u8) comptime_int | Bit offset of field within struct |