Skip to content

Instantly share code, notes, and snippets.

View mrkev's full-sized avatar

Kevin Chavez mrkev

View GitHub Profile
@mrkev
mrkev / moo
Last active May 28, 2020 10:50
moo v0.4
#!/bin/bash
# The moo scripting utility.
# By: Kevin Chavez (@aykev)
# moo myScript creates or edits a script.
## TODO: moo mv a b
SCRIPTS_DIR=~/.scripts/
@mrkev
mrkev / ports.js
Last active March 18, 2019 19:20
Easy two-way communication between two different JavaScript contexts (ie, iframe <-> parent window).
window.listen = function(cb) {
// handle requests
const recieveREQ = function(message) {
if (message.data.type !== "REQ") {
return;
}
if (!(message.ports && message.ports[0])) {
cb(new Error("ERROR 2315: connection request was malformed. No port."));
@mrkev
mrkev / Timers.swift
Created August 5, 2018 05:48
Some timer utilities
import Foundation
// I took this from: https://gist.github.com/peatiscoding/4f8699d8acd635746037b844f0730336
/**
setTimeout()
Shorthand method for create a delayed block to be execute on started Thread.
This method returns ``Timer`` instance, so that user may execute the block
@mrkev
mrkev / index.htm
Created July 5, 2018 22:03
minimal-react
<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.1/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.4.1/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
<script type="text/babel">
class App extends React.Component {
render () {
return <p>Hello, Universe</p>
}
@mrkev
mrkev / GIF-Screencast-OSX.md
Created January 17, 2017 01:17 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@mrkev
mrkev / objectify.js
Created May 30, 2016 17:56
Objectifies functions lol
'use strict';
var args = function (fun) {
var str = fun.toString().split("\n")[0];
return str.substring(str.indexOf("(")+1, str.indexOf(")")).split(",").map(function (x) { return x.trim(); });
};
var objectify = function (fun) {
if (typeof fun !== 'function') throw new Error(fun + " is not a function.");
// could extend so it also accepts an array or arguments
@mrkev
mrkev / curry.js
Created May 30, 2016 17:01
Currying a function in js
"use strict";
/* global require, console, module */
var arr = function (x) {
return Array.prototype.slice.call(x);
};
var args = function (str) {
return str.substring(str.indexOf("(")+1, str.indexOf(")")).split(",");
};

Keybase proof

I hereby claim:

  • I am mrkev on github.
  • I am chavez (https://keybase.io/chavez) on keybase.
  • I have a public key whose fingerprint is 6842 16FF B007 144F B068 04C5 D85F 1C8A BDFE AD82

To claim this, I am signing this object:

@mrkev
mrkev / exp.pde
Created November 9, 2015 16:04
Experiment
int SWID = 1440;
int SHEI = 720;
void setup () {
size(SWID, SHEI);
background(255,255,255);
}
void drawCircle (int cx, int cy, int rd, int res) {
pushMatrix();
@mrkev
mrkev / algo.coffee
Created October 17, 2015 17:15
My breakfast
if cereal and wants_cereal
cereal
if ceral and !wants_cereal
ask_on_csp()
cereal
if !cereal
cereal if buy_cereal() && Math.random() > .2
eat_out()