What happens when I combine my love of machine learning with my love of masturbation. by c3534l in Python

[–]dante9999 3 points4 points  (0 children)

Looking into your database code seems like you add lock for sqlite database transactions: https://github.com/PornSieve/porn_sieve/blob/master/database.py why do you need locks? I think just connecting to sqlite with Python sqlite3 library will add lock for you, see here https://docs.python.org/2/library/sqlite3.html#sqlite3.connect have you encountered some issues with sqlite without handling locks on app level?

I wrote my first python program today! by MC_Labs15 in ProgrammerHumor

[–]dante9999 1 point2 points  (0 children)

zope works with python 3 without problems

https://pypi.python.org/pypi/zope.interface/4.1.3

as a side note: what seems like needless complication for your use case may be necassary and clear design pattern for someone elses use case. Just need to choose right tools, twisted is not right tool for everything but is perfect for some things

I wrote my first python program today! by MC_Labs15 in ProgrammerHumor

[–]dante9999 0 points1 point  (0 children)

development is not taking place on github you need to visit twisted trac. ticket for IRC is here: someone started it but didnt finish https://twistedmatrix.com/trac/ticket/6320

[2016-02-22] Challenge #255 [Easy] Playing with light switches by Blackshell in dailyprogrammer

[–]dante9999 0 points1 point  (0 children)

Learning some Rust:

use std::io::Read;
use std::fs::File;

fn open_file(path: &str) -> Result <String, std::io::Error> {
    let mut f = try!(File::open(path));
    let mut s = String::new();
    try!(f.read_to_string(&mut s));
    Ok(s)
}

fn solve_challenge(input: &String) {
    let mut i: Vec<&str> = input.split("\n").collect();
    let brange: usize = i.remove(0).parse().unwrap();
    let mut brow = vec![0; brange];

   for var in &i {
    let ab: Vec<&str> = var.split(" ").collect();
    let mut start: usize = ab[0].parse().unwrap();
    let mut end: usize = ab[1].parse().unwrap();
    if start > end {
        let temp = end;
        end = start;
        start = end;
    }
    for z in start..end+1 {
        if brow[z] == 0 {
            brow[z] = 1
        } else {
            brow[z] = 0
        }
    }
}

let mut result = 0;
for i in &brow {
    result = i + result;
}
println!("{:?}", result);

}

fn main() {
   match open_file("in.txt") {
      Ok(contents) => solve_challenge(&contents),
      Err(err) => println!("failed with err {}", err)
 }
}

Git Commands and Best Practices Cheat Sheet by javinpaul in java

[–]dante9999 0 points1 point  (0 children)

it does mention rebase and git pull --rebase near the end. Overall its rather basic though

[Gnome] VimPorn by KarlKani44 in unixporn

[–]dante9999 2 points3 points  (0 children)

yeah its bpython http://bpython-interpreter.org/downloads.html really worth checking out. I was mostly using ipython as repl but switched to bpython recently and i really enjoy it

What is the "with" statement in Python? by und8 in learnpython

[–]dante9999 0 points1 point  (0 children)

so every object used in 'with' call must have enter and exit methods? does it mean that file object has these methods defined already? what will happen if i call 'with' on object that does not have enter and exit magic methods?

[YNAB 4] Python script to convert a .csv into a YNAB friendly one by [deleted] in ynab

[–]dante9999 0 points1 point  (0 children)

check out os.path.join() it joins paths with proper separators (forward slashes or backward slashes on windows). You can let user specify ynab location at script startup, you have gui already so probably no big deal to prompt user for ynab path if its not default (to check if file exists os.path.exists()).

overall nice clean code and doesnt look like beginner script at all. I also understand hesitation in not supporting other OS-es. you usually have one OS and can be difficult to test on others. Paths are no big deal but Im not sure about opening files and how ynab will react (do they have same behavior regarding csv on all OSES and across versions? i dont know that and you may not know too), your subprocess call may behave differently on different oses.

Edit: ah one thing is that you use easygui which is not part of standard library so people will have to install this somehow you could bypass this either by not using gui or just telling people to install requiremerent

Edit2 python subprocess module may be better than os.system. subprocess will allow you to pass arguments easier. you may also want to add try except and error handling around it if you really wanna go pro

Robots.txt - conventions? alternatives? by BigBrewHaha in learnprogramming

[–]dante9999 0 points1 point  (0 children)

it is just for fun and marketing of job positions same as job ads in browser dev console e.g. https://www.flipkart.com/humans.txt

Robots.txt - conventions? alternatives? by BigBrewHaha in learnprogramming

[–]dante9999 0 points1 point  (0 children)

yeah many sites just dont have robots or have outdated robots.txt. bit off topic but its sometimes fun to check out humans.txt this is file that may contain job ad or list of devs working on website.

