Skip to content

Instantly share code, notes, and snippets.

View richardkazuomiller's full-sized avatar

Ricky Miller richardkazuomiller

View GitHub Profile
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions

Deployed to

@richardkazuomiller
richardkazuomiller / foo.html
Last active August 29, 2015 14:27
Weird hack to get embedded tweets to load on (some versions of) iOS
<script src="/bower_components/webcomponentsjs/webcomponents.js"></script>
<!-- added the following script after importing webcomponents.js because Twitter
widgets call matches.apply(<something other than an element>) . Without it
the error "Can only call Element.matches on instances of Element" when trying
to embed a tweet on iOS Safari.
-->
<script>
Element.prototype._matches = Element.prototype.matches
Element.prototype.matches = function(element){
if(!(this instanceof Element)){
@richardkazuomiller
richardkazuomiller / ago.js
Created May 1, 2014 07:33
Simple "ago" for Date
(function(){
var lang = function(term){
//todo other languages
return term;
}
Date.prototype.ago = function(){
var now = new Date();
var diff = (now - this)/1000;
@richardkazuomiller
richardkazuomiller / gist:10622473
Created April 14, 2014 06:53
node-http-proxy with https
var httpProxy = require('http-proxy')
var fs = require('fs');
var proxy = httpProxy.createProxy({
ws : true,
});
var ssl = {
key: fs.readFileSync('server_nopass.key', 'utf8'),
cert: fs.readFileSync('server.crt', 'utf8')
@richardkazuomiller
richardkazuomiller / mysetup.md
Last active August 29, 2015 13:57
My work setup

#SSH Tunnel, Upstart, Launchd, and BTSyncで手ぶらで帰れるようになった

##問題:会社はマシンを支給してくれないので毎日自分のMacbook Proをオフィスに運ばないといけない。家でも作業したいけど、MBP思いし、途中で落としちゃったりすると大惨事になる

##解決:初号機をSSH TunnelでWeb Facing Computer経由でどこからでもアクセスできるようにして会社に置いとく。電源が入ってれば零号機(家にあるMacbook Pro)からアクセスできる。電源が入ってないと何もできないのでBTSyncで常に同期する。

###Step 1 - Setup SSH Tunnel

@richardkazuomiller
richardkazuomiller / installnode.sh
Last active August 29, 2015 13:56
install node.js in one go
#/bin/bash
sudo apt-get update
sudo apt-get install python-software-properties python g++ make git -y # install dependencies with -y to avoid prompt
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh # get the node.js install script
source ~/.nvm/nvm.sh
[ -s $HOME/.nvm/nvm.sh ] && . $HOME/.nvm/nvm.sh # This loads NVM without having to restart your console
nvm install 0.10
nvm use 0.10
nvm alias default 0.10
source ~/.profile
@richardkazuomiller
richardkazuomiller / retina.less
Last active August 29, 2015 13:56
Retina 1px Less functions
@grey: #ccc;
.retina-border-left(@color : @grey){
background-image: linear-gradient(90deg, @color, @color 50%, transparent 50%);
background-size: 1px 100%;
background-repeat: no-repeat;
background-position: left;
}
.retina-border-right(@color : @grey){
background-image: linear-gradient(90deg, transparent 50%, @color 50%, @color);
@richardkazuomiller
richardkazuomiller / proxy.js
Created February 19, 2014 06:52
node-http-proxy routing proxy with websockets
var httpProxy = require('http-proxy')
var proxy = httpProxy.createProxy({
ws : true
});
var options = {
'herp.dev': 'http://0.0.0.0:9008',
'derp.dev' : 'http://0.0.0.0:3000'
}
@richardkazuomiller
richardkazuomiller / momoclo.js
Last active December 22, 2015 05:29
コンプレするまでももクロマンを何個買わないといけないか
var success_count = 0;
var trial_count = 1000000; //とりあえず1000000回繰り返す
var unique_sticker_count = 22; //22種のシール
var purchase_count = 40; //40枚買った
for(var i = 0; i < trial_count; i++){
var collection = [];
for(var j = 0; j < purchase_count; j++){
collection.push(Math.floor(Math.random()*unique_sticker_count));
}