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 'bundler' | |
require 'socket' | |
Bundler.require | |
WS_CLIENTS = {} | |
WS_CLIENTS_NAME_TO_SOCKET = {} | |
WS_HOST = Socket.ip_address_list.last.ip_unpack.first) | |
WS_PORT = 8090 | |
HTTP_PORT = WS_PORT + 1 |
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/bash | |
readonly ARGS="$@" | |
readonly DEPLOY_USER="www-data" | |
clone_repo_at_tag() { | |
local repo="$1" | |
local tag="$2" | |
local project_name="$3" | |
local repo_dirname="$project_name-$tag" |
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
<!doctype html> | |
<html lang="en-us"> | |
<head> | |
<title> | |
[your title] | |
</title> | |
<meta charset="utf-8"> | |
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" /> | |
<link rel="stylesheet" href="" /> | |
<meta name="viewport" content="width=device-width"> |
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
html:5>#wrapper>((header>((#logo>img)+h1+nav>ul>li*3))+(#body>header>h2+p)+(footer>p))*1 | |
>> Now hit tab to get it to expand |
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/bash | |
echo "Executing Resque Manager." | |
start() { | |
echo -n "Starting resque..." | |
RAILS_ENV="$TARGET_ENV" QUEUE="v2_processing" VERBOSE="1" nohup bundle exec rake environment resque:work --trace > ./log/resque.log & | |
return | |
} | |
stop() { |
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
var MongoClient = require('mongodb').MongoClient; | |
MongoClient.connect('mongodb://127.0.0.1:27017/inbox', function(err, db) { | |
if (err) throw err; | |
var collection = db.collection('test_insert'); | |
var sample1 = { 'messages.82513': { body: '123\r\n456\r\n789\r\n', db_msg_id: '82513' } }; | |
var sample2 = { 'messages.12': { body: '123\r\n456\r\n789\r\n', db_msg_id: '12'} }; | |
var base_doc = { conv_hash: '711_34401', messages: {} }; | |
//## FAILS ## |
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 'mongoid' | |
Mongoid.load!("./mongoid.yml") | |
Mongoid.raise_not_found_error = false | |
class Doc | |
include Mongoid::Document | |
store_in collection: "testing123" | |
field :name, type: Integer | |
field :_id, type: Integer, default: ->{ name } |
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
# Command: GLOG | |
# Description: alias that creates a nice and easy on eye history log with graph indication of merge commits and branches | |
git config --global alias.glog "\!git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative ; true" | |
# Run: | |
git glog | |
# Command: LASTWORKS | |
# Description: Lists the last 10 branches you worked on | |
git config --global alias.lastworks "for-each-ref --count=10 --sort=-committerdate refs/heads/" |
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
var db = db.getSiblingDB("admin"); | |
var dbs = db.runCommand({ "listDatabases": 1 }).databases.sort(); | |
dbs.forEach(function(database) { | |
db = db.getSiblingDB(database.name); | |
cols = db.getCollectionNames().sort(); | |
cols.forEach(function(col) { | |
if (!db[col]) { return; } | |
db[col].getIndexes().sort().forEach(function(index) { | |
if ("_id_" !== index.name) { | |
print("at database: [" + database.name +"], db." + col + ".ensureIndex(" + tojson(index.key) + ")"); |
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
var COUNTER = 900; | |
function deleteSome(count) { | |
var itemsToDel = db.tasks.find({status: "SUCCESS"}, {_id: 1}).sort({created_at: 1}).limit(count).toArray(); | |
var IDs = itemsToDel.map(function(item){ return item["_id"]}) | |
if (IDs.length > 0 ) { | |
db.tasks.remove({"_id": {"$in": IDs } }); | |
sleep(5000); | |
} else { | |
COUNTER++; |
OlderNewer