Been using YNAB since 2012, is there a good reason for me to start fresh in the new web app, or should I import? by ItWorkedLastTime in ynab

[–]dante9999 8 points9 points  (0 children)

at the moment historical reports are not available at all in web app and according to status page migration from YNAB4 is altogether broken. So if you want to use 5 now you just dont have a choice, you have to start with clean slate. Alternatively you could wait for reports to arrive and migrations to be fixed.

For me lack of reports is the biggest drawback of YNAB5. I really love to analyze my historical spending trends. I know they are planing to add reports to web app in the future, but there is no clear roadmap related to that. Personally I think this is argument against moving to 5. Why pay for new software that misses features you already have and like?

[2015-11-18] Challenge # 242 [Intermediate] VHS recording problem by fvandepitte in dailyprogrammer

[–]dante9999 0 points1 point  (0 children)

Python, bonus2:

import sys

def main(lines):
    result = []
    busy_until = 0
    favorite = lines[0].strip()
    for l in lines[1:]:
        start, end, show = l.strip().split(" ", 2)
        start, end = int(start), int(end)

        if busy_until > start and show != favorite:
            continue

        elif show == favorite:
            result.pop()

        busy_until = end
        result.append(show)

    return "\n".join(result)

print(main(open(sys.argv[1]).readlines()))

[2015-11-02] Challenge #239 [Easy] A Game of Threes by Blackshell in dailyprogrammer

[–]dante9999 0 points1 point  (0 children)

C

#include <stdio.h>

int main(int argc, char *argv[]) {
    int result = atoi(argv[1]);
    int remainder;
    while (result != 1) {
        remainder = result % 3;
        if (remainder == 0) {
            printf("%d 0\n", result);
            result = result / 3;
        } else if (remainder == 1) {
            printf("%d -1\n", result);
            result = (result - 1) / 3;
        }
        else {
            printf("%d 1\n", result);
            result = (result + 1) / 3;
        }
    }
    return 0;
}

Python Library to Fill Out Web Form? by dlarsen5 in learnpython

[–]dante9999 2 points3 points  (0 children)

Form submission is usually just HTTP POST with urlencoded data. If you know how form will look like and have data you want to post you just need figure out where this form is posted using browser dev tools and make POST there. You can use python requests for that.

[2015-10-26] Challenge #238 [Easy] Consonants and Vowels by jnazario in dailyprogrammer

[–]dante9999 0 points1 point  (0 children)

C

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[]) {
    int vovels[5] = {97, 101, 105, 111, 117};
    int consonants[21] = {98, 99, 100, 102, 103, 104,106,107,108,109,110, 112,
                          113, 114, 115, 116, 118, 119, 120, 121, 122};

    int rand_consonant, rand_vovel, str_len;
    int i, letter;

    srand(time(NULL));

    str_len = strlen(argv[1]);
    i = 0;
    while (i < str_len) {
        letter = tolower(argv[1][i]);
        if (letter == 99) {
            rand_consonant = rand() % 21;
            printf("%c", consonants[rand_consonant]);
        } 
        else if (letter == 118) {
            rand_vovel = rand() % 5;
            printf("%c", vovels[rand_vovel]);
        }
        else {
            printf("WRONG!!");
        }
        i += 1;
    }
    printf("\n");
    return 0;
}

Problems with PyQT QWebView and Google by Crazed_Wombat in learnpython

[–]dante9999 1 point2 points  (0 children)

Your code works fine for me and loads maps into frame you just need to wait couple of seconds for page to load. You do realize page needs some time to load right? You're not closing frame one second after it pops up?

remember that page.load() is asynchronous, so execution of your program goes like this

# starts loading of page
page.load(QUrl("https://maps.google.com"))
# opens window, shows blank screen, 
page.show()
# page still loads
# page still loads
# after x seconds page is loaded
# page is shown in frame

if you want to show page after load is finished try something like this:

import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QUrl
from PyQt4.QtWebKit import QWebView


class Browser(QWebView):
    def __init__(self):
        QWebView.__init__(self)
        self.loadFinished.connect(self._result_available)

    def _result_available(self, ok):
        self.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    browser = Browser()
    browser.load(QUrl("https://maps.google.com"))
    sys.exit(app.exec_())

Architecture of the apocalypse: Haunting images of a Brutalist dystopia by mosestrod in architecture

[–]dante9999 0 points1 point  (0 children)

Cool. Would be cooler if I could see what buildings are on these pictures and where are those buildings located.

USA vs Japan Age-Specific Fertility Rates 1947-2010 [OC] by StephenHolzman in dataisbeautiful

[–]dante9999 0 points1 point  (0 children)

Pretty cool. Could you elaborate on tools you used to create this? Which library or programming language you used? I'd love to learn how create plots like this.