środa, 7 maja 2014

The easiest way to remove ppa repos from ubuntu

ls /etc/apt/sources.list.d


marek@lati:/etc/apt/sources.list.d$ ll
razem 20
drwxr-xr-x 2 root root 4096 maj  7 10:37 ./
drwxr-xr-x 6 root root 4096 maj  6 11:06 ../
-rw-r--r-- 1 root root  142 maj  7 10:37 mc3man-trusty-media-trusty.list
-rw-r--r-- 1 root root  142 maj  7 10:37 mc3man-trusty-media-trusty.list.save
-rw-r--r-- 1 root root  142 maj  7 10:37 ubuntu-on-rails-ppa-trusty.list




sudo rm -i /etc/apt/sources.list.d/ubuntu-on-rails-ppa-trusty.list

user input in ruby with to_i

#!/usr/bin/ruby

print ('Enter your score: ')
score= gets.to_i //without it you always choose invalid score :)
puts "#{score}"
result = case score
   when 0..40 then "Fail"
   when 41..60 then "Pass"
   when 61..70 then "Pass with Merit"
   when 71..100 then "Pass with Distinction"
   else "Invalid Score"
end

puts result

poniedziałek, 5 maja 2014

Missing message report in sbconsole?

The reports are stored in your Oracle Database.

Schema:[DOMAIN_NAME]_SOAINFRA
Tables:WLI_QS_REPORT_ATTRIBUTE and WLI_QS_REPORT_DATA

piątek, 2 maja 2014

enter anonymous password in mysql connection python

#!/usr/bin/python

import MySQLdb
import getpass

print "---====DB CONNECT====---"

user = raw_input("Enter username: ")
password = getpass.getpass("Enter password: ")
"""password = raw_input("Enter password: ")"""

try:
    db = MySQLdb.connect("localhost",user,password,"mysql")
    if db:
        print "connected"
        cursor = db.cursor()
        cursor.execute("Select version()")
        data = cursor.fetchone()
        print "db version: %s " %data
        db.close()
    else:
        print "error"
       
except MySQLdb.Error, e:
    try:
        print "MySQL Error [%d]: %s" % (e.args[0], e.args[1])
    except IndexError:
        print "MySQL Error: %s" % str(e)

search string in file python

#!/usr/bin/python


try:
    name = raw_input("Enter file name: ")

    f = open(name, "r")
    if os.path.isfile(name):
        searchline = raw_input("enter search phrease: ")
        searchlines = f.readlines()
        for i, line in enumerate(searchlines):
            if searchline in line:
                for l in searchlines[i:i+2]:
                    print l,
                print
except IOError as e:
    print "I/O error ({0}): {1}".format(e.errno, e.strerror)

request pers second apache

tail -f access.log|perl -e 'while (<>) {$l++;if (time > $e) {$e=time;print "$l\n";$l=0}}'

czwartek, 1 maja 2014

very very basic swing java app

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class App
{
    public static void main(String[] args)
    {
        //Swing Thread
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                //main window
                JFrame frame = new JFrame("jMdev");
                frame.setSize(500,400);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });

    }
}