Is page level CSS Bad practice? [on hold]
If I have set of rules specific to a particular page page Is it a bad
practice to place it in the page level?
Sample Code:
CSS
/* Product */
.product-list-link
{
padding-top: 5px;
padding-bottom: 5px;
}
HTML
<div class="product-list-link">
...
</div>
Butterworth
Sunday, 1 September 2013
How to generate filename appropiate to the list assigned "years"
How to generate filename appropiate to the list assigned "years"
How to generate filename appropiate to the list assigned "years". I need
to know how to generate the "calendar" name appropiate to the year_list. I
want to add 2000 to 2013 year_list at once, because right now I have to
edit and change every year number once I run the script to output
different year.
year_list = [2000]
FILENAME = "calendar_2000.txt"
What I need is year_list to be 2000, 2001, 2002.. up to 2013 and the
output file to be generated accordingly to the year_list numbers.
How to generate filename appropiate to the list assigned "years". I need
to know how to generate the "calendar" name appropiate to the year_list. I
want to add 2000 to 2013 year_list at once, because right now I have to
edit and change every year number once I run the script to output
different year.
year_list = [2000]
FILENAME = "calendar_2000.txt"
What I need is year_list to be 2000, 2001, 2002.. up to 2013 and the
output file to be generated accordingly to the year_list numbers.
ext.NET accordion is not working correctly (MVC)
ext.NET accordion is not working correctly (MVC)
Could someone please point me in the right direction here, I've spent
hours on this!
I am trying to create a West region Container that contains an image fixed
in height, with an accordion control below that takes up the rest of the
vertical space.
Every time I try this, the accordion control does not work properly. It
renders with the top node expanded, and all the other nodes jammed up
together (not at the bottom). Also, when you start using the accordion, it
just seems to stop reacting to user clicks completely. My suspicion is the
way I am laying out the control (I am new to ext.NET).
I have created a class that supplies to the view the ext.NET control. The
function that returns the West region returns an ext.NET Container.
ext.Image image = new ext.Image
{
ImageUrl = "~/resources/images/welcome-screens.png",
Height = 200,
};
ext.Container outer = new ext.Container
{
Border = true,
Region = ext.Region.West,
Width = 200,
Split = true
};
outer.Items.Add(image);
ext.Panel acc = new ext.Panel
{
Title = "ACCORDION PANEL",
Layout = ext.LayoutType.Accordion.ToString()
};
acc.Items.Add(new ext.Panel { Title = "TEST1", Items = { new
ext.Panel { Title = "a" }, new ext.Panel { Title = "b" } }
});
acc.Items.Add(new ext.Panel { Title = "TEST2", Items = { new
ext.Panel { Title = "c" } }});
acc.Items.Add(new ext.Panel { Title = "TEST3", Items = { new
ext.Panel { Title = "d" } }});
acc.Items.Add(new ext.Panel { Title = "TEST4", Items = { new
ext.Panel { Title = "e" } }});
acc.Items.Add(new ext.Panel { Title = "TEST5", Items = { new
ext.Panel { Title = "f" } } });
outer.Items.Add(acc);
Any pointers or advice would be really welcome. Thanks.
Could someone please point me in the right direction here, I've spent
hours on this!
I am trying to create a West region Container that contains an image fixed
in height, with an accordion control below that takes up the rest of the
vertical space.
Every time I try this, the accordion control does not work properly. It
renders with the top node expanded, and all the other nodes jammed up
together (not at the bottom). Also, when you start using the accordion, it
just seems to stop reacting to user clicks completely. My suspicion is the
way I am laying out the control (I am new to ext.NET).
I have created a class that supplies to the view the ext.NET control. The
function that returns the West region returns an ext.NET Container.
ext.Image image = new ext.Image
{
ImageUrl = "~/resources/images/welcome-screens.png",
Height = 200,
};
ext.Container outer = new ext.Container
{
Border = true,
Region = ext.Region.West,
Width = 200,
Split = true
};
outer.Items.Add(image);
ext.Panel acc = new ext.Panel
{
Title = "ACCORDION PANEL",
Layout = ext.LayoutType.Accordion.ToString()
};
acc.Items.Add(new ext.Panel { Title = "TEST1", Items = { new
ext.Panel { Title = "a" }, new ext.Panel { Title = "b" } }
});
acc.Items.Add(new ext.Panel { Title = "TEST2", Items = { new
ext.Panel { Title = "c" } }});
acc.Items.Add(new ext.Panel { Title = "TEST3", Items = { new
ext.Panel { Title = "d" } }});
acc.Items.Add(new ext.Panel { Title = "TEST4", Items = { new
ext.Panel { Title = "e" } }});
acc.Items.Add(new ext.Panel { Title = "TEST5", Items = { new
ext.Panel { Title = "f" } } });
outer.Items.Add(acc);
Any pointers or advice would be really welcome. Thanks.
Saturday, 31 August 2013
Using ConcurrentHashMap efficiently?
Using ConcurrentHashMap efficiently?
I have a Android Application whose core component is a
HashMap<String,float[]>. The System is having high concurrency. e.g here
are the following three situations I have which occur frequently and they
are highly overlapping in nature
Iterate through all the keys in the hashmap and do some operation on its
value(read only operations).
Add new key,value pairs in the Hashmap.
Remove Certain keys from the Hashmap.
I do all these operations in different threads and thus am using a
ConcurrentHashMap since some inconsistency in retrievals doesnt matter.
e.g While iterating the map,if new entries are added then it doesnt matter
to not read in those new values immediately as I ensure that next time
they are read .
Also while removing the entries I am recreating the iterator everytime to
avoid "ConcurrentModificationException"
Suppose , there is a following hashmap(i.e ConcurrentHashmap)
ConcurrentHashMap<String,float[]> test=new ConcurrentHashMap<String,
float[]>(200);
Now for Retrieval I do the following
Iterator<String> reader=test.keySet().iterator();
while(reader.hasNext())
{
String s=reader.next();
float[] temp=test.get(s);
//do some operation with float[] temp here(read only
operation)
}
and for removal I do the following
boolean temp = true;
while (temp) {
for (String key : test.keySet()) {
temp = false;
if (key.equals("abc")) {
test.remove(key);
temp = true;
break;
}
}
}
and when inserting in new values I simply do
test.put("temp value", new float[10]);
I am not sure if its a very efficient utilisation. Also it does matter not
to read in removed values(however I need efficiency ,and since the
iterator is again created during the function call,its guaranteed that in
the next time I don't get the removed values)so that much inconsistency
can be tolerated?
Could someone please tell me an efficient way to do it?
I have a Android Application whose core component is a
HashMap<String,float[]>. The System is having high concurrency. e.g here
are the following three situations I have which occur frequently and they
are highly overlapping in nature
Iterate through all the keys in the hashmap and do some operation on its
value(read only operations).
Add new key,value pairs in the Hashmap.
Remove Certain keys from the Hashmap.
I do all these operations in different threads and thus am using a
ConcurrentHashMap since some inconsistency in retrievals doesnt matter.
e.g While iterating the map,if new entries are added then it doesnt matter
to not read in those new values immediately as I ensure that next time
they are read .
Also while removing the entries I am recreating the iterator everytime to
avoid "ConcurrentModificationException"
Suppose , there is a following hashmap(i.e ConcurrentHashmap)
ConcurrentHashMap<String,float[]> test=new ConcurrentHashMap<String,
float[]>(200);
Now for Retrieval I do the following
Iterator<String> reader=test.keySet().iterator();
while(reader.hasNext())
{
String s=reader.next();
float[] temp=test.get(s);
//do some operation with float[] temp here(read only
operation)
}
and for removal I do the following
boolean temp = true;
while (temp) {
for (String key : test.keySet()) {
temp = false;
if (key.equals("abc")) {
test.remove(key);
temp = true;
break;
}
}
}
and when inserting in new values I simply do
test.put("temp value", new float[10]);
I am not sure if its a very efficient utilisation. Also it does matter not
to read in removed values(however I need efficiency ,and since the
iterator is again created during the function call,its guaranteed that in
the next time I don't get the removed values)so that much inconsistency
can be tolerated?
Could someone please tell me an efficient way to do it?
Changes not applied on AVD?
Changes not applied on AVD?
i am new to cocos2d-x i am making app for Android using cocos2d-x in
Android emulator their is no changes applied in it! I mean i change
HelloWorld.png to game.png and Hello World to Game but nothing works in
emulator it is showing Hello World and HelloWorld.png game.png is in
assets
I clean my Project close eclipse emulator but problem is still there!!! I
uninstall APK from emulator but no LUCK!
console message: bash /build_native.sh NDK_DEBUG=1 V=1 all /usr/bin/bash:
/build_native.sh: No such file or directory
Please help! me Thanks
i am new to cocos2d-x i am making app for Android using cocos2d-x in
Android emulator their is no changes applied in it! I mean i change
HelloWorld.png to game.png and Hello World to Game but nothing works in
emulator it is showing Hello World and HelloWorld.png game.png is in
assets
I clean my Project close eclipse emulator but problem is still there!!! I
uninstall APK from emulator but no LUCK!
console message: bash /build_native.sh NDK_DEBUG=1 V=1 all /usr/bin/bash:
/build_native.sh: No such file or directory
Please help! me Thanks
Express + Angular routing causing infinite loop + crash
Express + Angular routing causing infinite loop + crash
I'm work on a Node app using Express as well as Angular. I'm using Angular
for routing and have my routes setup like so:
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/partials/main'
//controller: 'IndexController'
}).when('/discover', {
templateUrl: '/partials/discover'
}).when('/user/home', { //HERES THE PROBLEM CHILD!!!!!
templateUrl: '/partials/user/home'
}).otherwise({
redirectTo: '/'
});
}]).config(['$locationProvider', function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
Now, whenever I try and call /user/home -- The page goes into an infinite
loop and keeps reloading the controller. I can see in the node console
that the page was called from partials/user/home which definitely contains
a Jade file. I've checked other posts, most of them are solved with ass
the / in the beginning of the partials path, that didn't help here. The
page loads fine if I transfer home.jade into the /partials directory with
no sub directory. Any ideas?
I'm work on a Node app using Express as well as Angular. I'm using Angular
for routing and have my routes setup like so:
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/partials/main'
//controller: 'IndexController'
}).when('/discover', {
templateUrl: '/partials/discover'
}).when('/user/home', { //HERES THE PROBLEM CHILD!!!!!
templateUrl: '/partials/user/home'
}).otherwise({
redirectTo: '/'
});
}]).config(['$locationProvider', function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
Now, whenever I try and call /user/home -- The page goes into an infinite
loop and keeps reloading the controller. I can see in the node console
that the page was called from partials/user/home which definitely contains
a Jade file. I've checked other posts, most of them are solved with ass
the / in the beginning of the partials path, that didn't help here. The
page loads fine if I transfer home.jade into the /partials directory with
no sub directory. Any ideas?
Error: The Constructor File(URI) is undefined
Error: The Constructor File(URI) is undefined
I'm trying to write an activity that takes a picture and saves the data
and image to the sd card where I can read the image data and output it.
But, I'm getting an error "Constructor File(Uri) is undefined.") in the
showPhoto() method. Can anyone help??
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager.OnActivityResultListener;
import android.provider.MediaStore;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
public class CallCamera extends Activity {
private static final String TAG = "CallCamera";
private static final int CAPTURE_IMAGE_ACTIVITY_REQ = 0;
Uri fileUri = null;
ImageView photoImage = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call_camera);
photoImage=(ImageView) findViewById(R.id.photo_image);
Button callCameraButton =
(Button)findViewById(R.id.button_callcamera);
callCameraButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
Intent i= new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = getOutputPhotoFile();
fileUri=Uri.fromFile(getOutputPhotoFile());
i.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(i, CAPTURE_IMAGE_ACTIVITY_REQ);
//returns photo file to activity when camera is done
}
//store photo taken on SD card
private File getOutputPhotoFile() {
File directory = new
File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),getPackageName());
if (!directory.exists()){
if(!directory.mkdirs()){
Log.e(TAG,"Failed to create storage directory.");
return null;
}
}
//set photo name with standard time linked and store
on sdCard in standard picture directory
String timeStamp = new
SimpleDateFormat("yyyMMdd_HHmmss",Locale.ENGLISH).format(new
Date());
return new File(directory.getPath() + File.separator +
"IMG_"+timeStamp+".jpg");
}
protected void onActivityResult (int requestCode, int
resultCode, Intent data){
if (requestCode==CAPTURE_IMAGE_ACTIVITY_REQ){
if(resultCode==RESULT_OK){
Uri photoUri = null;
if (data==null){
//confirming image save
Toast.makeText(CallCamera.this, "Image saved
successfully", Toast.LENGTH_LONG).show();
photoUri=fileUri;
} else {
photoUri = data.getData();
Toast.makeText(CallCamera.this, "imaged saved
successfully in: " + data.getData(),
Toast.LENGTH_LONG).show();
}
photoUri = data.getData();
showPhoto(photoUri);
} else if (resultCode==RESULT_CANCELED) {
Toast.makeText( CallCamera.this,"Cancelled",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(CallCamera.this, "Callout for image
capture failed!", Toast.LENGTH_LONG).show();
}
}
}
});
}
protected void showPhoto(Uri photoUri) {
File imageFile = new File(photoUri);
if (imageFile.exists()){
Drawable oldDrawable = photoImage.getDrawable();if(oldDrawable
!=null) { ((BitmapDrawable)oldDrawable).getBitmap().recycle();
}
}
if (imageFile.exists()){
Bitmap bitmap =
BitmapFactory.decodeFile(imageFile.getAbsolutePath());
BitmapDrawable drawable = new
BitmapDrawable(this.getResources(),bitmap);
photoImage.setScaleType(ImageView.ScaleType.FIT_CENTER);;
photoImage.setImageDrawable(drawable);
}
}
I'm trying to write an activity that takes a picture and saves the data
and image to the sd card where I can read the image data and output it.
But, I'm getting an error "Constructor File(Uri) is undefined.") in the
showPhoto() method. Can anyone help??
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager.OnActivityResultListener;
import android.provider.MediaStore;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
public class CallCamera extends Activity {
private static final String TAG = "CallCamera";
private static final int CAPTURE_IMAGE_ACTIVITY_REQ = 0;
Uri fileUri = null;
ImageView photoImage = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call_camera);
photoImage=(ImageView) findViewById(R.id.photo_image);
Button callCameraButton =
(Button)findViewById(R.id.button_callcamera);
callCameraButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
Intent i= new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = getOutputPhotoFile();
fileUri=Uri.fromFile(getOutputPhotoFile());
i.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(i, CAPTURE_IMAGE_ACTIVITY_REQ);
//returns photo file to activity when camera is done
}
//store photo taken on SD card
private File getOutputPhotoFile() {
File directory = new
File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),getPackageName());
if (!directory.exists()){
if(!directory.mkdirs()){
Log.e(TAG,"Failed to create storage directory.");
return null;
}
}
//set photo name with standard time linked and store
on sdCard in standard picture directory
String timeStamp = new
SimpleDateFormat("yyyMMdd_HHmmss",Locale.ENGLISH).format(new
Date());
return new File(directory.getPath() + File.separator +
"IMG_"+timeStamp+".jpg");
}
protected void onActivityResult (int requestCode, int
resultCode, Intent data){
if (requestCode==CAPTURE_IMAGE_ACTIVITY_REQ){
if(resultCode==RESULT_OK){
Uri photoUri = null;
if (data==null){
//confirming image save
Toast.makeText(CallCamera.this, "Image saved
successfully", Toast.LENGTH_LONG).show();
photoUri=fileUri;
} else {
photoUri = data.getData();
Toast.makeText(CallCamera.this, "imaged saved
successfully in: " + data.getData(),
Toast.LENGTH_LONG).show();
}
photoUri = data.getData();
showPhoto(photoUri);
} else if (resultCode==RESULT_CANCELED) {
Toast.makeText( CallCamera.this,"Cancelled",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(CallCamera.this, "Callout for image
capture failed!", Toast.LENGTH_LONG).show();
}
}
}
});
}
protected void showPhoto(Uri photoUri) {
File imageFile = new File(photoUri);
if (imageFile.exists()){
Drawable oldDrawable = photoImage.getDrawable();if(oldDrawable
!=null) { ((BitmapDrawable)oldDrawable).getBitmap().recycle();
}
}
if (imageFile.exists()){
Bitmap bitmap =
BitmapFactory.decodeFile(imageFile.getAbsolutePath());
BitmapDrawable drawable = new
BitmapDrawable(this.getResources(),bitmap);
photoImage.setScaleType(ImageView.ScaleType.FIT_CENTER);;
photoImage.setImageDrawable(drawable);
}
}
Subscribe to:
Posts (Atom)