Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Having fun

Alexander Fallenstedt Fallenstedt

:octocat:
Having fun
View GitHub Profile
View progress-bar.js
//HTML
<!-- Refer to collective.js for loadscreen code. -->
<div id="overlay">
<div id="progstat"></div>
<div id="progress"></div>
</div>
//CSS
//loading animation:
#overlay{
View isItAprilFoolDay()
/* Check if it is april fools day */
var aprilFools = {
month: 3,
date: 1
}
function isItAprilFoolDay() {
var now = new Date();
return (now.getMonth() == aprilFools.month && now.getDate() == aprilFools.date);
}
@Fallenstedt
Fallenstedt / fix-homebrew-npm.md
Created Jan 24, 2017 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew
View fix-homebrew-npm.md

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

View EmittingComponent.js
import React from 'react'
import mrEmitter from '../helpers/mrEmitter'
export default class EmittingComponent extends React.Component {
handleClick = () => {
mrEmitter.emit('onSomeEvent', 'foo sends bar')
}
render() {
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.5.2/pixi.min.js">
</script>
</head>
<body>
@Fallenstedt
Fallenstedt / ultimate-ut-cheat-sheet.md
Created Jul 10, 2017 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon
View ultimate-ut-cheat-sheet.md

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


View simple cube scene
<html>
<head>
<title>My first three.js app</title>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/88/three.min.js"></script>
View sass rem calulator
// Default font size set by browsers 16px
$browser-context: 16;
// Calculates the rem value so it can be applied everywhere;
//
// @param an integer font size in px
// @param an integer reference size in px
// @return a string with rem unit.
//
@function rem($pixels, $context: $browser-context) {
@Fallenstedt
Fallenstedt / Bridge Ports across a VM
Last active Jan 18, 2018
bridge ports from a VM to root
View Bridge Ports across a VM
netsh interface portproxy add v4tov4 listenport=8001 listenaddress=127.0.0.1 connectport=8001 connectaddress=10.0.2.2
# Change listenport and connectport to the port you desire
Working on a mac and need to test on IE 11 or Edge with a local dev build? Get a VM for the browser you need from developer.microsoft.com
Then open command prompt as admin and pase the code above with the port you need. As an example I may have a local sever on port 3000 on mac.
I need my VM to see this port. I replace connectport and listen port with 3000 and paste this magical line into command prompt to build
the bridge I need.
View gist:af208cb7737ffe03048fa1620292de4a
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master