Skip to content

Instantly share code, notes, and snippets.

View fluffybeing's full-sized avatar
💻
Working

Rahul Ranjan fluffybeing

💻
Working
View GitHub Profile
(raxcli)[rranjan@localhost python-raxcli]$ python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to raxcli.egg-info/requires.txt
writing raxcli.egg-info/PKG-INFO
writing top-level names to raxcli.egg-info/top_level.txt
writing dependency_links to raxcli.egg-info/dependency_links.txt
writing entry points to raxcli.egg-info/entry_points.txt
reading manifest file 'raxcli.egg-info/SOURCES.txt'
@fluffybeing
fluffybeing / gist:9496056
Created March 11, 2014 22:00
libcloud.rest startup error
(libREST)[rranjan@localhost libcloud.rest]$ python libcloud_rest/server.py
Traceback (most recent call last):
File "libcloud_rest/server.py", line 101, in <module>
main()
File "libcloud_rest/server.py", line 97, in main
logger=logger, debug=options.debug)
File "libcloud_rest/server.py", line 19, in start_server
from libcloud_rest.application import LibcloudRestApp
File "/home/rranjan/.virtualenvs/libREST/lib/python2.7/site-packages/libcloud_rest-0.0.1-py2.7.egg/libcloud_rest/application.py", line 7, in <module>
from libcloud_rest.api.urls import urls
@fluffybeing
fluffybeing / parinx
Created March 24, 2014 16:30
conversation
<Jc2k> does parinx cache anything? the thought of constantly parsing docstrings in an app isnt a pleasant one.
* rocker has quit (Ping timeout: 246 seconds)
<rahulrrixe> Jc2k : I didn't notice the message early :(
<Jc2k> its ok :)
<rahulrrixe> Jc2k : no there is no caching in parinx
<rahulrrixe> can you suggest me how can i implement this feature
<Jc2k> rahulrrixe: perhaps if you had a Parser class so that the API looked like this:
<Jc2k> from parinx.parser import Parser
<Jc2k> parser = Parser()
<Jc2k> p.get_method_docstring(a_method)
@fluffybeing
fluffybeing / libcloud REPL
Created March 26, 2014 15:47
IRC chat on libcloud REPL
<rahulrrixe> Jc2k : I have one question \0/
<rahulrrixe> I am trying to build a repl for apache libcloud so that a user can execute the libcloud code online
<rahulrrixe> but these code will be executed on server so security is important thing
<Jc2k> Daemoen: it was added to pycrypto git in Feb 2011
<rahulrrixe> so what should i use pysandbox or restricted python for safe execution?
<Jc2k> Daemoen: looks like it was first in pycrypto 2.5
<Daemoen> Jc2k: yeah... found that python-crypto on el6 is *wayyyyy* behind
<Daemoen> 2.0.1
<Jc2k> Daemoen: welcome to el6 :)
<Jc2k> you are probably going to have to put evverrything in virtualenv to have a chance with that thing..
@fluffybeing
fluffybeing / PYPY
Created March 27, 2014 08:22
Run untrusted Python code in secure environment
One option might be to use PyPy to create a sandboxed python. It would limit the external operations someone could do.
Once you have that set up, your website would take the code source, send it over ajax to your webserver, and the server would run the code in a subprocess of a sandboxed python instance. You would also be able to kill the process if it took longer than say 5 seconds. Then you return the output back as a response to the client.
See these links for help on a PyPy sandbox:
http://doc.pypy.org/en/latest/sandbox.html
http://readevalprint.com/blog/python-sandbox-with-pypy.html
5139 pts/0 T 0:00 sudo docker search ubuntu
5140 pts/0 Tl 0:00 docker search ubuntu
5312 pts/0 S 0:00 sudo HTTP_PROXY=http://172.31.1.4:8080/ docker -d
5316 pts/0 Sl 0:00 docker -d
6801 pts/0 S+ 0:00 grep --color=auto docker
@fluffybeing
fluffybeing / libcloud-click
Created May 4, 2014 21:40
Click Command line app
import click
@click.group()
@click.pass_context
def cli(ctx):
pass
@cli.command()
import click
@click.group()
@click.pass_context
def cli(ctx):
pass
@cli.command(cls=click.Group)
@fluffybeing
fluffybeing / diff
Created May 5, 2014 17:31
Cliff vs Click
rahulrrixe> rest if we compare cliff and click, then click is better
<rahulrrixe> as use of decorator make it very suitable for CLI which we want to developemnt
<rahulrrixe> **develop
<rahulrrixe> in our case we need to have config file parser and click handles that very well and .ini is custom to it
<rahulrrixe> also it support context
<rahulrrixe> i don't know much about it but what i have understood through documentation is that like we have <api><resource><action>
<rahulrrixe> resource is child for api and if we want to pass the information of api we can do through context
<rahulrrixe> it is useful because we want if a user had made connection then it should be stored in object
* rdodev (~rdodev@2001:4802:7801:103:18ba:c153:ff20:563f) has joined #libcloud
<rahulrrixe> not every request makes a new connection
@fluffybeing
fluffybeing / subcomands
Created May 13, 2014 10:40
python-cliff subcommands
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Cliff sample app
~~~~~~~~~~~~~~~~
"""
import os
import sys
import logging