Skip to content

Instantly share code, notes, and snippets.

View manuelmorales's full-sized avatar

Manuel Morales manuelmorales

View GitHub Profile
@manuelmorales
manuelmorales / html test.html
Created September 29, 2016 17:02
html test
<html>
<body>
<strong> Hello </strong>
</body>
</html>
db.currentOp().inprog.ForEach(
function(operation) {
if(operation.secs_running > 30) db.killOp(operation.opid))
})
// kills long running ops in MongoDB (taking seconds as an arg to define "long")
// attempts to be a bit safer than killing all by excluding replication related operations
// and only targeting queries as opposed to commands etc.
killLongRunningOps = function(maxSecsRunning) {
currOp = db.currentOp();
for (oper in currOp.inprog) {
op = currOp.inprog[oper-0];
if (op.secs_running > maxSecsRunning && op.op == "query" && !(/^local/.exec(op.ns))) {
print("Killing opId: " + op.opid
@manuelmorales
manuelmorales / 0_reuse_code.js
Created December 16, 2013 23:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@manuelmorales
manuelmorales / gist:7527288
Created November 18, 2013 12:52
Echo HTTP server in sinatra
require 'sinatra'
set :port, 8080
get '/*' do
puts "[ECHO] #{request.host}:#{request.port}#{request.path}?#{request.user_agent}"
end
# redirect port 80 traffic with
# sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080
@manuelmorales
manuelmorales / headless.sh
Created November 15, 2013 12:06
Run anything headless with Xvfb virtual frame buffer
Xvfb :89 -ac -noreset
export DISPLAY=:89
@manuelmorales
manuelmorales / freeze!.sh
Created July 17, 2013 16:19
How to freeze a process in Linux with kill
sudo kill -SIGSTOP 21758
sudo kill -SIGCONT 21758
@manuelmorales
manuelmorales / haproxy.cfg
Created May 11, 2013 16:59
Make sysklogd (syslog) listen for UDP messages on port 514. Useful for haproxy
# /etc/haproxy.cfg
global
log 127.0.0.1 local0
...
@manuelmorales
manuelmorales / ping-forever.sh
Created May 7, 2013 09:38
Will ping indefinitely and output the http status
while true; do STATUS=`curl --output /dev/null -s -w '%{http_code}' https://example.com`; echo "`date` status: $STATUS"; sleep 1; done
@manuelmorales
manuelmorales / gist:5460294
Last active December 16, 2015 15:59
Bootstrap and plain new Ubuntu linux installing all the basic packages
sudo apt-get install git vim terminator tmux aptitude vagrant meld ruby mongodb-server mysql-server redis-server