Tag Archives: Programming

Python Editors and Auto Completion

Just tested an editor called “PyCharm”, recommended for its auto-completion feature, and discovered it can’t complete “m= hashlib.sha1()” (it offers hashlib but not sha1)

In fact, it couldn’t auto-complete urllib.open either. Neither can IDLE(Python’s built-in editor).

Looking at https://wiki.python.org/moin/PythonEditors there are tons of editors, am I supposed to try every one of them? LOL

Edit: PyCharm actually completes sha1 from m= hashlib.sha1, but not m.Something(update, digest, etc)

Leave a comment

Filed under Uncategorized

Schizophrenia Roots(Logic)

(From forum.schizophrenia.com)

Suppose that I were to write a program that decided whether something was X, that program would return YES or NO. That program is what computer scientists call a decision function.

Is_Picture_A_Flower(Picture)

So I ask my friends Bob and Joe to also make programs to identify data

Joe makes Is_Picture_A_Rose(Picture) and Bob makes Is_Picture_A_Dog(Picture)

So we have a “parallel process of creating analysis functions”.

However we can’t just add the results statistical significance, for example, I have 10 pictures, 3 of them are flowers and 2 flowers are roses.

I can’t get impressed with getting a positive for roses(20%) if I already got a positive for flowers(making the chance 66%).

That means we need a “process of determining which tests affect which tests”.

I think schizophrenia is caused by the two processes not working well together, you have too many tests for too little knowledge of their interoperability, hence you get lots of false positives(people look like other people, places like other places).

The medicine probably works by slowing down the first process(creation of analysis tools). You could increase the second processes effectivity by being exposed to:
diverse data(not getting obsessed with a single subject/place)
high quality dreaming(ear plugs, country side, nothing happening in the vicinity of the room, long time of dreaming)

The relation between finding patterns and the immune system could explain why schizophrenics also have false positives(signs of infection) in their blood.

If we could find a drug that increased the dreaming phase of sleeping or somehow helped the second process I wrote about we could get closer to a “cure”.

Leave a comment

Filed under Uncategorized

Too much focus

I think what might be hindering my ability to publish a popular product is that I end up being too perfectionist.

For instance, I wanted to make a program that showed an image downloaded from an URL.

Now, instead of just showing it, I decided that I needed to store it so that I didn’t download it every time. Then I realized that two images with the same name would end up overwriting each other so I added a number N if the image of number N-1 already existed, then I realized that adding a number would hinder the user from using that file(because the extension gets modified)… you can see? It’s not that I’m doing things that are not needed, a decent program does everything I just stated, but given that I have only one employee(myself) I should focus on that later.

This is a generalization of that “design first” principle. Do the FUN stuff first. Do the rest later. There is a trade-off, obviously, if you do the FUN stuff first you end up without backwards compatibility. A small price to pay perhaps?

Leave a comment

Filed under Uncategorized

Creating an AxWindowsMediaPlayer programmatically

below Public Class Form1:

Dim AxWindowsMediaPlayer1 As New AxWMPLib.AxWindowsMediaPlayer

 

Inside Form1_Load:

Me.Controls.Add(AxWindowsMediaPlayer1)

AxWindowsMediaPlayer1.Show()

Leave a comment

Filed under Uncategorized

How to draw a hexagram

    Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

        Dim myPen1 As New Pen(New SolidBrush(Color.FromArgb(255, 0, 0, 0)), 10)

        Dim Tri1Point1 As New Point((Me.Width / 2) – Me.Height / 6, (Me.Height / 3) + (Me.Height / 18))
        Dim Tri1Point2 As New Point((Me.Width / 2) + Me.Height / 6, (Me.Height / 3) + (Me.Height / 18))
        Dim Tri1Point3 As New Point((Me.Width / 2), ((Me.Height / 3) * 2) + (Me.Height / 18))

        e.Graphics.DrawPolygon(myPen1, {Tri1Point1, Tri1Point2, Tri1Point3})

        Dim Tri2Point1 As New Point((Me.Width / 2) – Me.Height / 6, ((Me.Height / 3) * 2) – (Me.Height / 18))
        Dim Tri2Point2 As New Point((Me.Width / 2) + Me.Height / 6, ((Me.Height / 3) * 2) – (Me.Height / 18))
        Dim Tri2Point3 As New Point((Me.Width / 2), (Me.Height / 3) – (Me.Height / 18))

        e.Graphics.DrawPolygon(myPen1, {Tri2Point1, Tri2Point2, Tri2Point3})

    End Sub

