Siemens Dishwasher E-01 Error

by Süleyman Petek 18. Ekim 2016 08:54
This is a real life lessons learned issue, if you have a Siemens dishwasher and one day you see that

This is a real life lessons learned issue, if you have a Siemens dishwasher and one day you see that your machine does not work and gives the E-01 error, you first do what the service says to you. I have done also what they suggest. Somehow the problem did not leave me. Then another electricity device in the kitchen gave error ! The root cause was the fuse-box of the home, some cables were slack and because of that some cables were burned. We have get off a big trouble lightly by chance. So this error has gone when we replaced the fuse box... Keep in mind to check your fuse box at home regularly...

Tags: ,

Tip

Parse XML with Python

by Süleyman Petek 10. Haziran 2016 12:12
Here i am again with a small blog post, a life saver small Python script to parse your XML files.I s

Here i am again with a small blog post, a life saver small Python script to parse your XML files.

I suppose you have an XML file like below that you exported from some other tool ;

<schedule>
    <job name="www.mysite.com">
    <job name="www.mysite.com">
    ...
</schedule>

And you want to get all the "name" attribute values from the XML structure, then you can write Java or C Sharp or any other language to parse this file however i think Python is the easiest and the most speed one.

It is as short as below:

import xml.etree.ElementTree
f=open("jobs.txt","w")
e=xml.etree.ElementTree.parse('schedule.xml').getroot()
for atype in e.findall('job'):
f.write(atype.get('name')+"\n")
f.close()

I just create a .txt file here called "jobs.txt" and write all the job names to it.

Enjoy...


Tags: ,

Life Saver | Tip

Spotify Labs Puzzles -Medium- Solution with Java

by Süleyman Petek 9. Mayıs 2016 11:40
import java.util.*;public class SpotifyMedium {&amp;nbsp; &amp;nbsp; public static void main(String[] args)

import java.util.*;


public class SpotifyMedium {


    public static void main(String[] args) {       


        List<String> indata = new ArrayList<String>();


        System.out.println("Please enter the count of played times and name of the song with a one char gap...");

        System.out.println("e.g. 487 LetItBe");

        String line;

        Scanner stdin = new Scanner(System.in);

        while (stdin.hasNextLine() && !(line = stdin.nextLine()).equals("")) {

            String[] tokens = line.split(" ");

            indata.add(tokens[0] + ":" + tokens[1]);

        }


        System.out.println("Please enter the total song to select...");

        int totalSelect = Integer.parseInt(stdin.nextLine());

        stdin.close();


        String[][] songList = new String[indata.size()][3];

        for (int i = 0; i < indata.size(); i++) {

            String[] row = indata.get(i).split(":");

            songList[i][0] = row[0];

            songList[i][1] = row[1];

            songList[i][2] = String.valueOf(i + 1);

        }

    

        String[][] calculatedSongList = new String[songList.length][3];


        for (int i = 0; i < songList.length; i++) {

            for (int j = 0; j < songList[i].length; j++) {

                String zipValue = String.valueOf(ZipsLaw(songList.length, i + 1));

                String qualityValue = String.valueOf(SongQuality(Double.parseDouble(songList[i][0]), Double.parseDouble(zipValue)));

                calculatedSongList[i][j] = songList[i][j] + ":" + qualityValue;

            }

        }


        Arrays.sort(calculatedSongList, new Comparator<String[]>() {

            @Override

            public int compare(final String[] entry1, final String[] entry2) {

                String strObj1[] = entry1[0].split(":");

                String strObj2[] = entry2[0].split(":");

                

                Double obj1 = new Double(strObj1[1]);

                Double obj2 = new Double(strObj2[1]);

                int retval = obj2.compareTo(obj1);

                if (retval > 0) {

                    //System.out.println("obj1 is greater than obj2");

                } else if (retval < 0) {

                    //System.out.println("obj1 is less than obj2");

                } else {

                    //System.out.println("obj1 is equal to obj2");                    

                }

                return retval;

            }

        });


        int total = 0;

        for (final String[] s : calculatedSongList) {

            if (total < totalSelect) {

                System.out.println(s[1].split(":")[0]);

            }

            total++;

        }             

    }


    public static double ZipsLaw(double n, double i) {

        return (n * n) / i;

    }


    public static double SongQuality(double fi, double zi) {

        return fi / zi;

    }


}


Tags: , , , ,

Tech | Tip

Spotify Labs Puzzles -Easy- Solution with Java

by Süleyman Petek 5. Mayıs 2016 17:25
public static void main(String[] args) {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;

public static void main(String[] args) {        

        int yourNumber; 

        Scanner in = new Scanner(System.in);

        System.out.println("Enter your number");

        yourNumber = in.nextInt();        

        

        if (yourNumber < 0) {

            System.out.println("Error: Less then Zero");

        } 

        else 

        { 

            System.out.print("Binary is: ");           

            toBinary(yourNumber);

        }

    }

 

    public static void toBinary(int int1){       

       System.out.println(Integer.toBinaryString(int1));               

       String b = new StringBuffer(Integer.toBinaryString(int1)).reverse().toString();       

       System.out.println("The reverse in binary format is: "+ b);                  

       int decimalValue = Integer.parseInt(b, 2);           

       System.out.println("The reverse decimal is:" +decimalValue); 

   }


For harder ones, please visit https://labs.spotify.com/puzzles/ (:

Tags: , , , , ,

Geyik | Innovation | Tech | Tip

How to call batch files via Python

by Süleyman Petek 10. Mart 2016 17:26
Gentle reminder for me and anyone who needs in the future, say that you have lots of .bat files and

Gentle reminder for me and anyone who needs in the future, say that you have lots of .bat files and you need to call them all.

You can do it via Python like below :


import glob  

import os 

os.chdir('c:\YourBatFiles')  

for filename in glob.iglob('*.bat', recursive=True): 

print(filename)

os.system(filename)


Tags:

Tech | Tip

Cleaning SQL Server Database - Script

by Süleyman Petek 20. Ocak 2016 11:09
Sometimes you work with a database and you may come with a garbage on your database while you are tr

Sometimes you work with a database and you may come with a garbage on your database while you are trying different architectures in your mind. This is usual but when it comes to tidy up the db,sometimes it is hard  to find and delete all assets on db. This is a script that will  save your time, enjoy...


/* Drop all non-system stored procs */

DECLARE @name VARCHAR(128)

DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])


