Sunday, September 30, 2012

Project Euler Problem 357

Lame Brute Force 103secs @ 3,3ghz
import primefacmodule as pfm, math
def divp(n):
 a=[]
 if pfm.isprime(n+1)==True and pfm.isprime(n/2+(n/(n/2)))==True:
  for x in xrange(2,int(math.sqrt(n))+1):
   if n%x==0:
    if pfm.isprime(x+(n/x))==True:
     a.append(x)
    else: 
     return False
  
  for x in xrange(0,len(a)): #check other divisors
   z=(n/a[x])+(n/(n/a[x]))
   if pfm.isprime(z)==True:
    pass
   else:
    return False
  return True # every divisor brings a prime
 else:
  return False

l=[1,6]
p=pfm.primesbelow(100000000) # numbers are prime-1

for x in p:
 b=int(str(x-1)[::-1][::len(str(x-1))]) #last digit
 if b==0 or b==2 or b==8:
  if divp(x-1)==True:
   l.append(x-1)

print sum(l)

The difference between UNIX, BSD and Linux


Unix (officially trademarked as UNIX, sometimes also written as Unix) is a multitaskingmulti-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken ThompsonDennis RitchieBrian KernighanDouglas McIlroyMichael Lesk and Joe Ossanna.

Berkeley Software Distribution (BSD, sometimes called Berkeley Unix) is a Unix operating system derivative developed and distributed by the Computer Systems Research Group (CSRG) of the University of California, Berkeley, from 1977 to 1995. Today the term "BSD" is often used non-specifically to refer to any of the BSD descendants which together form a branch of the family of Unix-like operating systems.

Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of Linux is the Linux kernel, an operating system kernel first released 5 October 1991 by Linus Torvalds.