The code above is Public Domain

Image

Leave a comment

Filed under Uncategorized

VB rocks

When it comes down to GUI and cryptography, but sucks in everything else. I have a huge program and I’m not close to finishing my header-adding program, I would have already finished with few lines in python. Given that most users won’t need to add headers(only “webmasters”) I will move to python for this part. The worst part is that I don’t even know whether VB.net strings are binary-safe. That would easy my life somewhat.

Leave a comment

Filed under Uncategorized

PHP(ish) function for visual studio 2010

Explode function in VB:

 

Private Function phpishExplode(ByVal del As String, ByVal s1 As String)
Dim returnValue As New ArrayList

Dim lastMatchIndex As Integer = 0
For i As Integer = 0 To s1.Count – del.Length
Dim match As Boolean = True
For i2 As Integer = 0 To del.Length – 1

If s1(i + i2) <> del(i2) Then
match = False
Exit For
End If

Next
If match = True Then
returnValue.Add(s1.Substring(lastMatchIndex, i – lastMatchIndex))
lastMatchIndex = i + del.Length

End If
Next
returnValue.Add(s1.Substring(lastMatchIndex, s1.Length – lastMatchIndex))

Return returnValue
End Function

Leave a comment

Filed under Uncategorized

Network Topology

Network topology could be the reason I’m stuck.

Let n1 be the first and only tracker, let n2,n3,n4 and nM be nodes joining after n1,n2,n3..nM-1

Naive Approach(fully connected)

n1
n1-n2
n1-n2-n3,n2-n1-n3,n3-n1-n2
A network with J nodes will have J-1 connections per node. For a maximum of 100(my initial target), that would limit the network size to 101 nodes.

Naive Approach, then Least Connected First
[max connections=2]

n1
n1-n2
n1-n2-n3,n2-n1-n3,n3-n1-n2(next paragraph is Least Connected First)

(tell n1 she(n4) arrived)
n1-n2-n3-TEMPORARY-n4,n2-n1-n3,n3-n1-n2,n4-TEMPORARY-n1(n1 tells n2 that n4 has only 1 connection)
(n2 sees that n1 has 3 connections(counting tmp))
n1-n3-n4,n2-n3-n4,n3-n1-n2,n4-n1-n2

So we have already surpassed a fully connected network number of maximum nodes if connections are capped(at 2)
Now, I need to continue this later and generalize a maximum number of connected nodes if the algo least connected first is used with max connections X (maxNodes= topologyAlgo(MaxConnectionsPerNode))

Leave a comment

Filed under Uncategorized

Regarding my p2p project

Never mind the protocol and difficulty surrounding fixed size buffers, I’m reconsidering the whole project. I need eye candy to get people in or it would flunk. Maybe I should work on other issues I deem as lacking. Pretty much everything related to web(HTML,TCP/IP,JAVASCRIPT,) is disappointing in my opinion. My final goal with that p2p program was to build a platform to serve my analytics in exchange for data/ad-space or even some mean of exchange. Perhaps I should go straightforward to analytics? Hmmm… the HTML replacement I’m thinking about would be faster to build. But not really expansible and I’m afraid it could be construed as illegal.

Leave a comment

Filed under Uncategorized

Finally! Raw Packets from my browser!

https://docs.python.org/2/library/socket.html#example
http://msdn.microsoft.com/en-us/library/ms741621%28VS.85%29.aspx

Two very nice references that allowed me to make a raw server(containing ip and tcp headers) in visual basic

I changed from beginrcv to just receive, but the trick seems to be making the protocol IP(even if the socket is raw)

Dim sockexample2 As Net.Sockets.Socket = New Net.Sockets.Socket(Net.Sockets.AddressFamily.InterNetwork, Net.Sockets.SocketType.Raw, Net.Sockets.ProtocolType.IP)

However, is handling all those packets(from all ports) faster than just allowing the system to do it? And what about my browser sending like 15 or so packets in a single request? Why so many?

The speed issue I’ll probably leave to tomorrow, too complicated, 🙂

Leave a comment

Filed under Uncategorized