WHILE @name is not null

BEGIN

    SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'

    EXEC (@SQL)

    PRINT 'Dropped Procedure: ' + @name

    SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 AND [name] > @name ORDER BY [name])

END

GO


/* Drop all views */

DECLARE @name VARCHAR(128)

DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 ORDER BY [name])


WHILE @name IS NOT NULL

BEGIN

    SELECT @SQL = 'DROP VIEW [dbo].[' + RTRIM(@name) +']'

    EXEC (@SQL)

    PRINT 'Dropped View: ' + @name

    SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 AND [name] > @name ORDER BY [name])

END

GO


/* Drop all functions */

DECLARE @name VARCHAR(128)

DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 ORDER BY [name])


WHILE @name IS NOT NULL

BEGIN

    SELECT @SQL = 'DROP FUNCTION [dbo].[' + RTRIM(@name) +']'

    EXEC (@SQL)

    PRINT 'Dropped Function: ' + @name

    SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 AND [name] > @name ORDER BY [name])

END

GO


/* Drop all Foreign Key constraints */

DECLARE @name VARCHAR(128)

DECLARE @constraint VARCHAR(254)

DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)


WHILE @name is not null

BEGIN

    SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)

    WHILE @constraint IS NOT NULL

    BEGIN

        SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint) +']'

        EXEC (@SQL)

        PRINT 'Dropped FK Constraint: ' + @constraint + ' on ' + @name

        SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)

    END

SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)

END

GO


/* Drop all Primary Key constraints */

DECLARE @name VARCHAR(128)

DECLARE @constraint VARCHAR(254)

DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)


WHILE @name IS NOT NULL

BEGIN

    SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)

    WHILE @constraint is not null

    BEGIN

        SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint)+']'

        EXEC (@SQL)

        PRINT 'Dropped PK Constraint: ' + @constraint + ' on ' + @name

        SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)

    END

SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)

END

GO


/* Drop all tables */

DECLARE @name VARCHAR(128)

DECLARE @SQL VARCHAR(254)


SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 ORDER BY [name])


WHILE @name IS NOT NULL

BEGIN

    SELECT @SQL = 'DROP TABLE [dbo].[' + RTRIM(@name) +']'

    EXEC (@SQL)

    PRINT 'Dropped Table: ' + @name

    SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 AND [name] > @name ORDER BY [name])

END

GO

Tags:

Life Saver | Tip

Calendar

<<  Ağustos 2018  >>
PztSalÇarPerCumCmtPaz
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

RecentPosts