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 | |
| // save as somefile.sh and apply execution permissions | |
| // Installing jupiter for battery managment on ubuntu 11.10 64-bit, works for 32-bit computers too | |
| sudo add-apt-repository ppa:webupd8team/jupiter | |
| sudo apt-get update | |
| sudo apt-get install jupiter |
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
| require 'ostruct' | |
| class Setting < ActiveRecord::Base | |
| class SettingNotFound < RuntimeError ; end | |
| validates_uniqueness_of :key | |
| serialize :value | |
| class << self |
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
| class Api::RegistrationsController < Api::BaseController | |
| respond_to :json | |
| def create | |
| user = User.new(params[:user]) | |
| if user.save | |
| render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
| return | |
| else |
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
| class Api::V1::SessionsController < ApplicationController | |
| respond_to :json | |
| def create | |
| return invalid_login_attempt if params[:user_login].nil? | |
| resource = User.find_for_database_authentication(email: params[:user_login][:email]) | |
| return invalid_login_attempt unless resource |
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 | |
| ### BEGIN INIT INFO | |
| # Provides: unicorn | |
| # Required-Start: $remote_fs $syslog | |
| # Required-Stop: $remote_fs $syslog | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: Start daemon at boot time | |
| # Description: Enable service provided by daemon. |
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
| # Start a worker with proper env vars and output redirection | |
| def run_worker(queue, count = 1) | |
| puts "Starting #{count} worker(s) with QUEUE: #{queue}" | |
| ops = {:pgroup => true, :err => [(Rails.root + "log/workers_error.log").to_s, "a"], | |
| :out => [(Rails.root + "log/workers.log").to_s, "a"]} | |
| env_vars = {"QUEUE" => queue.to_s} | |
| count.times { | |
| ## Using Kernel.spawn and Process.detach because regular system() call would | |
| ## cause the processes to quit when capistrano finishes | |
| pid = spawn(env_vars, "rake resque:work", ops) |
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
| module Ci | |
| class SSH | |
| attr_reader :user, :host, :password, :port, :buffer, :session | |
| def initialize(options={}) | |
| # | |
| # Argument validations | |
| # |
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 objects; | |
| $.ajax({ | |
| url: "/path", | |
| done: function(response){ | |
| // Return here the value | |
| objects = response; | |
| } | |
| }); |
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
| recipients = ['email@example.com'] | |
| mail_body = <<-HTML | |
| Hello world! | |
| HTML | |
| mail = Mail.new do | |
| delivery_method( | |
| :smtp, | |
| :address => "address", |
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
| func makeIncrementer() -> (Int -> Int) { | |
| func addOne(number: Int) -> Int { | |
| return 1 + number | |
| } | |
| return addOne | |
| } | |
| var increment = makeIncrementer() | |
| increment(7) |
OlderNewer