Skip to content

Instantly share code, notes, and snippets.

@pixelkritzel
pixelkritzel / extractKeys.js
Created Feb 24, 2016
Extract keys from string without delimiter
View extractKeys.js
const str = '__key__dfdsafadf[__index__]kjjkl'
const regx = /__(\w+)__/g
let keys = [];
let res;
while((res = regx.exec(str)) !== null) { console.log( keys.push(res[1]) ) }
View MyComponentsTemplate.jsx
import React from 'react';
var template = function(){return(
<form onSubmit={ this.handleFormSubmit.bind(this) } >
<input type="text" value={ this.foo } ref="foo" />
<button type="submit">Go!</button>
</form>
)}
View MyComponent_extern_template.js
import React, { Component } from 'react';
import template from './MyComponentsTemplate';
export class MyComponent extends Component {
/* skipping all this */
render() {
retun template.call(this)
}
}
View MyComponent_2.jsx
import React, { Component } from 'react';
var template = function template() { return(
<form onSubmit={ this.handleFormSubmit.bind(this) } >
<input type="text" value={ this.foo } ref="foo" />
<button type="submit">Go!</button>
</form>
)}
export class MyComponent extends Component {
View MyComponent_Original.jsx
import React, { Component } from 'react';
export class MyComponent extends Component {
constructor(props) {
super(props);
this.state = {
foo: "foo",
bar: "bar"
}
}
View MyComponent.js
import React, { Component } from 'react';
import template from './MyComponentsTemplate';
export class MyComponent extends Component {
/* skipping all this */
render() {
retun template.call(this)
}
}
@pixelkritzel
pixelkritzel / new_gist_file.js
Created Apr 20, 2015
How to trim undefined
View new_gist_file.js
(this.get('foobar') || '').trim();
View index.html
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.fade-out {
opacity: 0;
@pixelkritzel
pixelkritzel / backboneModelinAttributeObject.js
Created Mar 13, 2015
Backbone - expose model cid to attribute object
View backboneModelinAttributeObject.js
App.Model = Backbone.Model.extend({
initialize: function() {
this.set('cid', this.cid);
}
});
View GIF-Screencast-OSX.md

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:

You can’t perform that action at this time.