Skip to content

Instantly share code, notes, and snippets.

View Seraf's full-sized avatar

Julien Syx Seraf

View GitHub Profile
#!/usr/bin/env python
# Copyright (c) 2008 Carnegie Mellon University.
#
# You may modify and redistribute this file under the same terms as
# the CMU Sphinx system. See
# http://cmusphinx.sourceforge.net/html/LICENSE for more information.
import pygtk
pygtk.require('2.0')
@Seraf
Seraf / Lisa_client.py
Last active August 29, 2015 13:57
lisa client
from twisted.internet import glib2reactor # for non-GUI apps
glib2reactor.install()
import sys
import signal
import gobject
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
from twisted.internet import ssl, utils
╭─julien@tagada-work ~/Sandbox/LISA-CLIENT-Linux ‹pocketsphinx*›
╰─➤ twistd -ny lisa.tac
Removing stale pidfile /home/julien/Sandbox/LISA-CLIENT-Linux/twistd.pid
2014-03-14 20:42:37+0100 [-] Log opened.
2014-03-14 20:42:37+0100 [-] twistd 13.2.0 (/usr/bin/python 2.7.5) starting up.
2014-03-14 20:42:37+0100 [-] reactor class: twisted.internet.glib2reactor.Glib2Reactor.
2014-03-14 20:42:37+0100 [-] Starting factory <__builtin__.LisaClientFactory instance at 0x2a194d0>
2014-03-14 20:42:37+0100 [-] Started to connect.
2014-03-14 20:42:37+0100 [Uninitialized] Resetting reconnection delay
2014-03-14 20:42:37+0100 [Uninitialized] Connected to Lisa.
@Seraf
Seraf / setup.py
Created April 13, 2014 18:21
setup.py for lisa
from setuptools import setup, find_packages
from pip.req import parse_requirements
import json
import pip
import os
from distutils.command.install_data import install_data
import shutil
from django.core.management import call_command
# Ugly hack but django-tastypie-mongoengine require mongoengine 0.8.1
@Seraf
Seraf / lisa-server.init
Created April 14, 2014 09:04
LISA Server Daemon
#! /bin/sh
### BEGIN INIT INFO
# Provides: lisa-server
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop Lisa server
### END INIT INFO
@Seraf
Seraf / gist:11367851
Last active August 29, 2015 14:00
LISA Install instructions
sudo apt-get install mongodb python-setuptools libxslt1-dev libxslt1.1 libxml2-dev build-essential python-dev libssl-dev python-openssl libyaml-dev
sudo easy_install pip
sudo pip install virtualenv virtualenvwrapper
sudo useradd -s /bin/bash -m lisa
sudo su - lisa
export WORKON_HOME=$HOME/.virtualenvs
echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.bashrc
export PROJECT_HOME=$HOME/
echo "export PROJECT_HOME=$HOME/" >> ~/.bashrc
source /usr/local/bin/virtualenvwrapper.sh
@Seraf
Seraf / terminal
Created July 15, 2014 14:53
Angularjs LISA
# Clone the repo
╭─julien@tagada-work ~/Sandbox/
╰─➤ git clone git@github.com:Seraf/LISA.git
╭─julien@tagada-work ~/Sandbox/
╰─➤ cd LISA
# Go to angularjs branch
╭─julien@tagada-work ~/Sandbox/LISA ‹master*›
╰─➤ git checkout angularjs
@Seraf
Seraf / lisa-vhost
Created October 5, 2014 20:45
Vhost to proxify LISA
server {
listen 80;
root /usr/share/nginx/html;
index index.html index.htm;
server_name lisa;
location / {
proxy_pass http://lisa:8000/;
@Seraf
Seraf / ec2_tags.rb
Last active August 29, 2015 14:10
ec2 tags to facts. It requires aws-cli (pip install aws-cli)
require 'facter'
require 'json'
instance_id = Facter.value("ec2_instance_id")
region = Facter.value("ec2_placement_availability_zone")[0..-2]
tags = Facter::Util::Resolution.exec("/usr/local/bin/aws ec2 describe-tags --filters \"Name=resource-id,Values=#{instance_id}\" --region #{region} | cut -f 4-")
parsed_tags = JSON.parse(tags)
parsed_tags['Tags'].each do |tag|
Facter.add("ec2_tag_#{tag["Key"]}") do
@Seraf
Seraf / register_ec2_to_route53.py
Created February 10, 2015 16:03
Register automatically an ec2 instance to route 53. The domain is pushed with DHCP option and is stored in the resolv.conf file
#!/usr/bin/env python
import urllib2
import boto
import logging
import socket
logger = logging.getLogger(__name__)
handler = logging.FileHandler('/var/log/route53.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')