Unix-like (sometimes referred to as UN*X or *nixoperating system is one that behaves in a manner similar to a Unixsystem, while not necessarily conforming to or being certified to any version of the Single UNIX Specification.



Thursday, September 27, 2012

atoms with consciousness




There are the rushing waves...
mountains of molecules,
each stupidly minding its own business...
trillions apart
...yet forming white surf in unison.

Ages on ages...
before any eyes could see...
year after year...
thunderously pounding the shore as now.
For whom, for what?
...on a dead planet
with no life to entertain.
Never at rest...
tortured by energy...
wasted prodigiously by the sun...
poured into space.
A mite makes the sea roar.
Deep in the sea,
all molecules repeat
the patterns of another
till complex new ones are formed.
They make others like themselves...
and a new dance starts.
Growing in size and complexity...
living things,
masses of atoms,
DNA, protein...
dancing a pattern ever more intricate.

Out of the cradle
onto dry land...
here it is standing...
atoms with consciousness
...matter with curiosity.

Stands at the sea...
wonders at wondering... I...
a universe of atoms...
an atom in the universe.

"The Value of Science," address to the National Academy of Sciences (Autumn 1955) by Richard Feynman

Monday, September 24, 2012

Stop using Windows Server - It SUCKZ!

Guess why only 2 out of the Top 500 Super Computers use Windows? Guess why every major company uses UNIX or Linux servers?

Here are 5 reasons:


1. Stability

Linux systems are well known for their ability to run for years without failure. In fact, many Linux users have never seen a crash. That's great for users of every kind, but it's particularly valuable for small and medium-sized businesses, for which downtime can have disastrous consequences.

Linux also handles a large number of processes running at once much better than Windows does, that's something, in fact, that tends to degrade Windows' stability quickly.

Then there's the need for rebooting. Whereas in Windows configuration changes typically require a reboot, causing inevitable downtime, there's generally no need to restart Linux. Almost all Linux configuration changes can be done while the system is running and without affecting unrelated services.

Similarly, whereas Windows servers must often be defragmented frequently, that's all but eliminated on Linux. Let your competitors endure the plentiful downtime that inevitably goes hand-in-hand with Windows, trusty Linux will keep you up and running and serving your customers around the clock.

2. Security

Linux is also innately more secure than Windows is, whether on the server, the desktop or in an embedded environment. That's due largely to the fact that Linux, which is based on Unix, was designed from the start to be a multiuser operating system. Only the administrator, or root user, has administrative privileges, and fewer users and applications have permission to access the kernel or each other. That keeps everything modular and protected.

Of course, Linux also gets attacked less frequently by viruses and malware, and vulnerabilities tend be found and fixed more quickly by its legions of developers and users. Even the six-year-old kernel bug that was recently fixed for instance, an extremely rare instance in the Linux world, had never been exploited.

Internally, meanwhile, users of a Windows system can sometimes hide files from the system administrator. On Linux, however, the sys admin always has a clear view of the file system and is always in control.

3. Hardware

Whereas Windows typically requires frequent hardware upgrades to accommodate its ever-increasing resource demands, Linux is slim, trim, flexible and scalable, and it performs admirably on just about any computer, regardless of processor or machine architecture.

Linux can also be easily reconfigured to include only the services needed for your business's purposes, thus further reducing memory requirements, improving performance and keeping things even simpler.

4. TCO

There's no beating Linux's total cost of ownership, since the software is generally free. Even an enterprise version purchased with corporate support will be cheaper overall than Windows or other proprietary software, which generally involve user-based licensing and a host of expensive add-ons, especially for security.
Same goes for most of the tools and applications that might be used on a Linux server. The overall TCO simply can't be beat.

5. Freedom

With Linux, there is no commercial vendor trying to lock you into certain products or protocols. Instead, you're free to mix and match and choose what works best for your business.

In short, with all the many advantages Linux provides in the server realm, it's no wonder governments, organisations and major companies around the world, including Amazon and Google, rely on the open source operating system in their own production systems.

If you're looking for a Linux distribution to run on your business's servers, you'd do well to consider CentOS (or RHEL, the paid version from Red Hat that CentOS is based on), Slackware, Debian and Gentoo.


Monday, September 17, 2012

Why it is more important to know "how to learn"


Classical education systems have a problem in our fast-paced 21th century. If you start to study Computer Science today and you finish in 3 years, you have not only learned old stuff, you also had not really the time to upgrade to the new things that come day by day. By the time some college graduate finishes and starts to work, many of the things he learned are likely to be not longer important, while a lot of new ones are all the rage. Especially in CS this is the case. Therefore it is more important to know how to learn and how to adapt on a cross-disciplinary spectrum. And what is more valuable for an employer these days? An employee who can solve highly complicated problems in his special field of work, if given the right input, or someone who can take a new problem, identify and describe the key features of the problem and use that to analyze the problem in a precise and practical fashion.We often hear it: "nowadays we need people who can think outside the box, we need cross-disciplinary educated people, we need up2date people".
I will quote Keith Devlin here, he is a Professor for Mathematics at Stanford University. Even though he is talking about mathematics, you can see this as a general statement.


"This new breed of individuals (well, it's not new, I just don't think anyone has shone a spotlight on
them before) will need to have, above all else, a good conceptual (in an operational sense) understanding of mathematics, its power, its scope, when and how it can be applied, and its limitations. They will also have to have a solid mastery of some basic mathematical skills, but that skills mastery does not have to be stellar. A far more important requirement is that they can work well in teams, often cross-disciplinary teams, they can see things in new ways, they can quickly learn and come up to speed on a new technique that seems to be required, and they are very good at adapting old methods to new situations." from KEITH DEVLIN: Introduction to Mathematical Thinking (Fall 2012) BACKGROUND READING

In layman's terms: rather be MacGyver than Stephen Hawking :)

Sunday, September 9, 2012

The Pleasure of Finding Things Out

