This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <sys/ioctl.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <netdb.h> | |
#include <arpa/inet.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ============================================================================================ | |
// Code | |
// | |
// Example showing how to set a View's background to a tiled bitmap. | |
// assumes: res/drawable/pattern01.png - The bitmap representing an individual tile | |
public void setViewTiledBackground(View view, Resources resources) { | |
Bitmap tile = BitmapFactory.decodeResource(resources, R.drawable.pattern02); | |
BitmapDrawable tiledBitmapDrawable = new BitmapDrawable(resources, tile); | |
tiledBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test extends Activity { | |
GridView gv; | |
Gallery g[] = new Gallery[3]; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
gv = (GridView)findViewById(R.id.gridview); | |
gv.setAdapter(new GAdapter()); | |
for (int i = 0; i < g.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Bitmap rotateBitmap(Bitmap original, float degrees) { | |
int width = original.getWidth(); | |
int height = original.getHeight(); | |
Matrix matrix = new Matrix(); | |
matrix.preRotate(degrees); | |
Bitmap rotatedBitmap = Bitmap.createBitmap(original, 0, 0, width, height, matrix, true); | |
Canvas canvas = new Canvas(rotatedBitmap); | |
canvas.drawBitmap(original, 5.0f, 0.0f, null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* How to use access files stored in the assets folder: | |
* | |
* Files saved in the assets/ directory are not given a resource ID, so you can't reference them through the R class or from XML resources. | |
* Instead, you can query files in the assets/ directory like a normal file system and read raw data using AssetManager. | |
* | |
* However, if all you require is the ability to read raw data (such as a video or audio file), then save the file in the res/raw/ directory | |
* and read a stream of bytes using openRawResource(). | |
* | |
* Notes: | |
* * AssetManager.list(String path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove the Activity parameter if this is being placed into a class that derives from Activity | |
public void launchHomeScreen(Activity activity) { | |
Intent homeIntent = new Intent(Intent.ACTION_MAIN, null); | |
homeIntent.addCategory(Intent.CATEGORY_HOME); | |
homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); | |
activity.startActivity(homeIntent); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git submodule foreach git submodule init && git submodule update --recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ChaoSim.pl : Simulation of Chaocipher enciphering/deciphering | |
# (c) Moshe Rubin, August 2010 | |
# email: mosher@mountainvistasoft.com | |
use strict; | |
use diagnostics; | |
use warnings; | |
my $left = uc($ARGV[1]); | |
my $right = uc($ARGV[2]); | |
my $mode = $ARGV[3]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use this to make it landscape: | |
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); | |
...and this to make it portrait: | |
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Basically, UIPasteBoard allows us to share data to other application. Below is an example of UIpasteBoard usage. | |
COPY | |
UIPasteboard *appPasteBoard = [UIPasteboard generalPasteboard]; | |
appPasteBoard.persistent = YES; | |
[appPasteBoard setString:@"STRING TO COPY"]; | |
PASTE |
NewerOlder