Saturday, March 23, 2019

Input string

Input value using python 2 and python 3
Example1:
```

# -*- coding: utf-8 -*-
#
import os
#python2.X
a = raw_input("enter your name : ")
print "hell0"+a
os.system("pause")
#python3
#a = input("input:")
#print ("name"+ a) 

Finding string from a file

I would like to share how to some string of a file by using python script.It's just like when we are searching some string from a text file.

Purpose of this script:
The text file contains password of day, in other word, meaning everyday contains different password according to different date.
Example 1:
Prerequisite:
You should obtain a text file which contain many data.

Text File:





Source code
```
#python 2
import sys
substring = raw_input("enter your string (Ex:20180810): ")

count =0  
for line in open('POD_RDKB_10Year.txt'):
    #if ("") in line:
    if substring in line:
 line = line.strip()
        count +=1
        print (line)
if count==0:
    print ("string not found")  

```

```
# python3
import sys
substring = input ("enter your string (Ex:20180810):: ")

count =0  
for line in open('POD_RDKB_10Year.txt'):
    #if ("") in line:
    if substring in line:
       line = line.strip()
 
       count +=1
       print (line)
if count==0:
    print ("string not found")

```

  Output
enter your string (Ex:20180810):: 20180810
20180810        eui7pieralWHvt9p


Example2
If you like to used another way, finding keyword written in source code without input it, please refer this source code as below:

```

# -*- coding: utf-8 -*-
#
import sys

string = "Hello Agnosticdev, I love Tutorials"
substring = "Agnosticdev"

# Straight forward approach for Python 2.7 and Python 3.6
# Executes the conditional statement when the substring is found
if substring in string:
 print ("Your substring was found!")



# Alternative Approach

# Use the find method in Python 2.7 or Python 3.6
if string.find(substring) is not -1:
 print("Python found the substring!")
else:
 print("Python did NOT find the substring!")

``` 

Example3

Search your file and export to a new file

```

#support python2 and 3

def find(substr, infile, outfile):
  with open(infile) as a, open(outfile, 'w') as b:
   for line in a:
    if substr in line:
     b.write(line + '\n')
     print(line + '\n')
 
# Example usage:
find('20181109', 'POD_RDKB_10Year.txt', 'b.txt')

