Is there some kind of compendium website for commonly used variable names?

Examples

  • db for a database
  • s for a string
  • i for an integer loop control variable

Note: these don't necessarily have to be good names, just commonly used ones. Although a list of preferred names would be useful.

Thanks in advance to anyone who is actually willing to help point me to resource instead of complaining, being a rules lawyer, or downvoting.

I was reading the 12 factor app manifesto. The manifesto recommends storing the configuration data for the application in environment variables.

Does this mean that properties like the DB username / password, resource URL should be stored as a part of Java Env variables rather than as property files?
Is this a secure way of storing the information?

To me this seems to be a pretty clunky way of storing the information.

One option that I can think of is to have a separate configuration service running in the landscape, and use env property to connect to the config service and then query the config service for further detailed configuration data.

Say you coded up some new feature.

Now the client comes to you and asks for a change that would make that new feature less user-friendly and just plain wrong.

Should you just accept the change request or can you influence the client that their request is misguided?

For methods that never access instance variable or static variable and they act just like a function (name-spaced) and they are deterministic base on only the input arguments , I want to ask, are there any consideration if I change all of them to static method?

I keep hearing people saying it static method is poor, but I am looking for some real code example on my above case.

I have been taught to follow the Red->Greeen->Refactor pattern when doing TDD. There have been situations where this pattern have not been applicable though.

For instance, a test to make sure that a controller action method (ASP.NET MVC) does not have an Authorize attribute. Since the test is testing the absense of an attribute it will pass on the first go, unless an Authorize attribute is added only to have the test fail.

What I have done so far when testing for absense of said Authorize attribute is to write a test for it, then add the Authorize attribute just to make sure that the test actually works, then immediately remove the Authorize attribute.

Am I doing something wrong, or is this just the way it is; some tests will pass unless we intentionally add code to make the fail and then remove that particular code?

I am making instrumentation for our legacy system and had specific questions about instrumentation and the terminology relating to it.

According to what is meant by instrumentation, what is instrumentation, and the Wikipedia article Instrumentation, instrumentation is a class of tools for debugging, logging, and profiling.

Just for confirmation:
1. What is the name of a single tool? (instrument?)
2. What is the process of attaching the tools to existing code? (instrumenting? / hooking? / attaching?)
3. What are profilers, debuggers (etc) considered?

I started my first job as a software developer while still a senior in college. It was at a small IT and computer repair shop, and I am the first and only programmer to work there. Now two months after graduation I have found a job at a company on the opposite end of the size scale, but as I reflect on the work I leave behind I feel uncomfortably as if I have failed in some of my responsibilities as a developer.

Mostly I couldn't find a way to convey to my boss (the owner) that the project I was working on was outside the scope of my experience and abilities. Without specifics, he wants a SaaS-like website that offers a host of features such as task management, calendaring, group chat messaging, and inventory tracking. The website should feature as native an experience as possible but have to advantage of being accessible across all platforms. He also wants Android and iOS client apps.

I like to think I am a decent, albeit novice, programmer. I set up Git, I created a database normalized to third normal form, I use bcrypt, our web api is mostly RESTful, I learned AngularJS for the website and Objective C for the iOS app. But progress has been slow. The iOS app is done, but Eclipse hasn't even been downloaded for the Android one. I'd say the website is about 25% done, but I've come to realize that my ability to accurately judge web development is nil (I'll never touch another line of HTML in any future jobs if I can help it).

That said, I definitely did not do well in project planning and requirements management. Worse, he'll never be able to find a more experienced developer willing to work for my wages, so there's a real danger that almost a full year's work will never see production.

Several months into the project, as I started to get an idea of how much work would be required and how little I knew about web development, I tried to convince my boss to accept separate desktop and mobile apps to decrease development time, but he was pretty set on the benefits of a web app interface. As a software developer, I feel I have a responsibility to not only write good code, but also make sure my employers accurately know what can feasibly be done within both my skill limits and their resource limits. How can I effectively convince to my boss that a project is too far beyond my abilities?

Given the amount of material that tries to explain what a context-free grammar (CFG) is, I found it surprising that very few (in my sample, less than 1 in 20) give an explanation on why such grammars are called "context-free". And, to my mind, none succeeds in doing so.

