Skip to content

Instantly share code, notes, and snippets.

View jmelis's full-sized avatar

Jaime Melis jmelis

View GitHub Profile
#!/usr/bin/python
import sys
import random
class AmigoInvisible:
def __init__(self,names=None):
if names:
self.N = len(names)
self.names = names
self.generate()
else:
#!/usr/bin/python
import sys
import random
class AmigoInvisible:
def __init__(self,names=None):
if names and len(names) > 3:
self.available = names
#random.shuffle(names)
self.names = names
from itertools import combinations,permutations
f = open('strings')
words = [i.strip() for i in f if i.strip() != '']
rs = [2,3]
w = []
for j in rs:
for c in combinations(words,j):
for p in permutations(c):
w.append("".join(p))
#!/bin/bash
# The following file contains a list of the domains to be accepted
ALLOWED_HOSTS=/etc/iptables/allowed_hosts
function add_rule {
host=$1
iptables -A INPUT -s $host -j ACCEPT
}
#!/bin/bash
/sbin/ifconfig|awk 'BEGIN{ iface_line=0}{
if ($0 ~ /Link encap:Ethernet/) {
iface_line = 1;
iface = $1;
mac = $5;
} else if (iface_line == 1) {
iface_line = 0;
if ($0 ~ /inet addr:/){
@jmelis
jmelis / init.rb
Created September 17, 2012 12:54
Virtual Router
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
@jmelis
jmelis / vlan_id.md
Created September 19, 2012 15:29
vlan_id

There are 3 possible scenarios:

  1. The user doesn't want VLAN in his network
  2. The user wants VLAN and can specify the VLAN_ID
  3. The user wants VLAN but wants an automatically generated VLAN_ID

Currently the VLAN tag is used with a number that specifies the VLAN_ID. There is no way to ask the system to generate an VLAN_ID automatically.

  1. Network without VLAN
@jmelis
jmelis / mq_hook.rb
Created September 20, 2012 10:45
asd
#!/bin/bash
echo "$@" > /tmp/args
exit
#!/usr/bin/env ruby
VM_HOOK = [
name = "mq compute.running",
@jmelis
jmelis / README.md
Created September 20, 2012 13:29
asf

Sublime Text 2 MarkDown preview

A simple ST2 plugin to help you preview your markdown files quickly in you web browser.

You can use builtin [python-markdown2][0] parser (default) or use the [github markdown API][5] for the conversion.

If you have the ST2 LivReload plugin, your browser will autorefresh the display when you save your file :)

Installation :

@jmelis
jmelis / run_command.py
Created December 19, 2012 16:33
run_command.py
import sublime
import sublime_plugin
import subprocess
# view.run_command('external_filter')
class ExternalFilterCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().show_input_panel('Command', '',
lambda command: self.runCommand(edit, command),
None, None)