Skip to content

Instantly share code, notes, and snippets.

View JavascriptMick's full-sized avatar

JavascriptMick JavascriptMick

View GitHub Profile
@JavascriptMick
JavascriptMick / GetNasty.js
Created February 29, 2016 21:55
Use a Higher order component to add mouse events to a host component
import React from "react";
export default function GetNasty(TargetComponent){
return class GetNasty extends React.Component{
handleOnClick($event){
alert("You suck!");
}
render(){
const props = Object.assign({
@JavascriptMick
JavascriptMick / DraggableComponent.js
Last active March 1, 2016 21:15
Adding Draggable behaviour to a React component
import React from "react";
export default class DraggableComponent extends React.Component{
constructor(props){
super(props);
this.isDragging = false;
this.originalClientX = 0;
this.originalClientY = 0;
this.originalTop = 0;
this.originalLeft = 0;
@JavascriptMick
JavascriptMick / frontend.js
Created November 8, 2015 21:55
Horrible Kluge to make ghost support my legacy Blogger URL's
var frontend = require('../controllers/frontend'),
config = require('../config'),
express = require('express'),
utils = require('../utils'),
frontendRoutes;
frontendRoutes = function frontendRoutes(middleware) {
var router = express.Router(),
subdir = config.paths.subdir,
@JavascriptMick
JavascriptMick / TextController.cs
Created April 19, 2015 05:52
Better Engine for Text101
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
public class TextController : MonoBehaviour {
public Text questionText;
private enum StateKey {Car, OpenWindow, Docs, MissingDog, DeadBug, Freakout, Police, Haircut, Court, PayFine, GoldCoast};
private StateKey currentState;
@JavascriptMick
JavascriptMick / index.html
Last active September 13, 2019 12:11
Thinking in React
<html>
<head>
<script src="bower_components/react/react.js"></script>
<script src="bower_components/react/JSXTransformer.js"></script>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" type="text/css"/>
</head>
<body>
<div class="container" id="container">
</div>
@JavascriptMick
JavascriptMick / config_dev.js
Last active August 29, 2015 14:14
Integration Testing a Restful Endpoint with Request and Jasmine and Node.JS
//*****useage*******
//var config = require('config_' + (process.env.NODE_ENV || 'dev'));
console.log('*** using dev config ***');
exports.mongo_db_address = 'localhost';
exports.mongo_db_port = 27017;
exports.mongo_db_name = 'myDB';
exports.mongo_db_user = null;
exports.mongo_db_pass = null;
@JavascriptMick
JavascriptMick / install fail
Created April 23, 2014 10:29
mean.io fail install
Michaels-MacBook-Pro:Workspace michael$ sudo npm install -g meanio@latest
Password:
npm http GET https://registry.npmjs.org/meanio
npm http 304 https://registry.npmjs.org/meanio
npm WARN engine meanio@0.4.8: wanted: {"node":"0.10.x","npm":"1.4.x"} (current: {"node":"v0.10.15","npm":"1.3.5"})
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/commander
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/mongodb
@JavascriptMick
JavascriptMick / output.txt
Last active August 29, 2015 13:57
poc using registry to look at files existing as @ listen
Michaels-MacBook-Pro:hackify_ruby michael$ bundle exec ruby poc.rb
b.js
subfolder
a.js
^Cpoc.rb:16:in `sleep': Interrupt
from poc.rb:16:in `<main>'
Michaels-MacBook-Pro:hackify_ruby michael$ bundle exec ruby poc.rb
fiddleWithAsync.js
^Cpoc.rb:16:in `sleep': Interrupt
@JavascriptMick
JavascriptMick / universal-analytics-wrapper.js
Created September 7, 2013 01:23
universal-analytics wrapper to assist with putting user info on session. Note that this method assumes you are going to scrape the cid out of the _ga cookie i.e. let analytics.js derive the cid and do the cookie persistance for you. If you want to use your own cid determined server side, then this is not for you.
/*
Useage
**require**
uaw = require('.[path]/universal-analytics-wrapper'),
** express setup **
app.use(uaw.cookieConfigurer('UAXXXXX'));
** get visitor **
@JavascriptMick
JavascriptMick / mongodb-dao.js
Last active February 18, 2021 15:28
Simple Node.js Utility module to enable easy creation of models using node-mongodb-native
/*
Simple Node.js Utility module to enable easy creation of models using node-mongodb-native
Useage:-
var dao = require('./mongodb-dao');
exports.NewClient = function(clientId, plan){
return {
clientId: clientId,
plan: plan,