Trying to Live in the Future–ZeroNet

It is always my dream to build a website without a centralized server as servers and VPS are quite expensive, and unstable. Even servers of large companies break down sometimes.So it shows that our current Internet has some problems.Now,I have built a blog based on P2P!This is really cool!

As you can see, it is simple and clean. And P2P tech guaranteed that the site will not down if someone visits. This can decentralize the load of the server to the nodes.

Not Possible!I Met CPU Frequency Dilemma

First of all,kindly remind:I am using an Intel Core i7-6700HQ.So the maximim and minimum frequency is 800MHz-3500MHz(Sure I turned on Turboboost).

Things first make me confused is the CPU freq extension I am using on my Gnome environment.Usually it shows the current frequency which I set as 800MHz-800MHz for power saving.So it usually shows”0.80GHz”.But today,it runs:

Weird!How can that be possible if my CPU’s minimum freq is 800MHz?I cannot figure it out.Then I looked it in the terminal.It again said my CPU’s minimum freq is 800MHz and it is running at 420MHz!Sure the overall performance of my computer is extremely bad at this freq.The animation,I can bearly stand.Even running Chrome costs 30%-50% of my whole CPU.And other CPU option seems not working too.The highest frequency seems to be 2.6GHz although sometimes it runs over it.

Solution?

I did not know why this happen,but the solution is pretty simple:I unplugged the charger,and everything went back to normal.But I am still curious about it.What makes it happen and how we can use it?

Returned to Ubuntu!

It’s nice to see you guys again!Today I finally installed Ubuntu on my laptop!It’s really delightful to see the linux desktop again!

After several days using Windows 10,I really get “too” used to the design.Not ugly,just too “normal”.So I abandoned Windows and return to the GNU family again.Of course I will choose Ubuntu,as I always prefer it.But which branch of Ubuntu?I really got used to Unity desktop,and XFCE,Mate cannot fulfill my desire of a great effect.So yes!I chose Gnome.

The Original Gnome desktop is as ugly as Unity which is before applying themes.So I searched and installed Flat-Plat theme.It supports Material Ripple Effect!And Gnome desktop environment means that I can write widget in JavaScript!I cannot write it yet but I have accumulated some skills.It will be so much fun!

Finally Installed Python,Tensorflow and OpenCV on Windows!

It’s good to see you again!

For some reasons,I have to reinstall my computer from Ubuntu and Windows.You will soon find out what reason it is;-).2017-05-01.png

So that my GRUB cannot function properly on my computer.

Anyway,I installed Windows 10 on my computer.Aftr using Ubuntu’s convenient APT software management system,I find it extremely hard to configure development environment on Windows.2017-05-01 01-38-36 - 副本.png

At last,I configured Python 3.5.2,Tensorflow-gpu and OpenCV on Windows!The difficulty is all because tensorflow only supports Python 3.5.2,OpenCV seems to only support Python 2.7,and I wanted to use Tensorflow and OpenCV together.

The solution is quite simple.I installed an unofficial version of OpenCV which supports Python 3.Problem solved.

Yeah,it is difficult.Thanks to the Ubuntu subsystem,I can run Linux apps on Windows now!

Start Working on the hard Javascript!

Long time no see you guys!I’m glad to write again!

Now since I have to work on a (large?) project,which evolves multiple programming language and a little complex system,my programming language seemed to be a liittle short.As I am going to handle all the website part,I have to learn everything about html,css,javascript,php,mysql,ect.Fortunately,I learned php and mysql quickly,and css does not seem to disturb me.But the javascript part is a little difficult.I knew NOTHING about how to use html in js!Yes,It looks like C and Java,but I still need to put in a lot of effect.

I think a good js should look like this:2017-04-28.png

But my js looks like this.2017-04-28 (1).pngNot talking that Duckduckgo’s js is bad.Yes,I think js should be as simple as it can be,but a good js is very large?Maybe I proved wrong.

So I think I really need to work hard on it for a while.

My Second OpenCV Program–Scanedge

After my first Python-OpenCV program,I then wrote another.I used this program to find an image’s edge.I think it will have more important task later.

I used Sobel to find the edges and made some calculation to make it more accurate.

This is the original image:

testreal.jpg

This is the outfile:

2017-01-27 21-31-45屏幕截图.png

(I failed to manage to printscreen with alt+prtscr)

That looks good!This is even amazing.I think the code still needs some fine tuning so I will make some modifition to the code.That’s exciting!

