Quantcast
Channel: Developer Feed - Snippet
Browsing all 178 articles
Browse latest View live

How to display PHP setup and environment variables?

In order to display PHP setup, configuration and environmental variables simply create a php page and execute the phpinfo command. It will display all the relevant information about PHP as output in...

View Article


How to load image from PhotoGallery into a CCSprite?

SinppetThe Asset Library is used here, so add import.#import "AssetsLibrary/AssetsLibrary.h"   CCSprite *playPhoto;  CCLOG(@"Photo %@",dataManager.playerPhoto);// check if the URL is an asset URL from...

View Article


How to change font to bold and color of a UILabel?

SnippetThe following snippet provides a utiity method to change the label font from bold to regular along with that it changes the color to red or black respectivelyread more

View Article

What are the various Enums used by the Facebook iOS SDK?

The following are the various Enumeration defined and used by the Facebook iOS SDK. Please review these for full understanding of how the SDK behaves for various operations./* * Constants used by...

View Article

How to load an remote image as a Drawable in Android?

Loading an remote image from a online server accessible via a URL as Drawable is very straightforward.// Utililty Methodpublic static Drawable loadImageAsDrawable(String url) {    try {        // open...

View Article


How to allow multiple line text in EditText view in Android?

The EditText widget by default is single line. In order to allow mutiple lines modify and customize the widget definition in the layout file as below:<EditText    android:singleLine="false"<!--...

View Article

How to show Alert Dialog in Java Swing?

Displaying a simple message box or an alert dialog with an Ok button can be done with just one line of code as show below:A) Without a JFrameJOptionPane.showMessageDialog(null, "Message goes...

View Article

How do you create a simple Swing based Window with Frame?

importjava.awt.EventQueue; importjavax.swing.JFrame;  publicclass MainWindow {      privateJFrame frame;      /**     * Launch the application.     */     publicstaticvoid main(String[] args){...

View Article


How to check the version of MySQL database using Python?

#!/usr/bin/python# -*- coding: utf-8 -*- import MySQLdb as mdbimport sys con = None try:     con = mdb.connect('localhost','username',        'password','dbname');     cur = con.cursor()...

View Article


How to remove all files of a particular type from a directory in iOS?

Lets say you want to remove(delete) all the files of a particular extension say PNG from the Documents folder of the app. We can use the following code snippet.NSString*fileExt =@"png";</p>read more

View Article

How do you hide an ImageButton in Android?

In order to hide the button, call the setVisible method with either one of two argumentsimageButton.setVisible(View.INVISIBLE)OR imageButton.setVisible(View.GONE);read more

View Article

How to build simple Hashmap cache in Android?

The following snippet shows how to build a simple Bitmap Cache in Android:import java.util.HashMap;import android.graphics.Bitmap;// TODO: Auto-generated Javadoc/** * The Class ImageMemoryCache....

View Article

How to check if a file is an Image in Android using FileFilters?

In order to check if file is an Image, one can check for the file extension (jpg, png, etc.) using FileFilter as shown below:packagecom.livrona.apps.sikh.wallpapers;...

View Article


How do you center an Image to display in a Splash Page in Android?

Generally the splash page displays an image of the App on launch of the app. Most of time its just an single image that is intended to be displayed.Depending of the size of image and device it runs, it...

View Article

Email Validator in Android

The snippet shows an Email Validator using RegEx.read more

View Article


How to download and store file contents from Remote location on the SD Card?

The following functions fetches the file contents from a remote location, stores it in a given directory with a given file name on the SDCard of the deviceread more

View Article

How to create nosiy captcha using RMagick?

</p>read more

View Article


How to generate a random number in CSharp?

In order to generate a random number between two numbers, use the Next Function of the Random class as shown below:Example :read more

View Article

How to create 2D Canvas in HTML5 using Javascript?

SnippetThe following snippet shows how to create a div called as canvas (can be any name) and then in javascript we get the handle to canvas by calling document.getElementById method. Finally we get...

View Article

Image may be NSFW.
Clik here to view.

Simple File Writer

This snippet show how to write Strings to a file. It writes the String text as new line using the \n character. This class can be used to build Logger or write data into the file for...

View Article
Browsing all 178 articles
Browse latest View live


Latest Images