Login Register






Small usefull program filter_list
Author
Message
Small usefull program #1
So i was really bored had that idea to code something useful in small lines of code .
I ended up coding a small program to randomly choose a movies from some movies i choose why well it happens a lot to me that i have some movies to watch and can't choose which one to watch first.

Spoiler:
Code:
import java.util.Scanner; import java.util.Random; public class Movies { public static String[] chooseYourMovies(){ Scanner in=new Scanner(System.in); in.useDelimiter("\\n"); System.out.println("how many movies you want to enter :"); String []movies=new String[in.nextInt()]; for(int i=0;i<movies.length;i++){ System.out.println(i); movies[i]=in.next();} return movies;} public static void randomMovie(String[]movies){ Random rand=new Random(); System.out.println(movies[rand.nextInt(movies.length)]);} public static void main(String[] args) { randomMovie(chooseYourMovies()); }}


your turn what can you code something useful in a max of 20 lines ?

[+] 1 user Likes Vi-Sion's post
Reply

RE: Small usefull program #2
20 lines is a lot of freedom if you know how to use it effectively. Run the program with a question mark as the first argument to see the syntax.

Code:
from urllib.parse import unquote from requests import get from sys import argv if argv[1]=='?': print("usage: python projectfinder.py [hot|new] [hour|day|week|month|year|all] [0-100]") exit() def get_settings(): if len(argv)==1: return ['hot','week','5'] return argv[1:].extend(['week','5'][:-(len(argv)-3)]) query=get( "https://www.reddit.com/r/ProgrammingPrompts/{}.json?t={}&limit={}".format(*get_settings()), headers={'user-agent': 'project-picker/0.1.0'} ).json() for c in query['data']['children']: print("\"%s\"\nlink: %s author: %s\n"%(unquote(c['data']['title']),'https://redd.it/'+c['data']['id'],c['data']['author']))
(This post was last modified: 11-23-2016, 10:27 PM by Inori.)
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

[+] 1 user Likes Inori's post
Reply

RE: Small usefull program #3
@Inori if i'm not mistaken your using a library here, that's not what i was looking to see.

Reply

RE: Small usefull program #4
(11-24-2016, 01:15 PM)Vi-Sion Wrote: @Inori if i'm not mistaken your using a library here, that's not what i was looking to see.

I'm using a library for an http request; I could use urllib, which is part of the Python Standard Library, but it's shitty and bulky.
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

[+] 3 users Like Inori's post
Reply

RE: Small usefull program #5
Get public ip in 2 lines of Python:
Code:
import urllib2 urllib2.urlopen("http://icanhazip.com").read().decode("utf-8")
(This post was last modified: 12-01-2016, 12:06 AM by Blink.)


(11-02-2018, 02:51 AM)Skullmeat Wrote: Ok, there no real practical reason for doing this, but that's never stopped me.

[+] 1 user Likes Blink's post
Reply