[How To] [LXDE] Fix lxrandr not working
in case you switch from traditional harddisk to SSD and your computer boot very fast that makes xrandr run too fast and makes it not work every time. you should
1. Edit the autostart file
vim ~/.config/autostart/lxrandr-autostart.desktop
2. Add some sleep before xrandr
[Desktop Entry]
Type=Application
Name=LXRandR autostart
Comment=Start xrandr with settings done in LXRandR
Exec=sh -c 'sleep 2 && xrandr --output VGA1 --mode 1920x1080 --same-as LVDS1 --output LVDS1 --off'
OnlyShowIn=LXDE
3. restart X and done
Technical Memory
Just a place that place that stored what I have learn
2018年7月23日 星期一
2018年5月15日 星期二
[How To] install adblock in openwrt or LEDE
As we know some of the wireless devices cannnot install adblock plugin such as iphone and iPad. We can modify our routers to add adblock in our open source routers.
So how to do it:
The following packages is needed:
1. adblock (the adblock package)
2. libustream-mbedtls (For https download using uclient-fetch)
3. luci-app-adblock (in case for luci interface)
#opkg install adblock libustream-mbedtls luci-app-adblock
After installation, you need some configuration. For luci, you can find the configuration in homepage-> "Service" Tab -> "Adblock"
enable the host that you need to.
for command line configuration
you need to: (I come from Hong Kong, so I block the reg_cn)
#/etc/init.d/adblock enable
#/etc/init.d/adblock start
#uci set adblock.global.enabled='1'
#uci set adblock.reg_cn.enabled='1'
#uci commit
To verify correct installation
In the log tab in Adblock luci page:
Tue May 15 14:25:18 2018 user.info adblock-[3.4.3]: blocklist with overall 29670 domains loaded successfully (NETGEAR WNDR3700v4, LEDE XXXXX)
or the same line shown in command line
#logread |grep adblock
from client side, try ping "analytics.google.com"
$ ping analytics.google.com
ping: analytics.google.com: Name or service not known
Conclusion
This adblock is not as good as the browser plugin one as it just block the advertisment hosts. But at least your private information will not be sent to those ad servers.
Cheers
So how to do it:
The following packages is needed:
1. adblock (the adblock package)
2. libustream-mbedtls (For https download using uclient-fetch)
3. luci-app-adblock (in case for luci interface)
#opkg install adblock libustream-mbedtls luci-app-adblock
After installation, you need some configuration. For luci, you can find the configuration in homepage-> "Service" Tab -> "Adblock"
enable the host that you need to.
for command line configuration
you need to: (I come from Hong Kong, so I block the reg_cn)
#/etc/init.d/adblock enable
#/etc/init.d/adblock start
#uci set adblock.global.enabled='1'
#uci set adblock.reg_cn.enabled='1'
#uci commit
To verify correct installation
In the log tab in Adblock luci page:
Tue May 15 14:25:18 2018 user.info adblock-[3.4.3]: blocklist with overall 29670 domains loaded successfully (NETGEAR WNDR3700v4, LEDE XXXXX)
or the same line shown in command line
#logread |grep adblock
from client side, try ping "analytics.google.com"
$ ping analytics.google.com
ping: analytics.google.com: Name or service not known
Conclusion
This adblock is not as good as the browser plugin one as it just block the advertisment hosts. But at least your private information will not be sent to those ad servers.
Cheers
2015年12月20日 星期日
[How to] Setup Samba in Linux
Let see my setup environment:
Server:
- Arch Linux 4.2.5-1-ARCH
- samba Version 4.3.3
Client:
Same as server
Network Setup:
Internet - Server(192.168.1) - Router(192.168.2) - Clients
= = =
Setup procedure:
1. Installation: (For both server and client)
#pacman -Syu samba
2. Setup config
I have made a config file to share the server /tmp folder and allow only me and home subnet only.
= = =
[global]
workgroup = WORKGROUP
server string = Samba Server
hosts allow = 192.168.1. 127.
printcap name = /etc/printcap
load printers = yes
log file = /var/log/samba/%m.log
max log size = 50
security = user
dns proxy = no
invalid users = nobody root
map to guest = Bad User
max connections = 10
[homes]
comment = Home Directories
browseable = no
writable = yes
[tmp]
comment = Temporary file space
path = /tmp
valid users = your_user
public = no
writable = yes
= = =
Configure your user to samba, and enter the user password.
#pdbedit -a -u your_user
3. Run
In server:
#systemctl enable smbd.service
If you also need netbios support:
#systemctl enable nmbd.service
Server side should be more or less ready and change to Client
Client:
Just test the samba connection to the server
user@localhost:~$ smbclient -L 192.168.1.1 -U your_user
smbclient: Can't load /etc/samba/smb.conf - run testparm to debug it
Enter your_user's password:
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.3]
Sharename Type Comment
--------- ---- -------
tmp Disk Temporary file space
IPC$ IPC IPC Service (Samba Server)
your_user Disk Home Directories
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.3]
Server Comment
--------- -------
LOCALHOST Samba Server
Workgroup Master
--------- -------
WORKGROUP LOCALHOST
If you see similar output, the connection should be ready and you can mount remote samba drive
#mount -t cifs //LOCALHOST/tmp /mnt -o user=your_user,workgroup=WORKGROUP,ip=192.168.1.1
password:
Nice and Done!!
Server:
- Arch Linux 4.2.5-1-ARCH
- samba Version 4.3.3
Client:
Same as server
Network Setup:
Internet - Server(192.168.1) - Router(192.168.2) - Clients
= = =
Setup procedure:
1. Installation: (For both server and client)
#pacman -Syu samba
2. Setup config
I have made a config file to share the server /tmp folder and allow only me and home subnet only.
= = =
[global]
workgroup = WORKGROUP
server string = Samba Server
hosts allow = 192.168.1. 127.
printcap name = /etc/printcap
load printers = yes
log file = /var/log/samba/%m.log
max log size = 50
security = user
dns proxy = no
invalid users = nobody root
map to guest = Bad User
max connections = 10
[homes]
comment = Home Directories
browseable = no
writable = yes
[tmp]
comment = Temporary file space
path = /tmp
valid users = your_user
public = no
writable = yes
= = =
Configure your user to samba, and enter the user password.
#pdbedit -a -u your_user
3. Run
In server:
#systemctl enable smbd.service
If you also need netbios support:
#systemctl enable nmbd.service
Server side should be more or less ready and change to Client
Client:
Just test the samba connection to the server
user@localhost:~$ smbclient -L 192.168.1.1 -U your_user
smbclient: Can't load /etc/samba/smb.conf - run testparm to debug it
Enter your_user's password:
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.3]
Sharename Type Comment
--------- ---- -------
tmp Disk Temporary file space
IPC$ IPC IPC Service (Samba Server)
your_user Disk Home Directories
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.3]
Server Comment
--------- -------
LOCALHOST Samba Server
Workgroup Master
--------- -------
WORKGROUP LOCALHOST
If you see similar output, the connection should be ready and you can mount remote samba drive
#mount -t cifs //LOCALHOST/tmp /mnt -o user=your_user,workgroup=WORKGROUP,ip=192.168.1.1
password:
Nice and Done!!
2015年12月16日 星期三
[How To] Fix Tearing on Linux Intel Graphics
#cat /etc/X11/xorg.conf.d/20-intel.conf
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "TearFree" "true"
EndSection
Works well on my arch linux machine. No tearing now in watching One Punch Man~ Cheers
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "TearFree" "true"
EndSection
Works well on my arch linux machine. No tearing now in watching One Punch Man~ Cheers
2015年12月15日 星期二
rsync - a simple backup command
If you want to backup something just use the following command
$rsync -au /source/path/* /dest/path/folder
In case after some days your source path have new files or some changes, just recall the command and it can simply update the destination folder to sync everything.
$rsync -au /source/path/* /dest/path/folder
In case after some days your source path have new files or some changes, just recall the command and it can simply update the destination folder to sync everything.
2015年10月23日 星期五
Alexa - a web page to show how pofitable of a web page
Alexa - http://www.alexa.com/
In internet point of view, browsing count means profit. This page can show the ranking of amount of access of a page. That is for simply, how profitable for the page is and the efficiency of putting advertisement there.
2015年10月2日 星期五
How To Download content in Python using urllib2 with example
I am working on a project that needs to download content from web and parse it's data in Python. I have done some modules which is useful in downloading stuff. Or I just share the source code.
= = =
#!/usr/bin/python2 import time import urllib2 __user_agent = "Mozilla/5.0 (Windows NT 5.1; rv:40.0) Gecko/20100101 Firefox/40.0" def url_req(url, cookie=None, max_retry=3, retry_wait_s=5): r_html = None retry = 0 while 1 : if (retry == max_retry): break data_req = urllib2.Request(url) #cookie support data_req.add_header('User-Agent', __user_agent) if cookie is not None: data_req.add_header('Cookie', cookie) try: data_handler = urllib2.urlopen(data_req) except urllib2.URLError as e: print (e.reason) time.sleep(retry_wait_s) retry = retry+1 continue except: pass time.sleep(retry_wait_s) retry = retry+1 continue try: r_html = data_handler.read() except urllib2.URLError as e: print (e.reason) time.sleep(retry_wait_s) retry = retry+1 r_html = None continue break return r_html
訂閱:
文章 (Atom)