Skip to content

Instantly share code, notes, and snippets.

View shamansir's full-sized avatar

Ulric Wilfred shamansir

View GitHub Profile
@berkus
berkus / dig.lua
Last active August 29, 2015 14:22
Minecraft turtle machinery
-- To load to turtle: pastebin get aKard6z3 dig
-- Simple digger --
-- When called, will dig down to bedrock, move one forward and dig back up to original location.
-- Call "dig <N>" - N times dig down and back up.
-- Can refuel from any slot.
-- Will group resources into same slot.
-- Will drop junk items if no free space.
--
@TheSeamau5
TheSeamau5 / OutlineWebAudioAPI.elm
Created May 7, 2015 17:34
Outline for Web Audio API in Elm
----------------------------
-- Basic Audio Operations --
----------------------------
getAudio : String -> Task Http.Error Audio
play : Audio -> Task error ()
stop : Audio -> Task error ()
@chantastic
chantastic / on-jsx.markdown
Last active March 20, 2024 01:03
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@mathisonian
mathisonian / index.md
Last active March 22, 2023 05:31
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@cobbal
cobbal / monad.swift
Last active April 6, 2016 04:40
Monad protocol in swift
protocol Monad {
typealias F
typealias U
class func bind<M : Monad where M.U == U>(Self, F -> M) -> M
class func `return`(F) -> Self
}
extension Array : Monad {
typealias F = T
@nikolaykasyanov
nikolaykasyanov / RAC.swift
Last active August 29, 2015 14:02
Proof-of-concept typesafe RAC wrapper
protocol ISubscriber {
typealias Element
func disposable() -> RACCompoundDisposable
func sendNext(e: Element)
func sendError(e: NSError)
func sendCompleted()
}
@bvssvni
bvssvni / gist:9674632
Last active December 23, 2023 22:56
A Rust Chain Macro
//! Chain macro in Rust
//!
//! A typical usage is to avoid nested match expressions.
//!
//! Supports:
//! - Pattern matching
//! - Or expressions (A | B => ...)
//! - Guarded statements (x if <cond> => ...)
//! - Implicit else (requires all arms to return same type)
@matthiasplappert
matthiasplappert / gist:9493050
Last active August 29, 2015 13:57
QuickLook Debugging for `UIView`
@interface UIView (MPAdditions)
@end
@implementation UIView (MPAdditions)
- (id)debugQuickLookObject {
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) {
return nil;
}