GithubHelp home page GithubHelp logo

hackr's Introduction

hackr: Unicorn library for Hackathons

An All-in-one library, safe for hackathon consumption.

You can perform every task using a single library.

hackr currently supports the following features:

  • Generate random names
  • Generate random address
  • Generate random dates
  • Generate random digits
  • Generate random characters
  • Generate QRCode
  • Scrape any webpage
  • Send web requests (GET, POST, PUT)
  • Parse data in JSON
  • Send Emails

hackr officially supports Python 2.7 currently.

pip install hackr

Generate Random names

>>> import hackr
>>> a = hackr.generator.names(5)
>>> print a
[u'Mr. Thomas Wolf MD', u'Valerie Turner', u'Maria Knight', u'Raymond Shelton', u'Erica Glenn']

Generate Random dates

>>> import hackr
>>> a= hackr.generator.dates(5,1995,2017)
>>> print a
['1998-08-17 00:00:00', '2007-03-25 00:00:00', '2003-01-27 00:00:00', '2014-10-13 00:00:00', '1995-02-10 00:00:00']

Generate Random json data

>>> import hackr
>>> a = hackr.object_generator.generate_json(4, name='names', address='address')
>>> print a
'[{"name": "Jeffery Russell", "address": "USNV Bradley\\nFPO AA 49483-3369"}, {"name": "Caitlin Wong", "address": "4622 Richard Summit Apt. 325\\nHollow
aystad, OH 88464"}, {"name": "Adrian Pugh", "address": "977 Hill Meadows Suite 944\\nVictoriaton, PR 58653-2191"}, {"name": "Christopher Schaefer", "add
ress": "62215 Charles Cape Apt. 039\\nHaleymouth, ND 82518-8938"}]'

Generate QRCode

>>> import hackr
>>> # default save to current path
>>> img = hackr.image.qrcode("https://github.com/pytorn/hackr")
>>> # or manually assign dest path
>>> img = hackr.image.qrcode("https://github.com/pytorn/hackr", dest_path="/tmp/hackr_qrcode.png")

Scrape a webpage

>>> import hackr
>>>#To get the response as JSON(if the url returns a JSON response, otherwise an exception is returned)
>>> json_response = hackr.web.scrape("https://api.github.com/users/ashwini0529", type="json")
>>>#To get the response as XML
>>> xml_response = hackr.web.scrape("https://api.github.com/users/ashwini0529", type="xml")
>>> #To scrape all images of a webpage(although the function will have limitations in case of dynamically generated content)
>>> scrape("https://github.com/", type="json", images=True) # All the images from the webpage will be saved in a folder named images inside a folder named as the URL.

Make Web Requests

>>> import hackr
>>> #If you want the response as a string
>>> a= hackr.web.request("http://httpbin.org/post", method="post", params={'a':'b'})
>>> If you want the response as JSON
>>> a= hackr.web.request("http://httpbin.org/post", method="post", params={'a':'b'}, type="JSON")

Send Emails

>>> import hackr
>>> #Enter your GMAIL email address and password in the parameters email, and password.
>>> hackr.actions.email("Hey there", email="[email protected]", password="foobar", to="[email protected]", subject="Foo Bar")

IP Tools

>>> import hackr
>>> hackr.iptools.getLiveIP()
'***.***.***.***'
>>> hackr.iptools.getPrivateIP()
'192.168.1.8'

Cryptography

>>> import hackr
>>> e = hackr.crypto.Encrypt('hackr')
>>> e.sha1()
'0cbb7cc60b77fe81355c3b116837a5e50b747311'
>>> d = hackr.crypto.Decrypt('0cbb7cc60b77fe81355c3b116837a5e50b747311','dict.txt')
>>> d.sha1()
hackr

Cryptocurrencies

>>> import hackr
>>> hackr.crypto.Currency(1).convert('btc','eth')
32.16
>>> c = hackr.crypto.Currency(1)
>>> c.convert('btc','eth')
32.16
>>> c.coin = 'btc'
>>> c.to('eth')
32.16
>>> c.value = 2
>>> c.to('eth')
64.32
  • Fork the repository
  • Find an issue or create one
  • Create a branch(we prefer to name it patch)
  • Inform everyone that you're working on the issue
  • Send a pull request with proper explanation of what you did
  • Wait for getting it reviewed.
  • We'd be glad to merge your PR

Our Awesome Contributors

