Skip to content

Instantly share code, notes, and snippets.

@The-Yoda
The-Yoda / StaticIp
Last active December 15, 2015 01:28
Setting static ip in Ubuntu
edit etc/network/interfaces
if "iface eth0 inet dhcp" line exists change dhcp to static
else add that line "iface eth0 inet static"
iface eth0 inet static
address 10.0.0.1
netmask 255.255.255.0
gateway 10.0.0.2
broadcast 192.168.1.255
@The-Yoda
The-Yoda / gist:5316791
Created April 5, 2013 05:11
Android Async http connection sample code
class GetJSONFromUrl extends AsyncTask<String, Void, RSSFeed> {
InputStream is = null;
String result = "";
String error_text="";
JSONObject j = null;
protected void doInBackground(String... urls) {
// http post
@The-Yoda
The-Yoda / SoftwaresToBeInstalledInUbuntu
Last active December 18, 2015 21:38
Softwares to be installed after reinstalling ubuntu
If you are gonna use same version of ubuntu, before installing take backup of software names using :
dpkg --get-selections > installed-software
After installing use following commands:
dpkg --set-selections < installed-softwares
apt-get -u dselect-upgrade
Installing java :
openjdk-7-jdk
or for sun java,
@The-Yoda
The-Yoda / gist:6350172
Created August 27, 2013 06:12
To remove errors because of constants in phpunit
public function prepareTemplate( Text_Template $template ) {
$template->setVar( array(
'constants' => '',
'zz_constants' => PHPUnit_Util_GlobalState::getConstantsAsString()
));
parent::prepareTemplate( $template );
}
@The-Yoda
The-Yoda / Method names
Created November 9, 2013 05:33
Scala: Getting method names of a class
//obj is object of a class
var params : Array[String] = obj.getClass.getMethods.map(_.getName)
var j : Int = 0
while ({j < params.length}){
println(params(j))
j = j + 1
}
@The-Yoda
The-Yoda / hotspot
Created November 9, 2013 05:37
Creating hotspot in ubuntu 12.04
/etc/hostapd/hostapd.conf
interface=wlan1
driver=nl80211
ssid=hotspot
hw_mode=g
channel=1
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
@The-Yoda
The-Yoda / Rooting-vlc-evince
Created November 9, 2013 13:37
Opening vlc and evince (document reader) as root
Opening evince as root :
sudo ln -s /etc/apparmor.d/usr.bin.evince /etc/apparmor.d/disable
sudo /etc/init.d/apparmor restart
opening vlc as root :
change geteuid to getppid in /usr/bin/vlc
@The-Yoda
The-Yoda / Important-files-to-backup
Last active December 27, 2015 20:39
Files to backup before reinstalling ubuntu
In ~/
.bashrc
.bash_history
In gnome
with more plugins, .local/share/gnome-shell
app preferences(terminal key bindings, etc), .gconf
.viminfo
.vim_rc
.mozilla
@The-Yoda
The-Yoda / bash_aliases
Created November 11, 2013 09:14
Aliases for bash
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
for f in `find . -name "*.dust"`;do sed -i.bkp "s/label=\"{@pre editable=\"false\"/label=\"{@pre encode=\"true\"/" $f; done
for file in `find ./ -name "*.bak"`; do rm $file; done;