Skip to content

Instantly share code, notes, and snippets.

View basarat's full-sized avatar
🌹
youtube.com/basaratali

Basarat Ali Syed basarat

🌹
youtube.com/basaratali
View GitHub Profile
console.log('Executing foo');
let foo = 'hello';
export const setFoo = (value)=> foo = value;
export const getFoo = ()=> foo;
const { FuseBox } = require('fuse-box');
const fsbx = require('fuse-box');
const box = FuseBox
.init({
tsConfig: "tsconfig.json",
homeDir: "src/",
sourceMap: {
bundleReference: "sourcemaps.js.map",
outFile: "public/build/sourcemaps.js.map",
export interface Check {
/** If a message is returned it is used to prevent a nav away */
(): string | null | undefined;
}
/** Checks we need to do before leave */
let checks: Check[] = [];
/** Only alert in browsers */
if (typeof window !== 'undefined') {
import * as React from "react";
import * as ReactDOM from 'react-dom'
const Tether = require('tether');
import { PropTypes, Children } from 'react';
const renderElementToPropTypes = [
PropTypes.string,
PropTypes.shape({
appendChild: PropTypes.func.isRequired
})
/**
* Quick array equal
*/
export function arraysEqual<T>(a: T[], b: T[]): boolean {
if (a === b) return true;
if (a == null || b == null) return false;
if (a.length != b.length) return false;
for (var i = 0; i < a.length; ++i) {
if (a[i] !== b[i]) return false;
export interface Listener<T> {
(event: T): any;
}
export interface Disposable {
dispose();
}
/** passes through events as they happen. You will not get events from before you start listening */
export class TypedEvent<T> {
// import
const assert = require("chai").assert;
// later
assert(something, "some message");
  • src/

    • app/
      • All your frontend stuff / entry points
    • Anothing that is not frontend
  • public/

    • index.html
    • build/
      • all your frontend bundles
  • images/

/**
* Utility : Resolves when a script has been loaded
*/
function include(url: string) {
return new Promise<{ script: HTMLScriptElement }>((resolve, reject) => {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
script.onload = function() {
@basarat
basarat / fstyle.tsx
Last active October 13, 2016 21:24
My thin wrapper around `free-style`
/**
* @module Maintains a single stylesheet and keeps it in sync with requested styles
*/
import * as FreeStyle from "free-style";
import * as React from "react";
/** Just for autocomplete convinience */
export interface CSSProperties extends React.CSSProperties {
'&:hover'?: CSSProperties;
'&:active'?: CSSProperties;