My question is, why are context-free grammars called context-free? What is "the context"? I had an intuition that the context could be other language constructs surrounding the currently analyzed construct, but that seems not to be the case. Could anyone provide a precise explanation?

We've developed a WordPress theme and we are going to deploy the theme for a client. We are only paid for the little modification on the theme and we still own the theme. We just let our client to use it. Legally, We agree that the themes is in in GPLv2.

Now, the problem is, after we've deployed the theme to the client server, they get a copy of source and they can do what ever they wanted, e.g. resell the theme to others.

How to prevent this? Are they unavoidable? Let's say if the client agree to sign a contract with additional terms that they don't resell the theme, is it still compatible with GPL?

I am beginner in programming and I've tried to implement the google maps inside sliding menu, at home, this is the fragment

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.moictab.decanias.MapActivity$PlaceholderFragment" >

<fragment 

          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.MapFragment"

          />

</RelativeLayout>

This is the class I want to put the maps

public class HomeFragment extends Fragment {

    public HomeFragment(){}

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_home, container, false);

        android.app.FragmentTransaction mTransaction = getFragmentManager().beginTransaction();
        SupportMapFragment mFRaFragment = new MapFragment();
        Bundle args = new Bundle();
        args.putDouble("lat", -4.573362);
        args.putDouble("lng", -44.6020426);
        mFRaFragment.setArguments(args);
        mTransaction.add(R.id.map, mFRaFragment);
        mTransaction.commit();


        MapsInitializer.initialize(getApplicationContext());


        return rootView;
    }

}

But I am getting these errors

mTransaction.add(R.id.map, mFRaFragment);

The method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, SupportMapFragment)

MapsInitializer.initialize(getApplicationContext());

The method getApplicationContext() is undefined for the type HomeFragment

The solution would be:

public class HomeFragment extends FragmentActivity {

And everything stay okay in this class, but in MainActivity is not acceptable because there is extends Fragment, I already tried to change there to FragmentActivity, but the the replace doesn't work:

    if (fragment != null) {
        FragmentManager fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction()
                .replace(R.id.frame_container, fragment).commit();

message: "The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, FragmentActivity)"

I already tried to use android.support.v4.app.Fragment, but it doesn't work too. My problem is to implement the google maps android in navigation Drawer.

/**
 * Diplaying fragment view for selected nav drawer list item
 * */
private void displayView(int position) {
    // update the main content by replacing fragments
    Fragment fragment = null;
    switch (position) {
    case 0:
        fragment = new HomeFragment();
        break;
    case 1:
        fragment = new FindPeopleFragment();
        break;
    case 2:
        fragment = new PhotosFragment();
        break;
    case 3:
        fragment = new CommunityFragment();
        break;
    case 4:
        fragment = new PagesFragment();
        break;
    case 5:
        fragment = new WhatsHotFragment();
        break;

    default:
        break;
    }

    if (fragment != null) {
        FragmentManager fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction()
                .replace(R.id.frame_container, fragment).commit();

        // update selected item and title, then close the drawer
        mDrawerList.setItemChecked(position, true);
        mDrawerList.setSelection(position);
        setTitle(navMenuTitles[position]);
        mDrawerLayout.closeDrawer(mDrawerList);
    } else {
        // error in creating fragment
        Log.e("MainActivity", "Error in creating fragment");
    }
}

I have seen too many ways to do, but they don't work.

I want the background color of my second activity to change once a button is pressed. This is my_activity2.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity2"
android:background="#ffdb4b5e">

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Next"
    android:id="@+id/button"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:textColor="#ffffffff"
    android:textSize="72sp"
    android:background="#00000000"
    />

<TextView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="@string/thing1"
    android:id="@+id/textView"
    android:textColor="#ffffffff"
    android:textSize="36sp"
    android:gravity="center"
    android:layout_above="@+id/button"
    />

This is my MyActivity2.java:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_activity2);
    Button n = (Button) findViewById(R.id.button);
    Typeface typeface = Typeface.createFromAsset(getAssets(), "BebasNeue Bold.ttf");
    n.setTypeface(typeface);
    final TextView tv = (TextView) findViewById(R.id.textView);
    Typeface face = Typeface.createFromAsset(getAssets(),
            "OSP-DIN.ttf");
    tv.setTypeface(face);

