Skip to content

Instantly share code, notes, and snippets.

View uolter's full-sized avatar

Walter Traspadini uolter

View GitHub Profile
#!/bin/bash
# Elastic Serarch Start and Stop Script
ES_HOME="/opt/elsearch/elasticsearch"
ES_USER="esearch"
PID=$(ps ax | grep elasticsearch | grep $ES_HOME | grep -v grep | awk '{print $1}')
#echo $PID
#! /bin/sh
### BEGIN INIT INFO
# Provides: elasticsearch
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts elasticsearch
# Description: Starts elasticsearch using start-stop-daemon
### END INIT INFO
@uolter
uolter / setup-web2py-ubuntu.sh
Created January 26, 2014 15:00
Set up web2py to run on Ubuntu with apache and mod_wsi
echo "This script will:
1) install all modules need to run web2py on Ubuntu/Debian
2) install web2py in /home/www-data/
3) create a self signed sll certificate
4) setup web2py with mod_wsgi
5) overwrite /etc/apache2/sites-available/default
6) restart apache.
You may want to read this script before running it.
@uolter
uolter / tf_idf.py
Created December 18, 2013 09:42
Simple term frequency and inverse document implementation
# -*- coding: utf-8 -*-
# <codecell>
# term frequency
from math import log
# XXX: Enter in a query term from the corpus variable
# QUERY_TERMS = ['mr.', 'green']
from datetime import datetime
def time_average(time_1, time_2):
"""
return a the average time between time_1 and time_2
as a string in the same format as the input
"""
FMT = '%M:%S:%f'
@uolter
uolter / counting_string
Created November 26, 2013 15:01
Counting characters in a string putting them in a dictionary
import sys
import unittest
def count(text):
# if the text is None or empty do nothing
if text:
text = text.replace(' ', '')
else:
return None
@uolter
uolter / cdb.sh
Last active December 28, 2015 05:29
#!/bin/bash
# save this script in your bin directory source it.
# source cdb.sh
# (it would be nice to do that in your bash profile as well.)
# Then you can run the cdb function in every terminal and bookmark any path you like.s
function show_bookmark {
for f in `ls ~/.cd_bookmarks/`
do
@uolter
uolter / collaborative_filtering.py
Created June 30, 2013 09:31
Simple collaborative filtering in python
import numpy as np
from scipy.optimize import fmin_cg
def cost(p, Y, R, alpha):
"""
Calculates collaborative filtering cost function.
Arguments
----------
@uolter
uolter / huffman.py
Created April 22, 2013 13:33
Huffman code with python
from collections import Counter
import heapq
class Node(object):
def __init__(self, pairs, frequency):
self.pairs = pairs
self.frequency = frequency
def __repr__(self):
return repr(self.pairs) + ", " + repr(self.frequency)
@uolter
uolter / gist:4258642
Created December 11, 2012 13:41
svn add new files only
svn st | grep ? | awk '{print $2}' | xargs svn add