Made with โ™ฅ by: PyTorn

hackr's People

Contributors

akshitgrover avatar alanfgn avatar anishsujanani avatar ashwini0529 avatar ba11b0y avatar gugsrs avatar hanksudo avatar miguel550 avatar ncrispi avatar pseudoaj avatar rosdyana avatar samuelrey avatar shubhodeep9 avatar theycallmemac avatar vi3k6i5 avatar willboyd8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hackr's Issues

TDD, a resolution

Hey guys,

As a maintainer of the organisation, I would like us to implement Test-Driven approach for development of every module hereafter.
Plus, let's write best-fit tests for existing code base.

This issue will be closed once this has been included in the CONTRIBUTING.md

Cheers

hackr doesn't load properly

I get the following error when I try to import hackr:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-59166352ef8e> in <module>()
----> 1 import hackr

~/anaconda3/lib/python3.6/site-packages/hackr/__init__.py in <module>()
      4 
      5 from . import generator
----> 6 from . import object_generator
      7 from . import web
      8 from . import actions

~/anaconda3/lib/python3.6/site-packages/hackr/object_generator.py in <module>()
      1 import json
----> 2 import generator
      3 
      4 
      5 def generate_json(count, **kwargs):
ModuleNotFoundError: No module named 'generator'

this commit fixed the issue, but the pip package wasn't updated.

Don't pin dependency version in requirments.txt

From https://packaging.python.org/discussions/install-requires-vs-requirements/#install-requires

It is not considered best practice to use install_requires to pin dependencies to specific versions, or to specify sub-dependencies (i.e. dependencies of your dependencies). This is overly-restrictive, and prevents the user from gaining the benefit of dependency upgrades.

So requirements can look like:

Faker>=0.8.4, <0.9
requests>=2.18.4, <2.19

It's just a best practice and not a necessity so feel free to close the issue if you don't see problem with current file ๐Ÿ‘

[FEATURE] Integrate third party libraries

There're lot of libraries that can be implemented in hackr. Although, I would suggest to not to use heavy libraries, but yeah, adding features is what is needed!

Under this issue, anyone can come up with any feature request and send a PR.

The main aim is to add more features. Once you start working on a feature, just comment it down and mark your PR in WIP until it's completed.

Happy hacking!

error to generate random json data

>>> import hackr
>>> a = hackr.object_generator.generate_json(4, name='names', address='address')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'object_generator'

Because missing import on init.py, I would like to fix this.

fetching crypto values

Maybe we could extend the support for getting crypto values?
Something like hackr.crypto.convert('eth','usd') would fetch the current eth to usd?

Implement cryptography functions

Many times, you need your data to be encrypted. One possible aspect could be implementing blockchain in your hackathon project.
It would be great if we could implement encryption related functionalities in the library.

Few things that could be taken care of

  • encryption (bcrypt, md5, hashing algorithms)
  • decryption

Plotting graphs and store it in a given path

To develop a function that allows to plot a graph providing the coordinates, and labels.

For example:

graph=hackr.plot.bar({"a":15,"b":10,"c":50}, xlabel=year, ylabel=issues)
graph.save('/path/to/save/')

The above code snippet would plot a graph with the provided coordinates and would save it in the mentioned path.

Extending the web scraper.

There hasn't been much work on the web scraping part.
I am interested to work on this.
Since this is going to be a generic one, what I have thought as of now includes:

  1. A generic web scraper which scrapes all images, links and the text.
  2. Use scrapy for this maybe.

Still a beginner, any tips or corrections?

Write tests

No tests have been written as of now. Writing tests would be very helpful.

Image Encoding

Handling images is a tedious task but a common one. Maybe we can create functionality to encode and decode images to base64.

QRCode generator

It's good to have a QRCode generator for hackr

Ex:

import hackr
# default save to current path
img = hackr.generator.qrcode("https://github.com/pytorn/hackr")
# or manually assign dest path
img = hackr.generator.qrcode("https://github.com/pytorn/hackr", dest_path="/tmp/hackr_qrcode.png")

Feature list

  • Generate dataset (CSV,XLS,TXT) of random numbers
  • Scrape a web page and perform operations like beautify, json() etc
  • Populate random locations lat, long
  • Populate countries, states, cities
  • Populate names dataset (Indian, American etc)
  • Perform mathematical operations
  • Create JSON files with given fields
  • Send Emails using SMTP

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.