My First OpenCV program by Python-ImgAutoBin

I have learned Python for half a day and I think I can make something out of python.Then I thought about OpenCV.How about a program that can turn RGB image into black-and-white image?I began working and that is what I have done.

Original Image:

test.jpg

Converted:

testout.jpg

NOTICE:This image is from remartarchive.tumblr.com

And that’s auto!

The code is here:

from PIL import Image
from pylab import *
import cv2
from optparse import OptionParser
from matplotlib import pyplot as plt
import Tkinter
import FileDialog
from lipytools import denoise
isize = 128

parser = OptionParser()

parser.add_option(“-f”, “–file”, dest=”filenm”,
type=”string”,
help=”Select input file”)

parser.add_option(“-d”, “–delta”,
type=”int”, dest=”delta”,
help=”Select delta”)

parser.add_option(“-p”, “–percent”,
type=”float”, dest=”percent”,
help=”Select float”)

(options, args) = parser.parse_args()
filename = options.filenm
percent = options.percent
delta = options.delta

print(“Receiving data.”)
imi2 = Image.open(filename).convert(‘L’)

print(“Compressing data.”)
(x,y) = imi2.size
x_s = isize
y_s = y * x_s / x
im2 = array(imi2)
im4 = 255.0 * (im2/255.0)**2
imi4 = Image.fromarray(im4)
imi4 = imi4.resize((x_s,y_s),Image.ANTIALIAS)
im4 = array(imi4)

# print(“Denoising data.”)
# U,T = denoise(im4,im4)
# figure()
# imshow(im4)
# figure()
# imshow(U)
# show()

print(“Converting data.”)
x=x_s
y=y_s
data=[]
while True:
data.append(int(im4[y-1,x-1]))
if x==0 :
if y==0:
break
else:
x = len(im4[1])
y-=1
else:
x-=1

print(“data accepted.”)

print(“Analoging data.”)
whiter = 0
i=0
while True:
if data.count(i)>whiter:
print(str(i)+” is the whiter”)
whiter = data.count(i)
white = i
if i==255:
break
else:
i+=1
print(str(i) + ” is NOT a whiter”)

height = whiter
j = white

while True:
if data.count(j) < height * percent:
print(str(i) + ” is the blacker”)
black = j
break
else:
print(str(j)+” is NOT a blacker”)
j-=1

print(“Final result:”+str(white)+”,”+str(black))

imcv = cv2.imread(filename)
print(“Image read.”)
grey = cv2.cvtColor(imcv, cv2.COLOR_RGB2GRAY)
print(“Image greyed.”)
_,bin = cv2.threshold(grey,black-delta,255,cv2.THRESH_BINARY)
_,bin2 = cv2.threshold(grey,black,255,cv2.THRESH_BINARY)
print(“Image Bined.”)
contours, hierarchy = cv2.findContours(bin,cv2.RETR_LIST,cv2.CHAIN_APPROX_NONE)
cv2.drawContours(bin2,contours,-1,(0,0,0),1)
print(“Image Bounded.”)

plt.imshow(bin2, cmap = ‘gray’, interpolation = ‘bicubic’)
plt.xticks([]), plt.yticks([])
plt.show()

You need a terminal to run it.

python testautobin.py -f "the file to input" -d "delta" -p "percent"

In fact,that’s a very simple program,and cannot really work out of human.You still need to make some modify.I encourage you to use delta = 50,percent = 0.02.

I have just found out the interesting of OpenCV and Python!I will try to do something more interesting!If you discovered bugs or butterflies,you can contact me!See you guys!

Connect to an Android Device with ADB over TCP

After some days of developing Android programs,I find it a pain to plug and replug the MicroUSB hub from my Xiaomi 4 (Cancro) device.MIUI in Xiaomi does not provide a switch to turn on adb over tcp.So I have to come up with a way to turn on it manually.

After some Duckduckgoes I found just the way to turn on it.Now I am writing it here in order to remind me of this brilliant way.

Be Prepared:Terminal

All you have to do is

su
setprop service.adb.tcp.port 5555
stop adbd
start adbd

That could be better if you write it in a script.

ATTENTION

Notice the first line “su”?That means you need to have root access to your phone.And ADB over TCP will not work after you reboot your device.

And let me show a little off of my XPS 15 with Ubuntu.

Ubuntu Unity and Dash really did something!Numix theme and icon seem to be pretty pretty!