 final String[] values = getResources().getStringArray(R.array.things_array);
n.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Random RAND=new Random();
        String nextValue = values[RAND.nextInt(values.length)];
        tv.setText(nextValue);

I have the background colors stored in the strings.xml like so:

<?xml version="1.0" encoding="utf-8"?>

<string-array name="colorcode_array">
    <item>3498db</item>
    <item>2ecc71</item>
    <item>9b59b6</item>
    <item>f1c40f</item>
    <item>1abc9c</item>
    <item>2980b9</item>
    <item>8e44ad</item>
    <item>e41c1c</item>
    <item>2ecca9</item>
    <item>752ecc</item>
    <item>4f2ecc</item>
    <item>2eccc3</item>
    <item>2ecc53</item>
    <item>2ecc2e</item>
    <item>5bcc2e</item>
    <item>9ecc2e</item>
    <item>cca12e</item>
    <item>cc712e</item>
    <item>f1c209</item>
    <item>86f109</item>
    <item>f11616</item>
    <item>9c1818</item>
</string-array>

Now how can I make the background color change on random when the button "Next" is clicked? Matthew

I have Liferay 6.0.6 with kaleo workflow. I need to send task comments in the body of the mail notification when the task is rejected. I use the velocity template

How can I do that?

I have an application using a navigation drawer. The drawer lets you navigate between 2 fragments : F1 and F2 :

Activity layout:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/background"/>
    <!-- The navigation drawer -->
    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:dividerHeight="0dp"
        android:background="#f5f5f5"/>

</android.support.v4.widget.DrawerLayout>

Code to replace fragment in Activity :

private void selectItem(int position) {
    Fragment fragment;
    fragment = getFragmentToDisplay(position);

    if(fragment != null)
    {
        FragmentManager fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction()
                .replace(R.id.content_frame, fragment,"fragment_"+position)
                .commit();
    }
}

On F1 i have a button to call an other fragment (F3). When F3 replace F1 i use addToBackStack() to be able to return to F1 by pressing return.

Replacing F1 by F3:

getFragmentManager().beginTransaction()
                .replace(R.id.content_frame, new GameFragment())
                .addToBackStack("Games").commit();

Going from F1 to F2 , F2 to F1 works perfectly.
Going from F1 to F3 , F3 to F1 (using back button) works too.

Nevertheless if i'm doing this sequence :
F1 to F3 by button.
F3 to F2 by navigation drawer.
F2 to F1 by back button (backstack).
F1 to F2 by navigation drawer

The last fragment (F2) does not replace F1 , instead it appears above , like if i have added it : F2 not replacing F1

Doing the same navigation but not using the back button works as expected.

Why the backstack is messing with the fragment replacement ?

My goal is to provide a back navigation between F1 and F3 but not between fragments accessed by the navigation drawer.

I'm trying to read and execute an SQL script from a file. CREATE commands work but my first INSERT command results in a Logcat error with tag "SQLiteLog" and text "(1) near "INSERT": syntax error". The error is thrown on the database.execSQL() line.

String[] createScript = outputStream.toString().split(";");
            for (int i = 0; i < createScript.length; i++) {
                String sqlStatement = createScript[i].trim();
                // TODO You may want to parse out comments here
                if (sqlStatement.length() > 0) {
                    database.execSQL(sqlStatement + ";");
                }
            }

The SQL line is as follows

INSERT INTO [EntityAttributeSet] ([Id],[Code]) VALUES (1,NULL);

I need to take input of two numbers from the user which are separated by a space in a single line. For eg, if the user types in 10 20 I need to store the values 10 and 20 in separate variables. Is there any way to do that in C++?

I am following the HelloWorld tutorial from developer.android.com in Eclipse Kepler Service Release 2 & 0S X 10.9.4, but when I try to run the application I get this error in the console:

[2014-08-15 15:18:56 - MyFirstApp] Performing sync
[2014-08-15 15:18:56 - MyFirstApp] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2014-08-15 15:19:14 - MyFirstApp] Uploading MyFirstApp.apk onto device 'emulator-5554'
[2014-08-15 15:19:15 - MyFirstApp] Installing MyFirstApp.apk...
[2014-08-15 15:19:31 - MyFirstApp] Installation error: Unknown failure
[2014-08-15 15:19:31 - MyFirstApp] Please check logcat output for more details.
[2014-08-15 15:19:31 - MyFirstApp] Launch canceled!

