Skip to content

Instantly share code, notes, and snippets.

View jlongster's full-sized avatar
💭
Workin on my app

James Long jlongster

💭
Workin on my app
View GitHub Profile
// Have some complicated non-React widgets that manipulate DOM?
// Do they manage a list of DOM elements? Here's how to wrap it
// into a React component so you can "constantly rerender" it.
// A dumb non-react widget that manually manage some DOM node that
// represent a list of items
function NonReactWidget(node) {
this.node = node;
}
@jlongster
jlongster / gist:1288142
Created October 14, 2011 20:00
Bugzilla jsonrpc
function jsonrpc(user, method, params, http_method, cont) {
if(_.isFunction(http_method)) {
cont = http_method;
http_method = 'GET';
}
var request;
var opts = {
Could not cast value of type 'DetoxAppDelegateProxy' (0x10ffafed0) to 'Blink.AppDelegate' (0x10f998c20).
Signal caught: Abort trap: 6
0 EarlGrey 0x0000000127e1d339 grey_signalHandler + 249
1 libsystem_platform.dylib 0x0000000116826b3a _sigtramp + 26
2 libsystem_kernel.dylib 0x00000001167ea430 libsystem_kernel.dylib + 1072
3 libsystem_c.dylib 0x000000011659588f abort + 127
4 libswiftCore.dylib 0x0000000115c4dd55 _ZN5swift10fatalErrorEjPKcz + 149
5 libswiftCore.dylib 0x0000000115c2bdbb _ZN5swift24swift_dynamicCastFailureEPKvPKcS1_S3_S3_ + 75
6 libswiftCore.dylib 0x0000000115c2be20 swift_dynamicCastClass + 0
7 libswiftCore.dylib 0x0000000115c2bec0 swift_dynamicCastClassUnconditional + 80
@jlongster
jlongster / forms-with-react.js
Last active May 8, 2017 14:15
higher-order form components w/react
// Simple wrapper to use bootstrap's grid system to position elements side-by-side
var VerticalFieldsElement = React.createClass({
render: function() {
return dom.div(
{ className: 'clearfix' },
React.Children.map(this.props.children, function(child) {
if(!child) {
return child;
}
@jlongster
jlongster / a-results
Last active April 16, 2017 07:49
transducers w/immutable-js
# benchmark immutable.js with my transducers lib: https://github.com/jlongster/transducers.js
% node bench/immut.js
Immutable map/filter (1000) x 5,497 ops/sec ±2.63% (91 runs sampled)
transducer map/filter (1000) x 7,309 ops/sec ±0.73% (100 runs sampled)
Immutable map/filter (100000) x 62.73 ops/sec ±0.85% (67 runs sampled)
transducer map/filter (100000) x 80.15 ops/sec ±0.48% (71 runs sampled)

I did some poking around CodeMirror and how it works, particularly with it's current code folding implementation. My goal was to see if there was a way to only have part of the string in memory, render those parts, and still have line numbers be correct. My goal was to have the editor display something like this:

1 
2 
3  function() {
27 }
28
new MyReadStream().pipe(new MyDuplex()).pipe(new MyTransform()).pipe(new MyWriteStream())
expect(thisFooVar).toEqual();
var Class = {
propTypes: {
field: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
])
syntax where = function(ctx) {
const binaryOps = ["or", "and", "==", ">", "<", "-", "+", "*", "/", "."];
const dummy = #`dummy`.get(0);
function matchNext(names) {
const marker = ctx.mark();
const next = ctx.next();
ctx.reset(marker);
return !next.done && names.includes(next.value.val());
}
@jlongster
jlongster / gist:2323373
Created April 6, 2012 22:00
LiSP Ch.5: CPS conversion
;; outlet: https://github.com/jlongster/outlet
(define-macro (case c . variants)
`(cond
,@(map (lambda (exp)
(if (== (car exp) 'else)
exp
`((list-find ',(car exp) ,c)
,@(cdr exp))))
variants)))
@jlongster
jlongster / touch.css
Created September 11, 2012 19:20
Web Audio API demo (iOS 6, Chrome) - The Web is a Platform
html, body {
background-color: black;
width: 100%;
height: 100%;
margin: 0;
}
canvas {
display: block;
margin: 0;