This file contains 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/sh | |
### BEGIN INIT INFO | |
# Provides: mongodb | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Mongodb startup script | |
# Description: Mongodb start stop daemon sends SIGINT to terminate | |
# say man signal to see details | |
# Please check the startup params and replication options |
This file contains 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
# FTP authentification -- see OVH FTP Backup guides | |
server, user, pass = ["your_server", "your_user", "your_pass"] | |
keep = 15 # keep last 15 days | |
what_to_save = ["/home/save/*.tar.gz"] # no subdirs | |
class SaveFtp | |
require "net/ftp" | |
require "time" |
This file contains 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
# Extend MongoMapper Objects | |
# Usage : | |
# ------- | |
# MyModel.search(["title", "text"], "my search", { :flag => nil }, { :limit => 10 }) | |
module MongoMapper | |
module Document | |
module ClassMethods | |
def search(fields, words, conditions = {}, options = {}) | |
filters = [] |
This file contains 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 MongoMapper | |
module Plugins | |
module Querying | |
module ClassMethods | |
def search(fields, words, conditions = {}, options = {}) | |
filters = [] | |
fields = fields.split(",").map {|l| l.strip } if fields.class.to_s == "String" | |
words.split(" ").each do |word| | |
ftemp = [] | |
fields.each {|field| ftemp << "(String(this.#{field}).replace('null', '').match(/#{word}/i))" } |
This file contains 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
Cloud | |
===== | |
apt-get update ; apt-get upgrade | |
apt-get install ruby rubygems curl git-core build-essential libssl-dev libcurl4-openssl-dev | |
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) | |
# Node.js | |
curl -O http://nodejs.org/dist/node-v0.4.9.tar.gz | |
tar -xf node-v0.4.9.tar.gz | |
cd node-v0.4.9 |
This file contains 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 "rubygems" | |
require "mongo" # gem install mongo | |
include Mongo | |
@connection = ReplSetConnection.new(['mongo1.mongood.com', 27017], ['mongo2.mongood.com', 27017], ['mongo3.mongood.com', 27017], :read_secondary => true) | |
@connection.add_auth("<base>", "<login>", "<motdepasse>") # Modifiez avec vos informations | |
@connection.apply_saved_authentication() | |
@db = @connection['<base>'] # Modifiez avec le nom de votre base de données |
This file contains 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 'base64' | |
require 'uri' | |
require 'net/http' | |
if ARGV[0] | |
data = Base64.encode64(IO.read(ARGV[0])) rescue nil | |
unless data.nil? | |
# First Resize to 640x> | |
options = "-resize '640x>'" | |
res = Net::HTTP.post_form(URI.parse('http://img.idfuze.com/api'), {'picture' => data, 'options' => options, 'output' => "o.jpg" }) |
This file contains 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
<?php | |
// connecting to mongood.com cluster | |
$m = new Mongo("mongodb://mongo1.mongood.com:27017,mongo2.mongood.com:27017,mongo3.mongood.com:27017", array("replicaSet" => "cluster")); | |
var_dump($m); | |
$db = $m->selectDB('my_database'); | |
$db->authenticate("my_login", "my_password"); | |
$collection = new MongoCollection($db, 'my_collection'); | |
$cursor = $collection->find(); | |
foreach ($cursor as $doc) { | |
var_dump($doc); |
This file contains 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
<link rel="stylesheet" href="chatify.css" type="text/css" media="screen"> | |
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<script src="underscore.js"></script> | |
<script src="jQuery.jPlayer.2.1.0/jquery.jplayer.min.js"></script> | |
<script src="http://servername:8080/socket.io/socket.io.js"></script> | |
<script src="jquery-chatify.js"></script> | |
<script> | |
var login = "Teacher"; | |
$(function() { | |
$("#chat").chatify({ login: login, rooms: ["teacher-student1", "teacher-student2"]}); |
This file contains 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
cd /path/to/jquery-chatify.js | |
npm install | |
node server.js |