"I can live with doubt, and uncertainty, and not knowing. I think it's much more interesting to live not knowing than to have answers which might be wrong. I have approximate answers, and possible beliefs, and different degrees of certainty about different things, but I’m not absolutely sure of anything, and in many things I don’t know anything about, such as whether it means anything to ask why we’re here, and what the question might mean. I might think about a little, but if I can’t figure it out, then I go to something else. But I don’t have to know an answer. I don’t feel frightened by not knowing things, by being lost in a mysterious universe without having any purpose, which is the way it really is, as far as I can tell, possibly. It doesn’t frighten me."

from The Pleasure of Finding Things Out : The Best Short Works of Richard Feynman

Friday, September 7, 2012

Project Euler Problem 234

Python  Solution for http://projecteuler.net/problem=234 :

primesbelow(n) = return list of all primes below n

import primefacmodule as pfm
import time

start=time.time()

primes=pfm.primesbelow(1000004)
summe=[]
limit=999966663333
for p in xrange(1,len(primes)):
    l=[]
    x=0
    while (primes[p-1]**2+x*primes[p-1])<primes[p]**2:
        x+=1
        if  (primes[p-1]**2+x*primes[p-1])<primes[p]**2:
            if (primes[p-1]**2+x*primes[p-1])<=limit:
                l.append(primes[p-1]**2+x*primes[p-1])                
    x=0
    while (primes[p]**2-x*primes[p])>primes[p-1]**2:
        x+=1
        if  (primes[p]**2-x*primes[p])>primes[p-1]**2:
            if (primes[p]**2-x*primes[p])<=limit:
                l.append(primes[p]**2-x*primes[p])

    if primes[p-1]*primes[p]>=limit:
        summe.append(sum(l))
    else:
        summe.append(sum(l)-2*primes[p-1]*primes[p])

print sum(summe)
print time.time()-start # print execution time

DIY Power/Noise Filter

How To DIY Dual Power/Noise Filter


  • 1x AC Power Socket
  • 2x Normal Power Sockets
  • Aluminium Case
  • 2x TDK Lambda Noise Filter MXB Series

I use TDK Lambda Noise Filter MXB-1206-33 6A/250V (http://www.tdk-lambda.com/products/sps/nf/mxb/indexe.html). That means 1500W per Filter MAX! More than enough for my PC and Hifi System.
DO NOT forget to earth/ground the case (even if it is anodized)



Wednesday, September 5, 2012

Tuesday, September 4, 2012

The Cryptocat Project

I found something awesome. It's perfect for secure encrypted communication without installing any software. Runs in your browser.

Project Page: https://project.crypto.cat/
Try It!: https://crypto.cat/

How to create a truely secure password which is easy to remember

As you probably already have seen, there are a million tips for how to create a secure password. 99,9% of them are quite useless because they end in some complicated stringchar-mixups.
What is the most important factor in pw security? LENGTH! (espsecially in regards to BruteForce)
"Hello.........................."  is more secure as  "skfjdf3AKJD/("  - Because its longer!
So a secure password does not have to be some complicated stringchar-mix.

My Recipe: 

Use sentences! Why? Because they are long, they have UPPER- and LOWERCASE and most of them end in a symbol or they contain other symbols. Length should not be under 12 chars!
Example: "IloveDouglasAdamsbecausehe'sfuckingawesome" <-- easy to remember and extremely strong because its 42 chars long!
Cracking that by Brute Force with a 100 Trillion guesses/sec would take:

3.49 billion quadruple trillion centuries (Calculation by https://www.grc.com/haystack.htm )

Other Examples:

  • "MyfavouritebookistheC-ReferencebyDennisRitchie"
  • "DreamTheaterandSymphonyXandPinkFloydrockhard!"
  • "Iamtoolazytofindanothercreativepasswordexample" <-- no one would guess that :D
  • "Somewhereovertherainbowbluebirdsfly"
  • "BarneyfromHowIMetYourMotherisAWESOME!"


XKCD approves:

source: http://xkcd.com/936/