This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function($){ | |
| // | |
| //-------------------------------------- Model : Image | |
| // | |
| Image = Backbone.Model.extend({ | |
| defaults: { | |
| 'delete' : false | |
| } | |
| }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var phantom = require('phantom'), | |
| vows = require('vows'), | |
| assert = require('assert'); | |
| // nesting tests inside phantom callback so we only | |
| // have to create it once | |
| phantom.create(function(ph) { | |
| var get_page_result = function(url, fn, result) { | |
| ph.createPage(function(page) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias server='open http://localhost:8000 && python -m SimpleHTTPServer' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var fs = require('fs'); | |
| var vm = require('vm'); | |
| var emberjs = fs.readFileSync('public/javascripts/vendor/ember-0.9.5.min.js', 'utf8'); | |
| var templatesDir = 'templates'; | |
| var destinationDir = 'public/javascripts/templates'; | |
| function compileHandlebarsTemplate(templatesDir, fileName) { | |
| var file = templatesDir + '/' + fileName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # chkconfig: 345 20 80 | |
| # description: Play start/shutdown script | |
| # processname: play | |
| # | |
| # Instalation: | |
| # copy file to /etc/init.d | |
| # chmod +x /etc/init.d/play | |
| # chkconfig --add /etc/init.d/play | |
| # chkconfig play on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.twitter.finagle.mysql._ | |
| import java.net.InetSocketAddress | |
| val login = "stevegury" | |
| val client = MySQLClient(new InetSocketAddress("localhost", 3306), login, password) | |
| val query = for { | |
| _ <- client.use("my_db") | |
| res <- client.query("select * from my_table") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.codehaus.jackson.annotate.{ JsonTypeInfo, JsonSubTypes, JsonProperty } | |
| import org.codehaus.jackson.annotate.JsonSubTypes.Type | |
| import org.codehaus.jackson.map.ObjectMapper | |
| @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") | |
| @JsonSubTypes(Array( | |
| new Type(value = classOf[Bingo], name = "x"), | |
| new Type(value = classOf[Bongo], name = "y"), | |
| new Type(value = classOf[Bungo], name = "z") | |
| )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package object mail { | |
| implicit def stringToSeq(single: String): Seq[String] = Seq(single) | |
| implicit def liftToOption[T](t: T): Option[T] = Some(t) | |
| sealed abstract class MailType | |
| case object Plain extends MailType | |
| case object Rich extends MailType | |
| case object MultiPart extends MailType |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source. | |
| # Will include all hosts the playbook is run on. | |
| # Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html | |
| - name: "Build hosts file" | |
| lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present | |
| when: hostvars[item].ansible_default_ipv4.address is defined | |
| with_items: groups['all'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Enhanced NGINX logstash parser: | |
| NGINX log format: | |
| log_format enhanced '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_length "$http_referer" "$http_user_agent" $request_time $upstream_response_time'; | |
| access_log /var/log/nginx/access.log enhanced; | |
| error_log /var/log/nginx/error.log; | |
| logstash pattern (/opt/logstash/pattern/nginx): |
OlderNewer