Skip to content

Instantly share code, notes, and snippets.

View schovi's full-sized avatar
👁️

David Schovanec schovi

👁️
View GitHub Profile
@schovi
schovi / checked.js
Last active December 14, 2015 06:49
define(['can/control', 'can/control/plugin'], function(Control) {
return can.Control('Checked', {
init: function(el, opt) {
var type = this.type = el.attr('type')
if(type != "checkbox" && type != "radio") {
console.warn("Cant initialize Checked control on type='" + type + "' element")
return
}
@schovi
schovi / can.compute.example.js
Created March 9, 2013 21:38
Simple example of using can.compute with template
var Person = can.Observe({
fullName: can.compute(function(fullName) {
if(typeof fullName === "undefined") {
return this.attr('firstName') + " " + this.attr("lastName")
} else {
var parts = fullName.split(/\s+/)
this.attr('lastName', parts.pop())
this.attr('firstName', parts.pop())
}
})
{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"and": [
{
"term": {
"situation_ids": "1"
}
// Generator
function timeDataGenerator(interval) {
var times = [];
for (x = 0; x < 24; x++) {
if (x.toString().length === 1) { var hours = "0"+x; }
else { var hours = x; }
for (y = 0; y < 60; y+=interval) {
if (y.toString().length === 1) { var minutes = "0"+y; }
else { var minutes = y; }
times.push(hours+":"+minutes);
http delete localhost:9200/cities
http post localhost:9200/cities <<< '{
"settings" : {
"number_of_shards": 2,
"number_of_replicas": 0,
"index.refresh_interval": "1s"
},
"mappings": {
"city": {
@schovi
schovi / gist:5374759
Created April 12, 2013 20:12
CanJS Live Value Control
var stringify = function(obj) {
if(obj === undefined || obj === null) {
} else if(typeof obj === "object") {
if(obj instanceof can.Observe) { // Get native object or array from Observe or Observe.List
obj = obj.attr()
} else { // Clone object to prevent change original values
obj = can.isFunction(obj.slice) ? obj.slice() : can.extend({}, obj)
}
// Convert each object property or array item into stringified new
can.each(obj, function(val, prop) { obj[prop] = stringify(val) })
DELETE
DELETE _template/{name}
DELETE {index}
DELETE {index}/_alias/{name}
DELETE {index}/_query
DELETE {index}/_warmer
DELETE {index}/_warmer/{name}
DELETE {index}/{type}
DELETE {index}/{type}/_mapping
DELETE {index}/{type}/_query
Filter
{
"whitespace_remove" : {
"type" : "pattern_replace",
"pattern" : " ",
"replacement" : ""
}
}
grunt.config.init
less:
options:
paths: ["src/css/"]
build:
options:
compress: true
stripBanners:
block: true
line: true
@schovi
schovi / REAME.md
Created September 24, 2013 10:05 — forked from romansklenar/REAME.md

How to set up your VPS with Chef Solo

1. What is it?

There are many different provisioning tools out there, the most popular of which are Chef and Puppet. Chef uses Ruby, Puppet uses a DSL (Domain Specific Language), there are others that use simple bash too, but today we're going to focus on Chef Solo.

2. Dependencies

To get Chef working properly on your local machine you need a few things.

Make sure you use Ruby 1.9.x and not Ruby 2.x as you will get errors with the json 1.6.1 gem on 2.x. Use rbenv or RVM to manage several different Rubies on the one machine.