Skip to content

Instantly share code, notes, and snippets.

@nikgraf
nikgraf / autocomplete.dart
Created April 12, 2014 20:16
Web UI Autocomplete in Blossom
import 'dart:async';
import 'dart:html';
import 'package:web_ui/web_ui.dart';
import 'package:escape_handler/escape_handler.dart';
class State {
static const ACTIVE = const State._(0);
static const INACTIVE = const State._(1);
"use strict";
import React, {Component} from 'react';
import calcContentHeight from './dom-textarea-measure';
class AutogrowingTextarea extends Component {
constructor(props) {
this.props = props;
this.state = {};
this.textareaProps = sanitizeChildProps(props);
"""
Flask
-----
Flask is a microframework for Python based on Werkzeug, Jinja 2 and good
intentions. And before you ask: It's BSD licensed!
Flask is Fun
````````````
@nikgraf
nikgraf / cloud_front_root.py
Created October 21, 2010 01:16
sets default_root_object of an aws cloud front distribution
from boto.cloudfront import CloudFrontConnection
def update_default_root_object(searched_origin, aws_access_key_id, aws_secret_access_key, default_root_object='index.html'):
""" sets default_root_object of an aws cloud front distribution
for futher information checkout http://boto.s3.amazonaws.com/ref/cloudfront.html
or http://github.com/boto/boto/tree/master/boto/cloudfront
"""
connection = CloudFrontConnection(aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
@nikgraf
nikgraf / npm-graph
Created June 17, 2011 14:47 — forked from michael/npm-graph
data.js playground
Data = require('data')
schema =
'/type/project':
'type': 'type'
'name': 'Project'
'properties':
'name':
'name': 'Name', 'unique': true, 'type': 'string', 'required': true
'tags':
@nikgraf
nikgraf / backbone view
Created October 12, 2012 20:00 — forked from fnordo/gist:3865266
Example BackboneView for pjax like architecture
ArstistPageView = Backbone.View.extend({
initialize: function(){
// If model has changed, update view accordingly:
this.model.bind("all", this.render, this);
},
render: function() {
// fetch the new rendered template from server
templateRequest = $.ajax({ url: "path/to/rendered/artist/template" })
templateRequest.done(function(data) {
// render the template into dom
@nikgraf
nikgraf / destructuring+defaults.js
Last active December 10, 2015 16:36
I'm a big fan of the destructuring assignment syntax in combination with setting default values in JavaScript ❤️
export default ({options = {}}) => {
const {
min = Number.MAX_SAFE_INTEGER,
max = Number.MIN_SAFE_INTEGER,
step = 1,
} = options;
return `Range between ${min} and ${max} with a step of ${step}`;
};
<script type="text/javascript">Raven.setUser({email: 'matt@example.com', id: '123'})</script>
<script src="//d3nslu0hdya83q.cloudfront.net/dist/1.0.5/raven.min.js" type="text/javascript">
</script>
<script type="text/javascript">
Raven.config('https://ac459699bb384140a7e69a3d15890000@app.getsentry.com/3100').install()
</script>
Raven.captureMessage('hello world!');