And this one in the LogCat:

Failed to chmod(/data/system/packages.list): libcore.io.ErrnoException: chmod failed: ENOENT (No such file or directory)

First of, thanks for taking the time to read this. I am a true ios developer newbie, just released my first app. Now, trying to submit a second (different) app to the appstore, but that seems to go wrong. Whenever i choose validate or submit my app in Xcode, i see that it tries to do so for my previous app (created 2 different bundles IDs for that first app, being a noob and all). I surfed the web and found that i can delete that previous app that still has the status "Waiting for upload".

This link gives me a bit info on how to delete that broken uploaded;

What to do if Xcode Archiving Utility shows wrong app for validation?

Please note that i have no intention on submitting that 'broken' version of my first app.

HOWEVER, i don't seem to have any link where i can press delete, see here:

http://i.stack.imgur.com/Vq73t.png

TL;DR Can't remove my app that is waiting for upload, stuck with next development app now.

Any help is very, very, very much appreciated!

My app icons sometime change from there set color green to grey. this even happens the location indicator that is displayed on the MKMapView. When the app loads for the first time its fine, its when i navigate away from the page and come back it can happen.

enter image description here

I have an abstract class that deals with the certain reusable elements

        /// <summary>
    /// Gets the left bar button.
    /// </summary>
    /// <value>
    /// The left bar button.
    /// </value>
    protected abstract UIBarButtonItem LeftBarButtonInstance
    {
        get;
    }


    /// <summary>
    /// The _ left button item
    /// </summary>
    private UIBarButtonItem _LeftButtonItem = null;

    /// <summary>
    /// Gets the left bar button.
    /// </summary>
    /// <value>
    /// The left bar button.
    /// </value>
    public UIBarButtonItem LeftBarButton
    {
        get
        {
            if (_LeftButtonItem == null)
            {
                _LeftButtonItem = LeftBarButtonInstance;
            }
            return _LeftButtonItem;

        }
    }

Then in the class that implements the base class i have

        /// <summary>
    /// Gets the left bar button instance.
    /// </summary>
    /// <value>
    /// The left bar button instance.
    /// </value>
    protected override UIBarButtonItem LeftBarButtonInstance
    {
        get
        {
            var leftBarButton = new NavBarButton(Resources.UserIcon);
            leftBarButton.TintColor = UIColor.FromRGB(139, 177, 40);
            return leftBarButton;
        }
    }

I want to show a cell with a button in the collection view when the view first loads. That button will be pressed to open an action sheet where the user can then add cells with images to the collection view.

I have a set up two custom cell classes (one for the images cell and one for the button cell). I can load the view with the button cell displaying but I cannot link the button to the code on the collection view controller to trigger the action sheet to open. I have tried applying some of the suggestions already mentioned from other questions previously posted but have not been successful. Can someone help me fix the code below to get it to work. I am sure the problem lies in how I set up the Protocals and Delegates but can't figure out how to fix it. Thanks in advance.

ButtonAddPhotoCell.h

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@protocol AddImageButtonCellDelegate <NSObject>
@required
- (void)ButtonCell:(UICollectionViewCell *)cell Button:(UIButton*)item;
@end

@interface ButtonAddPhotoCell : UICollectionViewCell

@property (nonatomic, weak) IBOutlet UIButton<AddImageButtonCellDelegate> *buttonAddPhoto;

@end

ButtonAddPhotoCell.m

#import "ButtonAddPhotoCell.h"
#import <QuartzCore/QuartzCore.h>

@implementation ButtonAddPhotoCell

@synthesize buttonAddPhoto;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.shouldRasterize = YES;
        self.layer.borderWidth=2.0f;
        self.layer.borderColor=[UIColor blackColor].CGColor;
        self.buttonAddPhoto = [UIButton buttonWithType:UIButtonTypeCustom];
        self.buttonAddPhoto.frame = CGRectMake(0, 0, 100, 100);
        self.buttonAddPhoto.backgroundColor = [UIColor redColor];
        [self.buttonAddPhoto setImage:[UIImage imageNamed:@"photo_add_Button.png"]forState:UIControlStateNormal];

        //The line below is where I attempt to connect the button to the Action to open the Action sheet but it crashes.
        //[self.buttonAddPhoto ButtonCell:self Button:buttonAddPhoto];

        //The line below is just a placeholder for the line above. I wanted to see if the button was being clicked.
        [self.buttonAddPhoto addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.buttonAddPhoto];
    }
    return self;
}

