Skip to content

Instantly share code, notes, and snippets.

View xiaohutai's full-sized avatar

Xiao-Hu Tai xiaohutai

  • The Netherlands
View GitHub Profile
@iainvdw
iainvdw / index.js
Created July 25, 2018 08:55
Transmuter.js - simple state container store, fires events when property changes
import { Transmuter, listen } from './transmuter.js';
// Set up intial state
const initialState = {
name: 'lala',
isIt: true,
count: 123,
};
// Setup store
function Mutilator(data, name, context) {
this.n = name || `mutilation-${+new Date()}`;
this.d = data;
this.c = context || window;
this.isArr = function(p) {
return this.d[p].constructor == Array;
};
this.dispatch = function(p, v, t) {
this.c.dispatchEvent(
new CustomEvent(this.n, {
@media print {
/* Hide stuff you don't want visible on the printed page */
.foo {
display: none;
}
/* Hiding video's and removing ugly whitespace fromr hidden iframes */
@nadavrot
nadavrot / Matrix.md
Last active October 16, 2025 09:22
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of

@turigabor
turigabor / google_maps.html
Created May 19, 2018 10:58
cookieless google maps
<!DOCTYPE html>
<html><head><title>Google Maps</title>
<meta charset="utf-8" />
<style type="text/css">html,body{width:100%;height:100%;margin:0;padding:0;}</style>
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1" />
<script type="text/javascript">
var address = getParamter('q');
document.title = address + ' - ' + document.title;
function getParamter (name) {
@sconstantinides
sconstantinides / App.js
Created May 1, 2018 23:37
Sample Firebase task app
import React, { Component } from 'react';
import firebase from '@firebase/app';
import firestore from './firestore'; // Code: https://gist.github.com/sconstantinides/546a48ba183b1234f750ca6261440199
class App extends Component {
constructor(props) {
super(props);
this.state = {
userId: localStorage.getItem('userId') || '',

Rules for life

Child

  1. Be nice to others.
  2. It's okay to say "no."
  3. Don't take what belongs to someone else.
  4. Be willing to share.
  5. It's okay to cry. It's better to solve the problem.
  6. Try a new thing each week.
@jadwigo
jadwigo / config.xml
Last active October 5, 2018 18:15
Cordova cli-8.0.0 config.xml for geolocation
<?xml version='1.0' encoding='utf-8'?>
<widget
id="com.example.appname"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:gap="http://phonegap.com/ns/1.0"
versionCode="10203"
version="1.2.3">
<name>appname</name>
@pestbarn
pestbarn / IE11-grid-with-autoprefixer.md
Last active January 23, 2019 18:56
CSS Grid for IE11 using Autoprefixer

About: CSS Grid for IE11

CSS Grid in IE11 is an implementation based on the 2011 spec, which means we aren't really able to use grids out of the box according to the newer spec. However, Autoprefixer automates a lot of work for us with getting the correct IE11 properties, and it has support for most (if not all?) -ms-grid properties.

There are still some gotchas which Autoprefixer can't help with though:

  • There is no auto-placement behaviour in the 2011 spec. This means that for IE11, you have to position everything. rather than use the autoplacement ability of grid.
  • Using minmax() with an auto value is not supported, and will break things - e.g. minmax(auto, 1200px) will not work. To use minmax, you have to specify two positive values - e.g. minmax(500px, 1200px).
  • grid-gap properties were added in a later spec. To create grid-gaps in IE11, you will need to create separate
@jaredatch
jaredatch / mailhog-mamp.md
Created January 30, 2018 21:57
Install MailHog with MAMP Pro

Install MailHog with MAMP Pro, using HomeBrew.

MailHog

First let's make sure HB is updated. Open up terminal for the following steps.

$ brew update