Skip to content

Instantly share code, notes, and snippets.

View zackify's full-sized avatar
🤠
coding like crazy

Zach Silveira zackify

🤠
coding like crazy
View GitHub Profile
@zackify
zackify / localstorage.html
Created August 28, 2011 23:59
Auto loading and saving for content
<script type="text/javascript">
$(document).ready(function(){
var edit = document.getElementById('edit');
$(edit).blur(function() {
localStorage.setItem('todoData', this.innerHTML);
});
@zackify
zackify / filters.php
Last active August 29, 2015 13:58
Cache Everything in laravel with 4 extra lines of code!
App::before(function($request)
{
$key = Str::slug($request->url());
if(Cache::has($key)) return Cache::get($key);
});
App::after(function($request, $response)
{
$key = Str::slug($request->url());
/** @jsx React.DOM */
import React from 'react'
import {itemHandlerMixin} from '/widgets/mixins'
import $ from 'jquery'
export var socialEmbed = React.createClass({
getInitialState: function(){
return this.props.config || {active: {twitter: false, facebook: false,google: false, instagram: false }, twitter: { url: '',html: '' }, facebook: { url: '' }, google: { url: '' }, instagram: { url: '' } }
@zackify
zackify / crop.jsx
Created August 19, 2014 00:19
First stab at a React.js client side cropper component using Jcrop ---comments coming soon---
/** @jsx React.DOM */
import React from 'react';
import {uploadImageBlob} from 'appicus';
export var crop = React.createClass({
contextTypes: {
site: React.PropTypes.object
},
getInitialState: function(){
var GaugeWrapper = React.createClass({
componentDidMount(){
var target = React.findDOMNode(this)
var gauge = new Gauge(target).setOptions(this.props.options);
gauge.maxValue = this.props.max;
gauge.set(this.props.value);
},
render(){
return <canvas width={this.props.width} height={this.props.height} />
}
@zackify
zackify / gist:861d6ed399f2ffa55c7d
Created May 12, 2015 04:53
ES6 classes and module loading is too easy with webpack:)
module.exports = {
entry: {
jobs: 'app.jsx'
},
output: {
filename: "[name].bundle.js",
chunkFilename: "[id].bundle.js"
},
module: {
loaders: [
@zackify
zackify / isMounted.js
Created May 14, 2015 03:42
isMounted Module
import React from 'react';
export default function isMounted(component) {
// exceptions for flow control :(
try {
React.findDOMNode(component);
return true;
} catch (e) {
// Error: Invariant Violation: Component (with keys: props,context,state,refs,_reactInternalInstance) contains `render` method but is not mounted in the DOM
return false;
import React from 'react'
export default class Woah extends React.Component{
render(){
return <div className="test">hi</div>
}
}
@zackify
zackify / gist:acf19f6ca0f8be13fb90
Last active January 14, 2020 15:06
Visually see react elements
setInterval(function() {
Array.prototype.slice.call(document.querySelectorAll('[data-reactid]'))
.forEach(function(element) {
element.style.background = 'rgba(255,0,0,0.1)';
})
}, 500)
@zackify
zackify / boxdown.js
Created August 9, 2015 21:11
CSS Powered dropdown
import React from 'react';
import './Boxdown.less';
class Boxdown extends React.Component{
items(){
return this.props.items.map(item => {
return (
<li key={item.value} onClick={this.handleChange} data-value={item.value}>
<a href="#">{item.text}</a>