``` 

Wednesday, July 13, 2016

GITHUB(simple)


Introduction of using GITHUB.
This are some of the simple setting or tutorial of using github. I will teach you the most simple command.

I will teach you: 
Push file in, add/ delete single folder, add multiply subdirectory.

I had written a slide, please take a took at it: GITHUB_SIMPLE


1)Create a Project (we called this a repositories )
we have to create an github account first before using this.
Go to your GITHUB webpage and create a new repositories .
We can create file on GITHUB page, but i reccomend used a utiity, which I'll introuce next.

2) Utility Introduce
WHY?????
It'll be really convenient when using a utility. You doesn't have to open web browser and upload your file or create folder. Most of the people coding ir creat a project on their own local laptop or PC. We can just sync from our local to the server by typing a few comment, then that's done.

3) Types of utility
There are three type of platfrom on GITHUB, you cn used either of this.

Window 
Window Desktop Source Tree

Linux
debian/ubuntu:  apt-get install git-core
Fedora/Redhat: yum install git-core

MAC: brew install git

NOTE: In my note I'll just used linux as an example,

4) Set up

your username:
#git config --global user.name "YOUR NAME"
your email:
#git config --global user.email "YOUR EMAIL ADDRESS"

your configure
#git config user.name

5)Clone your repository into your local [command: git clone]

sample: git clone  http//github.com/xxxxx/ooooo. 

 X: your username  
0:your repository name
# under Linux utility, create a directory 
mkdir GITHUB 
# clone repository from server to local and download it. Test is repository
git clone  http//github.com/chenchih/test 

6) Commit/Git push (add a new file) add a file in your local disk. Before Git Push we have to commit first. Every time you modify a file we have to commit; commit is to write description on what you modify to let you know

#go to test and create a file
touch 123456.txt
git commit -m "add file "
git push 

7)Add /delete folder[single]

Add folder
#create new folder 
mkdir testfolder 
#also create folder in gitserver 
add 'testfolder' 
#commit it 
git commit -am "Add testfolder" 
git push 
delete Folder
#delete new folder 
rm -rf testfolder 
#also delete folder in gitserver 
git rm -rf 'testfolder' 
#commit it 
git commit -m "Removed folder from repository"
git push 


8)add entire directory

# go into folder directory 
cd testfolder 
git add *
git commit -m "with the message"
git push

9) other command

Fork: when you coworj with other people, you go to their githib, and press fork
diff: is when you modify the file, you can see what's the different between previous

Reference: 
Setting config: 
https://help.github.com/articles/remembering-your-github-username-or-email/
https://help.github.com/articles/set-up-git/

Chinese tutorial 
http://gogojimmy.net/2012/02/29/git-scenario/

Source tree tutoria Chinese
https://superbil.github.io/slide/sourcetree/#sec-1

Thursday, January 7, 2016

online tools for webdesign planning

online tools for webdesign planning 
1. 14 Useful online tools for webdesign planning and prototyping.
http://www.webdistortion.com/2009/02/22/useful-online-tools-for-easier-website-planning-and-prototyping/

2. 24 Free Mockup and Wireframe Tools for Web Designers
http://www.webdistortion.com/2009/02/22/useful-online-tools-for-easier-website-planning-and-prototyping/

3.Recommend Some cool Site

=>JumpChart
=>RapidRabb.it
==>Writemap

Friday, November 13, 2015

How to create the yum repository

Why do we need to create repository?

The purpose of creating a repository is we wants to install offline. If we don't have an internet connection to external, we unable to download package by yum command. This time we can used local repository, in other word, yum install package from local disk. We have to mount it first, and used yum command it will automatic download from the mount place.

Overall it 's a offline install package. I have provided RHEL 6 and RHEL 7.

------------------------------------RHEL7---------------------------------------


1)Create the new directory and mount the RHEL 7 DVD.
# mkdir /rhel7-repo/ 
# mount /dev/cdrom /rhel7-repo/  
# cd  /rhel7-repo/


2)Navigate to /etc/yum.repos.d/ directory.

3) Create a new file with below contents with extension of “.repo” .


# cat unixarena-rhel7.repo
[rhel7_dvd]
gpgcheck = 0
enabled = 1
baseurl = file:///rhel7-repo
name = unixarena-repo

4) After Modify the file, please yum clean it
[root@UnixArena-RHEL7 yum.repos.d]# yum clean all
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel7_dvd
Cleaning up everything

5)Done

reference: http://www.unixarena.com/2015/04/how-to-create-the-yum-repository-on-rhel-7.html


------------------------------------RHEL6---------------------------------------


1)Create the new directory and mount the RHEL 7 DVD.

# mkdir /dvd/ 
# mount -0 loop /dev/cdrom /dvd
# cd  /dvd/

2)Create a file broexperts.repo  with the following content:
[broexperts]
mediaid=XXXXXX.XXXX   ==> look for mediaid (.diskinfo located in DVD)
name=Local Media Repo
baseurl=file:///dvd/
enabled=1
gpgcheck=0

Find what is our mediaid
#cd /dvd/
#cat .discinfo
xxxxxx.xxx
Red Hat Enterprise Linux 6.0
i386
1
Modify broexperts.repo
# vi /etc/yum.repos.d/broexperts.repo
[broexperts]
mediaid=XXXXXXX.XXXX
name=Local Media Repo
baseurl=file:///dvd/
enabled=1
gpgcheck=0
3. save and exit
reference: https://www.youtube.com/watch?v=NrwDVccKuKw

------------------------------------Let try to see if it work or not---------------------------------------


 yum install httpd

Wednesday, August 26, 2015

DRAC Tools[Dell Sol]

DRAC Tools[Dell Sol]
Dell can used other tool called DRAC.

Tool download as below link:
http://www.dell.com/support/home/us/en/ussoho1/Drivers/DriversDetails?driverid=hr1v5

Open cmd prompt under window and this command can used:

racadm getconfig -g cfgUserAdmin -i 2
racadm config -g cfgUserAdmin -o cfgUserAdminPassword -i 1 newpassword

[by Ip address]
racadm -u root -p calvin -r 192.168.1.1 config -g cfgUserAdmin -o cfgUserAdminPassword -i 1 password

Tuesday, August 25, 2015

SSH

Setup  SSH

SSH is a remote shell prompt that you can access and remote to linux server. You can use tera team, putty or related tool.

Note: Rhel/Centos ssh default is install, you don;t have to open manual.

ubuntu install ssh==>sudo apt-get install sshserver