- (void)buttonClicked:(UIButton *)sender
{
    NSLog(@"button clicked!");
}

@end

AddPhotosCollectionViewController.h

#import <UIKit/UIKit.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import <MobileCoreServices/UTCoreTypes.h>

#import "ImageAddAPhotoCell.h"
#import "ButtonAddPhotoCell.h"

@interface AddPhotosCollectionViewController : UIViewController
<UICollectionViewDataSource,UICollectionViewDelegate, UIActionSheetDelegate,UINavigationControllerDelegate,AddImageButtonCellDelegate>

@property (weak, nonatomic) IBOutlet UICollectionView *PhotosCollectionView;
@property(nonatomic,strong) NSMutableArray *arrayPhotos;

@end

AddPhotosCollectionViewController.m

#import "AddPhotosCollectionViewController.h"

@implementation AddPhotosCollectionViewController

@synthesize arrayPhotos =_arrayPhotos;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self.PhotosCollectionView registerClass:[ButtonAddPhotoCell class] forCellWithReuseIdentifier:@"ButtonCell"];
    [self.PhotosCollectionView registerClass:[ImageAddAPhotoCell class] forCellWithReuseIdentifier:@"PhotoCell"];
}

#pragma mark Action Sheet
//THIS IS PROBABLY WRONG.
- (void)ButtonCell:(UICollectionViewCell *)cell Button:(UIButton*)item;
{
    [item addTarget:self action:@selector(showActionSheet:) forControlEvents:UIControlEventTouchUpInside];
}

-(IBAction)showActionSheet:(id)sender
{
    //NSLog(@"Calling Action Sheet");
    }
}

#pragma mark Collection View Methods

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"PhotoCell";
    static NSString *identifier2 = @"ButtonCell";

        if (indexPath.item == self.arrayPhotos.count)
        {
            ButtonAddPhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier2 forIndexPath:indexPath];
            return cell;
        }
        else
        {
            ImageAddAPhotoCell *cell = (ImageAddAPhotoCell *)[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
            return cell;
        }
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView {
    // _data is a class member variable that contains one array per section.
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.arrayPhotos.count + 1;
}

I succesfully managed to connect an iPhone and a Mac using Bluetooth.

The iPhone is the central and the Mac is the peripheral. After the connection, both can communicate (the iPhone is subscribing to some characteristics, advertised by the Mac).

But, after some (random ?) time, the iPhone's Bluetooth icon is grayed out and the iPhone doesn't receive Bluetooth messages from the Mac anymore.

Why? How can I make the communication last?

EDIT : here is the error : advertised by didDisconnectPeripheral:

Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly.

So I have RightBarButtonItem on all my UIViewController and I want to be able to swipe from right to left to slide in and left to right to slide out.

As of now, I am using UIAnimate when user clicks on the RightBarButtonItem.
Here is my code.

public void animateSideMenu() {

var sideMenuExpandPos = new PointF (200.0f, 252.0f);
var sideMenuInitPos = new PointF (456.0f, 252.0f);
UIView.Animate (
    duration: 0.3f,
    delay: 0,
    options: UIViewAnimationOptions.CurveEaseInOut,
    animation: () => {
        if (Flag_SideMenu) {
            this.overlay.Layer.Hidden = true;
            view_SideMenu.Center = sideMenuInitPos;
            Flag_SideMenu = false;
        } else {
            this.overlay.Layer.Hidden = false;
            view_SideMenu.Center = sideMenuExpandPos;
            Flag_SideMenu = true;
        }
    },
    completion: () => {

    }
);
}

and then this is how I am setting my RightBarButtonItem.

this.NavigationItem.SetRightBarButtonItem (
    new UIBarButtonItem (UIImage.FromFile ("menuIcon.png")
    , UIBarButtonItemStyle.Plain
    , (sender, args) => {
        animateSideMenu();
    })
, true);

Please give me an idea on how I can setup gestures to swipe in and out.

Thank you for your time.