Skip to content

Instantly share code, notes, and snippets.

View chrisgervang's full-sized avatar

Chris Gervang chrisgervang

View GitHub Profile
@chrisgervang
chrisgervang / ComponentSynthetic.tsx
Last active January 7, 2024 03:59
Understanding Typescript: "allowSyntheticDefaultImports": true
// React doesn't use es2015 "export default react" syntax in their NPM dist.
// Instead they set a "default" key in their export object.
/** node_modules/react/cjs/react.development.js
...
var React$2 = Object.freeze({
default: React
});
// using babel-node to run.
var Ast = require("ts-simple-ast");
const a = new Ast.default();
a.addSourceFiles("../src/**/*.tsx");
const sourceFiles = a.getSourceFiles();
// Filter down to files that import react
@chrisgervang
chrisgervang / helpers.ts
Last active May 27, 2017 00:47
Redux Thunk Helpers
import * as Redux from 'redux'
import { ThunkAction } from 'redux-thunk'
import { Store } from './store'
export type Status = 'pending' | 'success' | 'fail'
export interface Request {
status: Status
error?: string
}
@chrisgervang
chrisgervang / typescript.json
Created May 27, 2017 00:27
VS Code User Snippets
{
/*
// Place your snippets for TypeScript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
@chrisgervang
chrisgervang / notes.md
Last active February 13, 2017 21:40
Language Type Design Notes

##Nominal Type System The name of the class or the interface is the only thing significant in the type system and defines the type for the data. Two type structures may match, but if the name is different the compiler will not let it pass.

Used by: F#, C#, Java

##Structural Type System Also known as duck typing, the structure of the class or interface is significant in the type system and defines the type. Two interfaces with different names, but matching structures are interchangable in this system. It's more flexible than Nominal.

@chrisgervang
chrisgervang / ParentComponent.tsx
Last active July 9, 2023 13:37
Convert SVG from Illustrator to a React Typescript Component (Works in Chrome and IE11+)
import * as React from 'react'
export function IconUsage() {
return (
<div style={{ height: "100%", display: "flex" }}>
<div style={{ height: "40px", width: "40px" }} /* Size icon from parent. Event handlers go here */>
<CircleIcon />
</div>
/* you can add other html here and position it with flexbox */
Meteor.startup(function () {
if (Assets.find().count() === 0) {
console.log('calling loadCSV');
Meteor.call('loadCSV', function (error, result) {
console.log('err: ', error);
console.log(result, 'gameAssets');
//var filePath = '/public/Textures/' + lines[i].match(/\(?<="\)[^"]*\(?="\)/);
//var fileHandle = lines[i].match(/^[^,*]+/);
for(var i = 0; i < result.length; i++) {
fs = Meteor.require('fs');
Future = Meteor.require('fibers/future');
Meteor.methods({
loadCSV: function() {
console.log('loadCSV called');
// Set up a future for the current job
var future = new Future();
//array of data to return to client
var assetsList = [];