chkconfig sshd on
list enabled services with:
chkconfig
Source: experts-exchange.com
$ adb devices
List of devices attached
???????????? no permissions
$ su
$ adb kill-server
$ adb start-server
$ adb devices
$ lsusb
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 044: ID 18d1:2d66 <- this is my mobile
Bus 002 Device 004: ID 0451:2046 Texas Instruments, Inc. TUSB2046 Hub
Bus 002 Device 003: ID 10d5:0001 Uni Class Technology Co., Ltd
$ su
$ vim /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", OWNER="%YOUR_USER%" GROUP="%YOUR_USER_GROUP%"
touch -t 11020000 /tmp/stamp_2010-11-02_0000
touch -t 11240000 /tmp/stamp_2010-11-24_0000
find . -regextype posix-awk -regex '^\./PREFIX[0-9]*.txt' -newer /tmp/stamp_2010-11-02_0000 -and -not -newer /tmp/stamp_2010-11-24_0000 -ls
find . -regextype posix-awk -regex '^\./PREFIX[0-9]*.txt' -newer /tmp/stamp_2010-11-02_0000 -and -not -newer /tmp/stamp_2010-11-24_0000 -exec grep --color "123456" {} \; > /tmp/mydata_123456.csv
Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? strings.xml
"%s/%s (Linux; Android)"
"%1$s/%2$s (Linux; Android)"
“never compare floating point numbers for equality”.
The reason (19.6*100) !== (double)1960, is because inside a computer they are not equal.
Try this:
<?php
printf("%.15f", (19.6*100));
?>
Outputs: 1960.000000000000227 (not 1960 as somewhat expected)
If comparison is required a few options come to mind (other than BCMath):
1) Round numbers before comparison:
<?php
$sig_figs = 5;
echo (round((19.6*100), $sig_figs) !== round((double)1960, $sig_figs)) ? 'not equal' : 'equal';
?>
Outputs: equal
D/LiveViewPlugin(15550): Plugin registered. mPluginId: 0 isSandbox? true
D/LiveViewPlugin(15550): Plugin installation notified.
D/LiveViewPlugin(15550): Registry success!
<uses-permission android:name="com.sonyericsson.extras.liveview.permission.LIVEVIEW_API"/>
D/LiveViewPlugin(15843): Plugin installation notified.
D/LiveViewPlugin(15843): Registry success!D/LiveViewPlugin(15843): Plugin registered. mPluginId: 161427209 isSandbox? true
D/LiveViewKupriyanovPlugin(15481): startPluginD/LiveViewKupriyanovPlugin(15481): Enter HelloWorldService.startWork.
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
startActivity(new Intent(Settings.ACTION_SETTINGS));
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
You can useContext.getSystemService(Context.CONNECTIVITY_SERVICE).getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
orContext.getSystemService(Context.CONNECTIVITY_SERVICE).getNetworkInfo(ConnectivityManager.TYPE_WIFI)
and parse the DetailedState enum of the returned NetworkInfo object
and don't forget to allow it the Manifest
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity android:name="SampleActivity" android:label="@string/app_name" android:windowSoftInputMode="adjustPan" >
...
</activity>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="horizontal"
android:background="@android:drawable/bottom_bar" android:paddingLeft="4.0dip"
android:paddingTop="5.0dip" android:paddingRight="4.0dip"
android:paddingBottom="1.0dip" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@+id/TextView01">
<Button android:id="@+id/allow" android:layout_width="0.0dip"
android:layout_height="fill_parent" android:text="Allow"
android:layout_weight="1.0" />
<Button android:id="@+id/deny" android:layout_width="0.0dip"
android:layout_height="fill_parent" android:text="Deny"
android:layout_weight="1.0" />
</LinearLayout>
zypper in texlive-latex
A) Start CPAN Shell:
# perl -MCPAN -e shell
B) Install a perl module:
At cpan> shell prompt install module using install module::Name command. For example install module called MIME::Lite:# cpan> install MIME::Lite
Alternatively, try out the following command:# cpan -i MIME::Lite
-Go here
--http://developer.android.com/sdk/index.html
and get the SDK for your OS
-Once you download it, unzip it to its own folder, I put it off C:\
-Run the SDK Setup.exe
-Click available Packages, on left, I didn't know what was needed so I installed -EVERYTHING. Although I do suspect that we only need the USB driver, which is at the very bottom.
It will take forever to install.
After it's done installing, I Clicked on Installed Packages, and updated all.
Not done yet.
check that the phone is set up to allow debugging via USB (Settings⇒Applications⇒Development⇒USB debugging)
Plug in your phone
Windows will fail to install the driver.
Go in device manager and and update the newly Yellowed entry, the driver is in:
C:\android-sdk_r06-windows\android-sdk-windows\usb_driver
The driver should install
Start console: "Start"->"Run"->cmd->ENTER> adb devicesif you see a serial number starting with an "H" that means you got things working, now do the following:> adb shell pm setInstallLocation 2
This command will push ALL apps to your sd card, to revert back to saving apps to internal memory enter in:
> adb shell pm setInstallLocation 0
<?php
$request_url = ‘http://www.akchauhan.com/test.php’;
$post_params['name'] = urlencode(’Test User’);
$post_params['file'] = ‘@’.'demo/testfile.txt’;
$post_params['submit'] = urlencode(’submit’);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);
?>
After upgrading to the latest Cyanogen I notices, that the Android Market is quiet slow and does not show my downloaded apps in the download section. 2 Fixes to repair this:
1) Take the following source and save in file named vending_preferences.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<boolean name="local_db_sync_required" value="false" />
<int name="SERVER_VERSION" value="1000" />
<string name="vending_tos_version">1.0.0</string>
<long name="MARKET_LAST_HEARTBEAT_TIMESTAMP" value="1271657433127" />
<long name="last_sync_time" value="1271659724720" />
<long name="last_tickle_id" value="1271657514775" />
<int name="reconciled_version" value="1710" />
<boolean name="metadata_paid_apps_enabled" value="true" />
<string name="vending_backup_state">vending</string>
<string name="vending_tos_version">1.0.0</string>
</map>
Now push to /data/data/com.android.vending/shared_prefs/vending_preferences.xml :
adb push vending_preferences.xml /data/data/com.android.vending/shared_prefs/vending_preferences.xml
Next you do in a terminal window (device or via adb shell):
su
cd /data/data/com.android.vending/cache
rm *
reboot
You will need to take control over what goes into the ListView and
Spinner. I have not experimented with these techniques on Spinner, but
on ListView, you will need to override getView() (on ArrayAdapter) or
newView() and bindView() (on CursorAdapter).
Here is a free excerpt from one of my books that demonstrates the technique:
http://commonsware.com/Android/excerpt.pdf
In your case, you would use your Typeface object to update the font used
by the TextView widgets in your rows.
In principle, you could do this via a wrapping adapter -- this would be
more reusable but a bit slower. I have an AdapterWrapper base class here:
http://github.com/commonsguy/cwac-adapter
and some projects that use it here:
http://github.com/commonsguy/cwac-endless
http://github.com/commonsguy/cwac-thumbnail
java -jar AndroidDBEditor.jar
@echo off
rem set current path
set CURRENT_PATH=%~dp0
rem replace slashes
set CURRENT_PATH=%CURRENT_PATH:\=/%
echo sqliteeditorpath=%CURRENT_PATH%sqlitebrowser.exe > settings.ini
rem start app
java -jar AndroidDBEditor.jar
Additionally you should set umask 002 while working with a repository so that all new files will be writable by owner and group. This is made mandatory by creating a wrapper script for svn and svnserve:
mv /usr/bin/svn /usr/bin/svn.orig &&
mv /usr/bin/svnserve /usr/bin/svnserve.orig &&
cat >> /usr/bin/svn << "EOF"#!/bin/sh
umask 002
/usr/bin/svn.orig "$@"
EOF
cat >> /usr/bin/svnserve << "EOF"#!/bin/sh
umask 002
/usr/bin/svnserve.orig "$@"
EOF
chmod 0755 /usr/bin/svn{,serve}
Setting default browser manually
You can manually set the default browser by selecting it as the the default program for individual file types and protocols, as follows:
- Windows XP and earlier: Open the Control Panel from the Windows Start menu.
- In Windows 2000 and earlier, or if Windows XP is using the Control Panel "Classic View": Click on "Folder Options -> File Types".
- In Windows XP, if using the Control Panel "Category View": Click on "Performance and Maintenance". Then, click on "File Types" in the left column under the heading "See Also".
- Windows 7 and Vista: Click the Start button, open "Default Programs" and then click "Associate a file type or protocol with a program". For detailed instructions, see the Microsoft article here for Vista or here for Windows 7. Note: On Windows Vista (or above), you may be unable to associate the HTTP HTTPS or FTP protocols with SeaMonkey because it does not appear as an available option. See this forum topic for additional information.
Assign the following protocols and file types to the browser you wish to set as default:
- URL:HyperText Transfer Protocol (HTTP protocol)
- URL:HyperText Transfer Protocol with Privacy (HTTPS protocol)
- URL:File Transfer Protocol {FTP protocol)
- HTML File
- HTM File (optional)
In Windows XP and earlier, you can find the URL protocols listed above in File Types, under extension "N/A" or "(NONE)".
openssl crl2pkcs7 -nocrl -certfile mycert.crt -outform DER -out newcertfile.spc
openssl req \
-new -newkey rsa:1024 -nodes \
-keyout mykey.pem -out myreq.pem
openssl req -new -key mykey.pem -out myreq.pem
WebView
allows you to create your own web browser Activity. In this tutorial, we'll create a simple Activity that can view web pages.(6) When integrating AdMob ads into your application it is recommended to use test mode. In test mode test, ads are always returned.
Test mode is enabled on a per-device basis. To enable test mode for a device, first request an ad, then look in LogCat for a line like the following:
To get test ads on the emulator use AdManager.setTestDevices...
Once you have the device ID you can enable test mode by calling AdManager.setTestDevices:
AdManager.setTestDevices( new String[] {
AdManager.TEST_EMULATOR, // Android emulator
"E83D20734F72FB3108F104ABC0FFC738", // My T-Mobile G1 Test Phone
} );
Just put stateAlwaysHidden attribute in your Manifest
<activity name="EditContactActivity"
android:windowSoftInputMode="stateAlwaysHidden">
...
</activity>
The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.
$ adb shell monkey -p your.package.name -v 500
TextView t=(TextView) findViewById(android.R.id.title);
t.setGravity(Gravity.CENTER_HORIZONTAL);
It uses pixels, but I'm sure you're wondering how to use dips instead. The answer is inTypedValue.applyDimension()
. Here's an example of how to convert dips to px in code:
// Converts 14 dip into its equivalent px
Resources r = getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, r.getDisplayMetrics());
Android comes with 3 fonts (Sans, Serif, Monospace) which can be accesed using android:typeface="FONT_NAME". But most of the times you would want to use your own fonts instead of the stock ones. Android provides an "assets" folder where you can put your TTF font files and access them from within the code.
There are two ways of doing this,
1. Assign the Typeface object to TextView,
2. Paint the Typeface on screen Canvas.
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView bauhs = null,chiller=null,broadw=null,joker=null ;
Button mag=null;
setFont(bauhs, "fonts/BAUHS93.TTF", R.id.bauhs);
setFont(broadw, "fonts/BROADW.TTF", R.id.broadw);
setFont(chiller, "fonts/CHILLER.TTF", R.id.chiller);
setFont(joker, "fonts/JOKERMAN.TTF", R.id.joker);
setFont(mag, "fonts/MAGNETOB.TTF", R.id.magneto);
}
void setFont(TextView name, String path, int res)
{
name=(TextView)findViewById(res);
Typeface font = Typeface.createFromAsset(this.getAssets(), path);
name.setTypeface(font);
}
- "Typeface" is the class for handling fonts.
- The createFromAsset() method is used to specify the font path.
- font object is assigned to the TextView name
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(new FontView(this));
}
private static class FontView extends View
{
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Typeface mFace;
public FontView(Context context)
{
super(context);
// mFace = Typeface.createFromAsset(getContext().getAssets(),"fonts/MAGNETOB.TTF");
mPaint.setTextSize(34);
mPaint.setColor(Color.WHITE);
}
@Override
protected void onDraw(Canvas canvas)
{
canvas.drawColor(Color.BLACK);
drawFont(canvas, "fonts/BAUHS93.TTF", 50, "Bauhaus 93");
drawFont(canvas, "fonts/BROADW.TTF", 150, "Broadway");
drawFont(canvas, "fonts/CHILLER.TTF", 250, "Chiller");
drawFont(canvas, "fonts/JOKERMAN.TTF", 350, "Jokerman");
}
void drawFont(Canvas canvas, String path, int y, String name)
{
mFace = Typeface.createFromAsset(getContext().getAssets(),path);
mPaint.setTypeface(mFace);
canvas.drawText(name, 30, y, mPaint);
}
}
- We need to extend the View class to access and override the onDraw() method.
- A Paint object is created which allows us to set the font size and color.
- The TypeFace object mFace is assigned to mPaint which is drawn on screen using the drawText().
- drawText() takes 3 parameters, the text to be painted, its X-Y location and the Paint object.
Usually you run mysqldump to create database copy:
$ mysqldump -u user -p db-name > db-name.out
Copy db-name.out file using sftp/ssh to remote MySQL server:
$ scp db-name.out user@remote.box.com:/backup
Restore database at remote server (login over ssh):
$ mysql -u user -p db-name < db-name.out
Short answer is you can copy database from one computer/server to another using ssh or mysql client.
You can run all the above 3 commands in one pass using mysqldump and mysql commands (insecure method, use only if you are using VPN or trust your network):$ mysqldump db-name | mysql -h remote.box.com db-name
Use ssh if you don't have direct access to remote mysql server (secure method):$ mysqldump db-name | ssh user@remote.box.com mysql db-name
You can just copy table called foo to remote database (and remote mysql server remote.box.com) called bar using same syntax:$ mysqldump db-name foo | ssh user@remote.box.com mysql bar
First create a tar ball of old uses (old Linux system). Create a directory:# mkdir /root/move/
Setup UID filter limit:# export UGIDLIMIT=500
Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig
Copy /etc/group file:# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig
Copy /etc/shadow file:# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig
Copy /etc/gshadow (rarely used):# cp /etc/gshadow /root/move/gshadow.mig
Make a backup of /home and /var/spool/mail dirs:# tar -zcvpf /root/move/home.tar.gz /home
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail
Where,
Use scp or usb pen or tape to copy /root/move to a new Linux system.# scp -r /root/move/* user@new.linuxserver.com:/path/to/location
First, make a backup of current users and passwords:# mkdir /root/newsusers.bak
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak
Now restore passwd and other files in /etc/# cd /path/to/location
# cat passwd.mig >> /etc/passwd
# cat group.mig >> /etc/group
# cat shadow.mig >> /etc/shadow
# /bin/cp gshadow.mig /etc/gshadow
Please note that you must use >> (append) and not > (create) shell redirection.
Now copy and extract home.tar.gz to new server /home# cd /
# tar -zxvf /path/to/location/home.tar.gz
Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail# cd /
# tar -zxvf /path/to/location/mail.tar.gz
Now reboot system; when the Linux comes back, your user accounts will work as they did before on old system:# reboot
You might probably faced the same following error while you were restarting the Apache server on Ubuntu.
To fix that problem, you need to edit the httpd.conf file. Open the terminal and type,
By default httpd.conf file will be blank. Now, simply add the following line to the file.
Save the file and exit from gEdit.
Finally restart the server.
@Override
public void onCreate(Bundle icicle) {
. . .
WindowManager w = getWindowManager();
Display d = w.getDefaultDisplay();
int width = d.getWidth();
int height = d.getHeight();
.
PackageManager pm = this.getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);
for(ResolveInfo info: list)
{
Log.w("App browser", info.activityInfo.applicationInfo.loadLabel( pm ).toString());
}
String theMIMEType = getMIMEtype(aFile);
if (theMIMEType!=null) {
Intent theIntent = new Intent(Intent.ACTION_VIEW);
theIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK+Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
theIntent.setDataAndType(Uri.fromFile(aFile), theMIMEType);
try {
startActivity(theIntent);
} catch (ActivityNotFoundException anfe) {
//show error
}
}
Intent theIntent = new Intent(Intent.ACTION_VIEW);
theIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK+Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
String theMIMEcategory = getMIMEcategory(aFile);
theIntent.setDataAndType(Uri.fromFile(aFile),theMIMEcategory);
try {
startActivity(Intent.createChooser(theIntent,aChooserTitleString));
} catch (Exception e) {
//show error
}
<intent-filter>
<action android:name="android.intent.action.PICK" />
<action android:name="org.openintents.action.PICK_FILE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:scheme="folder" />
<data android:scheme="directory" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />
</intent-filter>
String theMIMEType = getMIMEtype(aFile);
if (theMIMEType!=null) {
Intent theIntent = new Intent(Intent.ACTION_SEND);
theIntent.setType(theMIMEType);
theIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(aFile));
//next line specific to email attachments
theIntent.putExtra(Intent.EXTRA_SUBJECT, aFile.getName());
try {
startActivity(Intent.createChooser(theIntent, aChooserTitle));
} catch (Exception e) {
//show error
}
}
public static String getMIMEcategory(String aMIMEtype) {
if (aMIMEtype!=null) {
aMIMEtype = aMIMEtype.substring(0,aMIMEtype.lastIndexOf("/",aMIMEtype.length()-1))+"/*";
} else {
aMIMEtype = "*/*";
}
return aMIMEtype;
}
protected boolean packageMarkedFiles(Intent aIntent) {
ArrayList theUris = myFilesToSend.toUriList();
//iterate through the list and get overall mimeType
String theOverallMIMEtype = null;
String theMIMEtype = null;
String theOverallMIMEcategory = null;
String theMIMEcategory = null;
Iterator iu = theUris.iterator();
while (iu.hasNext()) {
String theFilename = iu.next().getLastPathSegment();
theMIMEtype = getMIMEtype(theFilename);
if (theOverallMIMEtype!=null) {
if (!theOverallMIMEtype.equals(theMIMEtype)) {
theOverallMIMEcategory = getMIMEcategory(theOverallMIMEtype);
theMIMEcat = getMIMEcategory(theMIMEtype);
if (!theOverallMIMEcat.equals(theMIMEcat)) {
theOverallMIMEtype = "multipart/mixed";
break; //no need to keep looking at the various types
} else {
theOverallMIMEtype = theOverallMIMEcat+"/*";
}
} else {
//nothing to do
}
} else {
theOverallMIMEtype = theMIMEtype;
}
}
if (theUris!=null && theOverallMIMEtype!=null) {
aIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,theUris);
aIntent.setType(theOverallMIMEtype);
return true;
} else {
return false;
}
}
protected boolean sendMarkedFiles() {
Intent theIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
if (packageMarkedFiles(theIntent,false)) {
startActivity(Intent.createChooser(theIntent, aChooserTitle));
}
return true;
}
Intent theIntent = getIntent();
if (theIntent!=null) {
String theAction = theIntent.getAction();
if (Intent.ACTION_SEND_MULTIPLE.equals(theAction)) {
theFileList = theIntent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
}
}
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" />
</intent-filter>