Skip to content

Instantly share code, notes, and snippets.

View wmira's full-sized avatar

Warren Mira wmira

View GitHub Profile
@wmira
wmira / kotlinjsnotes.md
Last active May 17, 2020 17:06
KotlinJS Notes

Trying to get my feet wet with kotlinjs. Here are a few things that are not so obvious that could help you.

  1. Make sure you use the Gradle > Kotlin Javascript. This has all the tools you need for auto reload/compile etc.
  2. When you run the project from Intellij, add the --continuous arguments from within IntelliJ Run. This ensures that when you do any changes, your project gets recompiled and reloaded automatically on your browser.
  3. Edit src/resources/index.html. The <script> tag has the bundled js code is under the head element. This will cause issue because your javascript will get executed before the whole document is rendered. Place before the end of the body closing tag.

Ref:

@wmira
wmira / Json.kt
Created December 22, 2018 03:22
Kotlin SpringBoot Json
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class Json {
@wmira
wmira / react_fiber.md
Created February 9, 2017 12:48 — forked from geoffreydhuyvetters/react_fiber.md
What is React Fiber? And how can I try it out today?
//code can be null/undefined so lets fix it
export const formatOrderCode = ( code ) => {
if ( code !== null && code !== undefined ) {
return code.toUpperCase();
}
return null;
}
@wmira
wmira / gist:bcbdeed32329ee29fd7d
Last active February 8, 2016 07:39
Exception Handler
export const toStackOverflowOnError = function(f) {
  return function() {
      try {
          f(...Array.from(arguments));
      } catch ( e ) {
          window.location.href = 'http://stackoverflow.com/search?q=[js]+e.message';
      }
 
/* jshint esnext:true, -W097, maxstatements:15, maxdepth:2, maxcomplexity:5 */
@wmira
wmira / gist:8e62f772a9d6f0efe9f1
Created May 23, 2015 03:59
webpack external react
externals: {
react: {
root: 'React',
commonjs: 'react',
commonjs2: 'react',
amd: 'react'
}
}
@wmira
wmira / 0. intro.md
Last active August 29, 2015 14:19 — forked from jquense/0. intro.md

The 0.13.0 improvements to React Components are often framed as "es6 classes" but being able to use the new class syntax isn't really the big change. The real thing of note is that in 0.13 React Components are no longer special objects, that need to be created using a specific method (createClass()). One of the benefits of this change is that you can use the es6 class syntax, but also tons of other patterns work as well!

Below are a few examples creating React components that all work as expected using a bunch of JS object creation patterns (https://github.com/getify/You-Dont-Know-JS/blob/master/this%20&amp;%20object%20prototypes/ch4.md#mixins). All of the examples are of stateful components, and so need to delegate to React.Component for setState(), but if you have stateless components each patterns tends to get even simpler. The one major caveat with react components is that you need to assign props and context to the component instance otherwise the component will be static. The reason is

@wmira
wmira / postsql.sql
Last active August 29, 2015 14:16 — forked from tobyhede/postsql.sql
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--

Deprecating transferPropsTo

It's a common pattern in React to wrap a component in an abstraction. The outer component exposes a simple property to do something that might have more complex implementation details.

We used to have a helper function called transferPropsTo. We no longer support this method. Instead you're expected to use a generic object helper to merge props.

render() {
 return Component(Object.assign({}, this.props, { more: 'values' }));