text:
Q: Set the background color of selected text in NSTextView? I am trying to change the background color of a portion of text that is selected by the user to a different color (to add a highlight) to the text. Now I have tried the:

*

*(void)setSelectedTextAttributes:(NSDictionary *)attributes

method but that only changes the background color of the selection. I need the to change the background color of text so that it stays highlighted.

A: As you've discovered, the selected text attributes only apply to the text while it's selected. If you want to add some attributes to the selected text that persist, you'll need to apply those attributes to the underlying NSTextStorage object (which is just a subclass of NSMutableAttributedString).
The way to do that is to use the text view's textStorage method and then apply the attributes using the addAttributes:range: method (or setAttributes:range: depending on whether you want to add to the existing text attributes or replace them altogether).


text:
Q: How to log results of Where method? I'm contemplating using a function block predicate in a fluent style Where clause to log some results, for example:
var bar = SomeEnumerable.Where(i =>
    {
        if(...)
        {
            return true;
        }
        else
        {
            //Log "failure" to in-memory List<T>
            return false;
        }
    }).Select(...);

Is there some other way I could capture this that would not introduce side-effect?
I was thinking along the lines of having a Linq extension method that could "tee" its result to more than one subsequent method. Is there already such an operator?
I agree 100% about keeping side-effect away from Linq, if possible.

A: It's your code, do what you want.
If you understand the implication of adding side effects to LINQ, i.e. it won't work with say, a SQL query, and you know it will only be run once .ToList() or similar is called.
Go for it!
Logging is a pretty safe side effect in most contexts and if you need the information in your telemetry, that's up to you. I might make it a method and not a lambda, just so readers later on can see clearly the intent.

A: In this case what you're doing here is not really filtering the sequence, but rather grouping the items into one of two different groups.  There are much better operators for doing this than Where.
var validatedItems = SomeEnumerable.ToLookup(item => IsValid(item));

foreach(var invalidItem in validatedItems[false])
{
    LogFailure(invalidItem);
}

var bar = validatedItem[true].Select(...);

Note that ToLookup here eagerly evaluates the source sequence and your validation logic.  If you wanted to defer the validation until later (while also avoiding multiple enumeration of the sequence, which you probably do want to do, given that it's doing validation logic) it would greatly complicate this.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Conditions in Event Storming I will explain this as an Album application problem.
I want to create a new Album but the Artist of that Album is not created yet.
There are 2 solutions to solve this problem:

*

*Create the Artist first, then create the Album

*When creating the Album, check if the Artist is created. If the Artist is not created, then create a new Artist and save that information to the Album.

I chose solution 2 and I want to present this using Event Storming.
I don't know how to present the solution correctly in timeline order.
So I have come to this.

I don't know if my solution is correct or not :(
And if it isn't, how to correctly present this?

A: I would try to make each step explicit so that you also can easily spot what transactions happen to what aggregate. So I assume you see artist and album as separate aggregates (not relevant for now if they live in the same bounded context or not). I would approach it in an event storming session somewhat like this:

*

*--> Create Album (Command)

*--> Album Created (Event)

*--> Check Artist of Created Album (Policy)

*--> Create Artist (Command)

*--> Artist Created (Event)

*--> Check for Existing Albums of New Artist (Policy)

*--> Link Artist to Album (Command)

*--> Artist of Album Updated (Event)

For me the policies usually mean: when policy X applies then perform command Y.
With that flow you would also guarantee that only one aggregate is created/modified at a time. Your current approach binds the simple creation of a new album to lots of other responsibilities in one go (e.g. checking if the artist already exists, if yes, creating the artist and afterwards creating the album). I like to get the most essential stuff done as quickly and simple as possible and separate subsequent steps. So here I would consider the creation of the album the highest goal of the user of the application. Because if they haven't created the artist first they obviously like to focus on album creation now more. If the artist entity is created in a second step should then be not of so much concern for the user.

A: It really depends why your business needs to know that an album has an artist.
On the face of it, I would say that both album and artist, if they are separate aggregates, should be created independently and exist regardless of  there being a link between the two.
You do not want to implement referential integrity between aggregates, it is eventual consistency. All should be able to exist without the other, it is just in a state of not having all information.
If you actually want to prevent the album from being created without there being an artist, then there should be a policy in which you will decide to create an album, but this will result in a create artist command, as the album needs an artist first.
If an artist already exists it is as simple as:
Create Album Policy -> Create Album -> Album -> Album Created
When an artist does not exist I would do something like this:
Create Album Policy -> Create Artist Command -> Artist -> Artist Created Event -> Create Album For New Artist Policy -> Create Album -> Album -> Album Created
These make sense when you have manual policies with a user, however if it is entirely automated then you might actually be talking about a single command and you might need to reconsider your aggregates, or at least your aggregate root.


text:
Q: How to insert a vector into one row of a data frame? I'm trying to insert a character vector into a row of a data frame rather than create a separate row for each value in the data frame. What I have so far:
a<- as.character(c(1:10))

data_frame <- as.data.frame(a)

Instead of 10 observations in 1 variable, I want 1 observation in 1 variable and that 1 observation would look like "1", "2"...."10" where each value in the vector is separated by a comma.

A: You can simply do transpose vector t:
df = data.frame(t(a))

  X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
1  1  2  3  4  5  6  7  8  9  10

A: Please try below. "I" is a function that inhibits the interpretation / conversion of objects as indicated by typing "?I" in the console.
data.frame(test = I(list(a)))


text:
Q: Error on update with Entity Framework 5: data may have been modified This is my repository with Entity Framework:
public class MetricRepository : IMetricRepository
{
    private readonly AccountStatsContext _context;

    public MetricRepository(AccountStatsContext context)
    {
        _context = context;
    }

    public async Task<bool> Add(MetricEntity metric)
    {
            metric.UpdatedOnUtc = DateTime.UtcNow;
            await _context.Metrics.AddAsync(metric).ConfigureAwait(false);
            await _context.SaveChangesAsync().ConfigureAwait(false);
            return true;
    }

    public async Task<bool> Update(MetricEntity metric)
    {
            metric.UpdatedOnUtc = DateTime.UtcNow;
            await _context.SaveChangesAsync();
            return true;
    }

    public async Task<MetricEntity> FindAsync(Expression<Func<MetricEntity, bool>> predicate)
    {
        return await _context.Metrics.SingleOrDefaultAsync(predicate);
    }
}

And in my table I have a composite primary key with 4 columns like this:
CREATE TABLE public.metrics
(
    category character (30) COLLATE pg_catalog."default" NOT NULL,
    code character (30) COLLATE pg_catalog."default" NOT NULL,
    repartition_key character (30) COLLATE pg_catalog."default" NOT NULL,
    date timestamp without time zone NOT NULL,
    value numeric(18,2),
    type character (5) COLLATE pg_catalog."default" NOT NULL,
    updated_on_utc timestamp without time zone NOT NULL,

    CONSTRAINT metrics_pkey PRIMARY KEY (category, code, repartition_key, date)
);

And the primary key is set in my Entity Framework repository
private void BuildEntity(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<MetricEntity>()
               .ToTable("metrics")
               .HasKey(c => new { c.Category, c.Code, c.RepartitionKey, c.Date });
}

When I make an insert it's ok but when I try to update a value, I get this error:

Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded

Here is my code for the update:
public async Task<BaseResponse> Handle(MetricsCommand request, CancellationToken cancellationToken)
{
    var requestMapped = _mapper.Map<MetricEntity>(request);
    var result = await _metricRepository.FindAsync(m => m.Category == requestMapped.Category && m.Code == requestMapped.Code && m.RepartitionKey == requestMapped.RepartitionKey && m.Date == requestMapped.Date);

    bool response = false;

    if (result == null)
        response = await _metricRepository.Add(requestMapped);
    else
    {
        result.Value = requestMapped.Value;
        result.Type = requestMapped.Type;
        response = await _metricRepository.Update(result);
    }

    return new BaseResponse(response);
}

A: The best way to use a database context is to create and dispose it right before and after it is used. But since you are already using another approach, I may only suppose that the following code can help you.
Insert the provided line after metric.UpdatedOnUtc = DateTime.UtcNow; in your Update method of MetricRepository class:
_context.Entry(metric).State = EntityState.Modified;

UPD:
If it doesn't help, there is another way of modifying entities in a dbcontext. Insert it in same place as the previous hint:
_context.Update(metric);

A: I always use this algoritm to update only several properties, it has never failed
  var metric = _mapper.Map<MetricEntity>(request); //I hope your code works properly

   var existedMetric = await _context.FindAsync(m => m.Category == requestMapped.Category && m.Code == requestMapped.Code && m.RepartitionKey == requestMapped.RepartitionKey && m.Date == requestMapped.Date);

if (existedMetric!=null)
{
 context.Entry(existedMetric).Property(m=> m.Value ).CurrentValue = metric.Value;
 context.Entry(existedMetric).Property(m=> m.Type).CurrentValue =  metric.Type;
 context.Entry(existedMetric).Property(m=> m.UpdatedOnUtc).CurrentValue =  DateTime.UtcNow;

 await _context.SaveChangesAsync();
}

A: Change your Generic Update method like this. You should  set the State of your Entity to Modified
 public async Task<bool> Update(MetricEntity metric)
 {
        metric.UpdatedOnUtc = DateTime.UtcNow;
        _context.Entry(metric).State = EntityState.Modified;
        await _context.SaveChangesAsync();
        return true;
 }


text:
Q: connect uitableviewcells to diffrent viws via segue I create a UITableView programmatically with different cells and sections that connects to the other views in storyboard like below picture:
My question is:
how can I connect these 3 cells to these different views ,would you please helping me
Thanks in advance!
Here is my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *key = [[self sectionKeys] objectAtIndex:[indexPath section]];
NSArray *contents = [[self sectionContents] objectForKey:key];
NSString *contentForThisRow = [contents objectAtIndex:[indexPath row]];

static NSString *CellIdentifier = @"CellIdentifier";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}

[[cell textLabel] setText:contentForThisRow];
return cell;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
_selectedIndex = indexPath.row;
[self.tableView reloadData];

}

Edit:
When I use this method It just load the WorkTime view even if user select the absence cell,
Does any one knows why ?
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
  _selectedIndex = indexPath.row;
[self.tableView reloadData];
//maybe you could use a switch/case here, to assign the correct string to the segue identifier.
 switch (indexPath.row){
    case 0:
        [self performSegueWithIdentifier:@"test" sender:self];
        break;
    case 1:
        [self performSegueWithIdentifier:@"set" sender:self];
        break;
    case 2:
        [self performSegueWithIdentifier:@"get" sender:self];
        break;
 }
 }

A: Your last method is the way you want to go, but by the looks of it, you need to be checking indexPath.section not indexPath.row


text:
Q: How to retain values from textarea after submitting the form I have a textarea and then I try to click Save as draft button or submit button. But when the page submits, the values on my textarea doesn't retain.
<textarea type="text" name="briefDescription" id="briefDescription" rows="12" cols="98" value="${briefDescription}" ></textarea>

Please teach me how to retain values of a textarea.
Thanks!

A: The content of the textarea should go between its start and end tag:
<textarea type="text" name="briefDescription" id="briefDescription" rows="12" cols="98">$briefDescription</textarea>


text:
Q: MPU9250 IMU wearable design considerations and device address problem I need to use 12-16 mpu9250 IMU for wearable design. Each IMU will be placed different places on the body. Therefore, I want to read data from each device by using I2C interface. However, problem is all mpu9250 devices have same device address -0x68- for I2C. So far I come up with multiplexer yet multiplexing might not be a good idea with I2C.
I also learnt that SPI will not be a good solution due to cable lengths.
I am looking for suggestions for overcoming device address problem for I2C interface and also system architecture.
(Another IMU is not an option)

A: Multiplexing. There exists chips designed especially for multiplexing I2C, and so far you have no evidence against using them.


text:
Q: Don't want IDM to catch my firefox plugin downloads I'm developing a FF extension which will be downloading zip files from server(s), saving to specific local location and unzipping the file.
But my problem is IDM plugin which is installed in my FF. Whenever I try to download a file from server IDM catches it and shows its download dialog.
I want to save file(s) at specific location (other than downloads dir), so I dont want IDM to catch it or else myPlugin will not get the file and download untill it gets file.
I guess IDM has implemented nslDownloadManager How to hook the download dialog in a Firefox extension? -------- https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIDownloadManagerUI?redirectlocale=en-US&redirectslug=nsIDownloadManagerUI
Should I implement this also to escape from IDM or any other downloader? I don't want to catch downloads; from; other than my plugin.
I'm using https://developer.mozilla.org/en-US/docs/Code_snippets/Downloading_Files#Downloading_files this function to download file. For testing purpose I press Control key to disable IDM plugin.
Can you please tell me what should I do to download zipped files from my plugin without getting caught in IDM???

A: If you want to temporary disable IDM for single download you may hold Alt  button while clicking on the download link of zipped files to prevent IDM from taking the download.

A: Turn off the browser integration


text:
Q: Kotlin IllegalStateException: Resource not found in classpath: kotlin/.kotlin_string_table I'm trying to play around with Kotlin a bit in my Android app and am having trouble calling extension functions. The app crashes immediately with the following stack trace:
04-23 13:31:22.415  32606-32606/com.example.kotlin.test E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.kotlin.test, PID: 32606
    java.lang.ExceptionInInitializerError
            at org.jetbrains.kotlin.load.kotlin.reflect.RuntimeModuleData$Companion.create(RuntimeModuleData.kt:34)
            at kotlin.reflect.jvm.internal.InternalPackage$moduleByClassLoader$cff17278.getOrCreateModule(moduleByClassLoader.kt:54)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:31)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:26)
            at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.get(ReflectProperties.java:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getDescriptor(KClassImpl.kt)
            at kotlin.reflect.jvm.internal.KClassImpl.getScope(KClassImpl.kt:43)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:72)
            at kotlin.reflect.ReflectPackage$KClassExtensions$6beb0f9b.getDeclaredProperties(KClassExtensions.kt:25)
            at kotlin.reflect.ReflectPackage.getDeclaredProperties(KClassExtensions.kt:1)
            at com.example.test.kotlin.api.model.DatabaseObject$$TImpl.deflate(DatabaseObject.kt:40)
            at com.example.test.kotlin.api.model.impl.Model.deflate(Model.kt)
            at com.example.test.kotlin.api.model.impl.Model.<init>(Model.kt:28)
            at com.example.test.kotlin.api.model.impl.TestModel.<init>(TestModel.kt:23)
            at com.example.app.TestModelIndexFragment.onCreate(TestModelIndexFragment.java:122)
            at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:915)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
            at android.app.Activity.performStart(Activity.java:5949)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
            at android.app.ActivityThread.access$900(ActivityThread.java:147)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
     Caused by: java.lang.IllegalStateException: Built-in library initialization failed. Please ensure you have kotlin-runtime.jar in the classpath:     java.lang.IllegalStateException: Resource not found in classpath: kotlin/.kotlin_string_table
            at org.jetbrains.kotlin.builtins.KotlinBuiltIns.initialize(KotlinBuiltIns.java:75)
            at org.jetbrains.kotlin.builtins.KotlinBuiltIns.getInstance(KotlinBuiltIns.java:93)
            at org.jetbrains.kotlin.platform.JavaToKotlinClassMapBuilder.init(JavaToKotlinClassMapBuilder.java:35)
            at org.jetbrains.kotlin.platform.JavaToKotlinClassMap.<init>(JavaToKotlinClassMap.java:44)
            at org.jetbrains.kotlin.platform.JavaToKotlinClassMap.<clinit>(JavaToKotlinClassMap.java:35)
            at org.jetbrains.kotlin.load.kotlin.reflect.RuntimeModuleData$Companion.create(RuntimeModuleData.kt:34)
            at kotlin.reflect.jvm.internal.InternalPackage$moduleByClassLoader$cff17278.getOrCreateModule(moduleByClassLoader.kt:54)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:31)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:26)
            at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.get(ReflectProperties.java:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getDescriptor(KClassImpl.kt)
            at kotlin.reflect.jvm.internal.KClassImpl.getScope(KClassImpl.kt:43)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:72)
            at kotlin.reflect.ReflectPackage$KClassExtensions$6beb0f9b.getDeclaredProperties(KClassExtensions.kt:25)
            at kotlin.reflect.ReflectPackage.getDeclaredProperties(KClassExtensions.kt:1)
            at com.example.test.kotlin.api.model.DatabaseObject$$TImpl.deflate(DatabaseObject.kt:40)
            at com.example.test.kotlin.api.model.impl.Model.deflate(Model.kt)
            at com.example.test.kotlin.api.model.impl.Model.<init>(Model.kt:28)
            at com.example.test.kotlin.api.model.impl.TestModel.<init>(TestModel.kt:23)
            at com.example.app.TestModelIndexFragment.onCreate(TestModelIndexFragment.java:122)
            at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:915)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
            at android.app.Activity.performStart(Activity.java:5949)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
            at android.app.ActivityThread.access$900(ActivityThread.java:147)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
     Caused by: java.lang.IllegalStateException: Resource not found in classpath: kotlin/.kotlin_string_table
            at org.jetbrains.kotlin.builtins.BuiltinsPackageFragment.getStream(BuiltinsPackageFragment.kt:86)
            at org.jetbrains.kotlin.builtins.BuiltinsPackageFragment.<init>(BuiltinsPackageFragment.kt:55)
            at org.jetbrains.kotlin.builtins.KotlinBuiltIns.<init>(KotlinBuiltIns.java:114)
            at org.jetbrains.kotlin.builtins.KotlinBuiltIns.initialize(KotlinBuiltIns.java:70)
            at org.jetbrains.kotlin.builtins.KotlinBuiltIns.getInstance(KotlinBuiltIns.java:93)
            at org.jetbrains.kotlin.platform.JavaToKotlinClassMapBuilder.init(JavaToKotlinClassMapBuilder.java:35)
            at org.jetbrains.kotlin.platform.JavaToKotlinClassMap.<init>(JavaToKotlinClassMap.java:44)
            at org.jetbrains.kotlin.platform.JavaToKotlinClassMap.<clinit>(JavaToKotlinClassMap.java:35)
            at org.jetbrains.kotlin.load.kotlin.reflect.RuntimeModuleData$Companion.create(RuntimeModuleData.kt:34)
            at kotlin.reflect.jvm.internal.InternalPackage$moduleByClassLoader$cff17278.getOrCreateModule(moduleByClassLoader.kt:54)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:31)
            at kotlin.reflect.jvm.internal.KClassImpl$descriptor$1.invoke(KClassImpl.kt:26)
            at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.get(ReflectProperties.java:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getDescriptor(KClassImpl.kt)
            at kotlin.reflect.jvm.internal.KClassImpl.getScope(KClassImpl.kt:43)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:84)
            at kotlin.reflect.jvm.internal.KClassImpl.getProperties(KClassImpl.kt:72)
            at kotlin.reflect.ReflectPackage$KClassExtensions$6beb0f9b.getDeclaredProperties(KClassExtensions.kt:25)
            at kotlin.reflect.ReflectPackage.getDeclaredProperties(KClassExtensions.kt:1)
            at com.example.test.kotlin.api.model.DatabaseObject$$TImpl.deflate(DatabaseObject.kt:40)
            at com.example.test.kotlin.api.model.impl.Model.deflate(Model.kt)
            at com.example.test.kotlin.api.model.impl.Model.<init>(Model.kt:28)
            at com.example.test.kotlin.api.model.impl.TestModel.<init>(TestModel.kt:23)
            at com.example.app.TestModelIndexFragment.onCreate(TestModelIndexFragment.java:122)
            at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:915)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
            at android.app.Activity.performStart(Activity.java:5949)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
            at android.app.ActivityThread.access$900(ActivityThread.java:147)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)

My project is composed of two modules, test-kt and app, for the new Kotlin stuff and existing Java code respectively. test-kt/build.gradle has the following:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
  compileSdkVersion 22
  buildToolsVersion "22.0.1"

  defaultConfig {
    minSdkVersion 9
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
  sourceSets {
    main.kotlin.srcDirs += 'src/main/kotlin'
    main.java.srcDirs += 'src/main/kotlin'
  }
}

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.android.support:appcompat-v7:22.0.0'
  compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}

buildscript {
  ext.kotlin_version = '0.11.91.2'
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.android.tools.build:gradle:1.1.0'
  }
}

repositories {
  mavenCentral()
}

I've tried adding the Kotlin libs as dependencies within app as well with no luck. Is there something I'm missing?
EDIT: Upon further investigation, it looks like this only happens whenever I use property references (such as ::x) and not when I use extension methods. I definitely have included kotlin-reflect... any ideas?

A: I just encountered this as well when upgrading to Kotlin version 0.11.91.2. There is apparently an issue where the Android toolset does not pack a file prepended with a dot into resources. (note that the file the exception references, .kotlin_string_table, is prepended with a dot).
A fix has been written but not yet released. You can try using the snapshot release of Kotlin in order to take advantage of it, or otherwise just wait for the next update.


text:
Q: Fixing css so it's relative to it's children (/responsive) Problem:
The header size is static now. For example if i wanted to change the image size or change my device it would collide with my underlying navigation (in this case the navigation just goes below the images because of their absolute tag).
How can i change this header to be responsive while the images are still on top of each other (fore and bg)?
HTML

Styling
.header {
    position: relative;
    height: 518.75px;
    width: 100%;
}

.header-parallax {
    padding: 20px 20px 20px 20px;
}

* {
  box-sizing: border-box;
}

.box {
  position: absolute;
  perspective: 400px;
  width: 750px;
  height: 478.75px;
  overflow: hidden;
  transform-style: preserve-3d;
  transition: perspective 5s;
}

.fore-box {
  z-index: 10;
}

.bg-box {
  z-index: 5;
}

.img {
  top: 0;
  left: 0;
  width: 750px;
  height: 478.75px;
  transition: all 5s;
}

.fore {
  z-index: 10;
  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/9332/hills-foreground.png);
  background-size: cover;
}

.bg {
  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/9332/hills-bg.jpg);
  transform: translateZ(150px);
  background-size: cover;
   filter: blur(2px);
}

.box.on .fore {
  transform: translateZ(200px);
 filter: blur(1px);
}
.box.on .bg {
  transform: translateZ(0);
  filter: blur(0px);
}

Image of it in the browser:

A: Hope this will help you

<!DOCTYPE html>


text:
Q: YouTube API onPlayerReady is Never Getting Called Follow this tutorial, I have been trying to integrate the YouTube API into my website. Specifically, when a button is pressed I want to play a video hosted on YouTube in fullscreen mode. Unfortunately, I can't even get the code given in that tutorial to work.
I'm using Slim for markup so I added an empty div with the ID of player as the tutorial suggests
.body
  .player

I then added this javascript at the end of my markup
  $(document).ready(
    function() {
      loadYoutubeAPI();
    });

Which should start the chain of calling these functions
function loadYoutubeAPI() {
    var tag = document.createElement('script');
    tag.src = "https://www.youtube.com/iframe_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}

var player;
function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
        height: '390',
        width: '640',
        videoId: 'M7lc1UVf-VE',
        events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange
        }
    });
}

function onPlayerReady(event) {
    event.target.playVideo();
}

var done = false;
function onPlayerStateChange(event) {
    if (event.data == YT.PlayerState.PLAYING && !done) {
        setTimeout(stopVideo, 6000);
        done = true;
    }
}

function stopVideo() {
    player.stopVideo();
}

However, the chain of calls stops before onPlayerReady fires and I can't figure out why.

A: From what I can see, it seems as though your issue may be in the player div seems to be of the class player and from what I can see in the tutorial, its looking for an div with player id. so something like the following may work:
.body
    #player

I am not 100% familiar with Slim so you may need to mark this up differently.


text:
Q: Why is the voltage between 2 phases in the wye connection sqrt(3)*E in a delta-wye system We've got a delta-wye combination of inductors.
So the delta part is connected to the/a 3-phase voltage source which delivers the voltage E across any combination of 2 phases.
So across the delta connection the voltage drop across each inductor is E.
Now it is claimed that the voltage drop across 2 of the inductors in the wye-connection is E * sqrt(3), in other words between any 2 phases in the wye connection.
Now I can't see the reasoning behind the last claim, how does one find that? And how exactly are the delta and wye connected togheter?

A: You need to understand phasor diagrams and then do some basic trigonometry. Consider this: -

The blue lines represent the voltages across each delta coil in your question. Now if you rearranged to a Y connection, to get the same voltage across each coil you would have to increase the line voltage (Vca, Vab or Vbc) by \$\sqrt3\$ to maintain the voltage across each coil as the same when it was delta wired. It's just trigonometry.


text:
Q: Is it safe to split a path on '/' to parse it? I am trying to get all directories in a path. For example, from a/b/c/d.e I would like to get a, a/b, and a/b/c. I can achieve this by calling functions like posixdirname several times. The problem is with paths like a/b/c/. I would like to get a, a/b, and a/b/c. Since there is a / following c, c should be a directory that I would like to list. But functions like dirname return a/b instead of a/b/c when given a/b/c/ as input.
Can I just split on / to get the list of directories or is there an edge case where this wouldn't work?

A: The only special cases I know are

*

*with file name at the end

*with a / at the end

*with a folder name called a.e (may or may be not at the end)

*symbolic link

*Windows path (which is using \ but I think it is not applying in your case)

*User input error, put multiple /. e.g. /tmp//something which is supported in some programmes

If your function is supporting all of the above cases, I think it is fine.


text:
Q: ActiveXObject() failing in IE8 on Win7 I'm running a website testing automation tool(Sahi). But before starting the website testing, I'm forst checking whether the testing tool is placed in drive C. So I'm writing a js to create a file system object:
function IsSahi_tool_Exists(DriveName)

{
    var folderBool = false;
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    if(DriveName != null) {
        folderBool = fso.FolderExists(DriveName + ":\Sahi_tool");
        if(folderBool == true)
        {
            folderBool = fso.FolderExists(DriveName + ":\Sahi_tool\sahi\bin");
        }
    }
return folderBool;

}
But this function is returning false, and as I'm sure the path exist, I assume the error is because of ActiveXObject failing. Tried discussing in sahi form but no response. I have tried the following:

*

*Enabling all ActiveX controls in IE8->Internet Option->Security

*Indtalling Flash Player with ActiveX.

*Start->Run->regsvr32 "C:\Program Files\Common Files\Microsoft Shared\DAO\DAO360.DLL".

But still I'm the function is returning false. If I commented this function call, sahi is continuing to test the website but stops at another ActiveXObject function call.
Please suggest me the procedure to enable ActiveX. No error is reported by the function ActiveXObject().
Thanks

A: Sahi runs Sahi script in the embedded rhino javascript engine. It does not have support for ActiveX in the rhino engine (You can access the ActiveX controls on the browser though)
Remember that Sahi scripts execute ONLY if Sahi is available and running. Your requirement is equivalent to writing a java program to check if java is installed.
Regards,


text:
Q: How to make error-chain errors compatible with Failure errors? Given the following code:
extern crate dotenv; // v0.11.0
#[macro_use]
extern crate failure; // v0.1.1

#[derive(Debug, Fail)]
#[fail(display = "oh no")]
pub struct Error(dotenv::Error);

Due to the fact that error-chain (v0.11, the latest) does not guarantee that its wrapped error is Sync (open PR to fix the issue) I get an error saying that Sync is not implemented for dotenv::Error:
error[E0277]: the trait bound `std::error::Error + std::marker::Send + 'static: std::marker::Sync` is not satisfied
 --> src/main.rs:5:17
  |
5 | #[derive(Debug, Fail)]
  |                 ^^^^ `std::error::Error + std::marker::Send + 'static` cannot be shared between threads safely
  |
  = help: the trait `std::marker::Sync` is not implemented for `std::error::Error + std::marker::Send + 'static`
  = note: required because of the requirements on the impl of `std::marker::Sync` for `std::ptr::Unique<std::error::Error + std::marker::Send + 'static>`
  = note: required because it appears within the type `std::boxed::Box<std::error::Error + std::marker::Send + 'static>`
  = note: required because it appears within the type `std::option::Option<std::boxed::Box<std::error::Error + std::marker::Send + 'static>>`
  = note: required because it appears within the type `error_chain::State`
  = note: required because it appears within the type `dotenv::Error`
  = note: required because it appears within the type `Error`

What's the minimal amount of boilerplate/work I can get away with to make these types play nicely together? The shortest thing I've been able to come up with is adding an ErrorWrapper newtype so that I can implement Error on an Arc<Mutex<ERROR_CHAIN_TYPE>>:
use std::fmt::{self, Debug, Display, Formatter};
use std::sync::{Arc, Mutex};

#[derive(Debug, Fail)]
#[fail(display = "oh no")]
pub struct Error(ErrorWrapper<dotenv::Error>);

#[derive(Debug)]
struct ErrorWrapper<T>(Arc<Mutex<T>>)
where
    T: Debug;

impl<T> Display for ErrorWrapper<T>
where
    T: Debug,
{
    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
        write!(f, "oh no!")
    }
}

impl<T> ::std::error::Error for ErrorWrapper<T>
where
    T: Debug,
{
    fn description(&self) -> &str {
        "whoops"
    }
}

// ... plus a bit more for each `From<T>` that needs to be converted into
// `ErrorWrapper`

Is this the right way to go about it? Is there something that will have less code/runtime cost for converting into an Arc<Mutex<T>> for things that don't need it?

A: The only thing that I can suggest is to remove the Arc type.
If you have something that is not Sync then wrap into a Mutex type, so
to integrate error-chain with failure just wrap dotenv::Error:
#[macro_use]
extern crate failure;
extern crate dotenv;
use std::sync::Mutex;

#[derive(Debug, Fail)]
#[fail(display = "oh no")]
pub struct Error(Mutex<dotenv::Error>);

fn main() {
    match dotenv::dotenv() {
        Err(e) => {
            let err = Error(Mutex::new(e));
            println!("{}", err)
        }
        _ => (),
    }
}


text:
Q: Drupal sharing content between two websites I am farmiar with building drupal sites but not sure what the best way to implement this scenario. I have two domain names mydomain.com and mydomain2.com. I need to have a conten type with some fields in. i.e.
ContentType
Field - Title
Field - Body
Field - Picture
Field - Price

I want both sites to use the same data for the custom conten type.  So you enter the data on one site and it will be updated on both.
mydomain.com will show the follwoing infromation from the content type.
ContentType
Field - Title
Field - Body
Field - Picture

mydomain2.com will show all the data.
mydomain.com and mydomain2.com will have diffent look nd feel. And each domain may use some diffent modules. mydomain2.com will be using ubercart and mydomain.com  will not.
Would I use mutlisite here and somehow sharte the tables. Use one instance of drupal and do the rest with theming? Use features and context?
Any help would be apreciated.

A: After doing some research this may be what I need http://drupal.org/project/domain. A case study can be found at http://drupal.org/node/369398.
Still wondering if there are otherways so not acepting this as the answer yet.

A: You just need to share tables between the sites.
You can share specific tables (best done in logicaly groups) accross Drupal 7 installs by adding something like this to your settings.php file:
$my_db_users = 'drupal_users.shared_';
$my_db_content = 'drupal_content.shared_';

$databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => 'defaultdatabase',
    'username' => 'databaseuser',
    'password' => 'databasepassword',
    'host' => '127.0.0.1',
    'port' => 3066,
    'prefix' => array(
        'default'   => 'default_',
        'users'     => $my_db_users,
        'sessions'  => $my_db_users,
        'role'      => $my_db_users,
        'authmap'   => $my_db_users,
        'node' => $my_db_content,
        'node_revisions' => $my_db_content,
        'node_type' => $my_db_content,
    ),
    'collation' => 'utf8_general_ci',
);

In the above instance, we set variables that point to different databases for certain groups of tables. So in the above example, we need three databases: defaultdatabase, drupal_users, and drupal_content.
Then in the array, we set the default table prefix 'default'   => 'default_', and that says: "store all tables, unless otherwise specified, in defaultdatabase and make their table prefix default_." We're also saying: "store all users, sessions, roles, and user-role mappings (authmap) in the database drupal_users with the table prefix shared_." And lastly, we're saying: "store all node types, nodes, and their revisions in the database drupal_content with the table prefix shared_."
With great power comes great responsibility:
You will completely hose your install if you don't keep logical groups of tables together.
What are logical groups of tables? Well, probably any table with the prefix node_ in your current install should probably be moved to the shared database. Most well structured modules (say node_access) will have their table name's prefixed with something logical. Based on your modules, ensure you keep groups of tables in the right place (in the default database for site-specific data, or in another database for shared data.)
Add a little bling:
I did a similar install where the users and roles were shared, but NOT the authmap. To what end?
Well, if you do this, you could have the same users and groups accross a large network of sites while still allowing users different permissions on different sites. On one site you may be an editor, but on another you'd be an author.

A: The Domain module looks good (although I haven't used it). It may be overkill for your needs.
If you want something very simple you can create a module which sets the global $custom_theme in hook_init() depending on the domain.

A: For me, if this was a critical portion of the site, I would create a custom module.  There are a few guides out there to create node_types through modules.  I happen to like this one.
That way, you have a basic structure of your data in a custom table and then can customize the call for displaying the data to either include the price column or not.
Again, some may see this as too much work but if you aren't familiar with Drupal module development, this is a great way to learn.  If you are familiar, it should be quick and simple.


text:
Q: How to get the real size of the image in image list I have a piece of code which shows the pictures in a specific size. I want to get the real size of the pictures and want to show those pictures in their real size.
Can anybody help me in this matter.
Here is the piece of code which I am using to get the pictures.
private void btnZoom_Click(object sender, EventArgs e)
{
    listView1.Items.Clear();
    imageList1.Images.Clear();

    string[] pics = System.IO.Directory.GetFiles("TestFolder//");
    listView1.View = View.SmallIcon;
    listView1.SmallImageList = imageList1;

    imageList1.ImageSize = new Size(64, 64);
    foreach (string pic in pics)
    {
        imageList1.Images.Add(Image.FromFile(pic));
    }
    for (int j = 0; j < imageList1.Images.Count; j++)
    {
        ListViewItem item = new ListViewItem();

        item.ImageIndex = j;

        listView1.Items.Add(item);
    }
}

It's a Windows Form App.

A: Here's another approach...store the Image and its Full Path FileName in the Tag property of your ListViewItem using a Tuple<Image, String>.
Something like:
    private void btnZoom_Click(object sender, EventArgs e)
    {
        listView1.Items.Clear();
        imageList1.Images.Clear();

        string[] pics = System.IO.Directory.GetFiles(@"C:\Users\mikes\Pictures\Facebook\Backyard Wildlife"); //"TestFolder//");
        listView1.View = View.SmallIcon;
        listView1.SmallImageList = imageList1;

        imageList1.ImageSize = new Size(64, 64);
        for(int i = 0; i < pics.Length; i++)
        {
            Image img;
            using (FileStream fs = new FileStream(pics[i], FileMode.Open))
            {
                try
                {
                    img = Image.FromStream(fs);
                    imageList1.Images.Add(img);

                    ListViewItem item = new ListViewItem();
                    item.ImageIndex = imageList1.Images.Count - 1;
                    item.Text = System.IO.Path.GetFileNameWithoutExtension(pics[i]);
                    item.Tag = new Tuple<Image, String>(img, pics[i]);
                    listView1.Items.Add(item);
                }
                catch (Exception ex) { };
            }

        }
    }

    private void btnView_Click(object sender, EventArgs e)
    {
        if (listView1.SelectedItems.Count > 0)
        {
            ListViewItem item = listView1.SelectedItems[0];
            Tuple<Image, String> data = (Tuple < Image, String >)item.Tag;
            label1.Text = data.Item2;
            pictureBox1.Image = data.Item1;
            Size sz = data.Item1.Size;
            label2.Text = sz.ToString();
        }
    }


text:
Q: Running a batch file and a single command I am a beginner at batch programming and I'm wondering if it is possible to run a batch file along with just one command already executed and accept a command from the user and execute it.
For example this is what I want to happen:
1) Run batch file
2) Type one command and press enter. The command executes.
But I want that all to happen just by running the batch file by itself.
This might be a very simple task to most of you but I've searched and can't get a solid solution.
Help is greatly appreciated. Thank you.

A: set /p Variab=Command_here:
%Variab%

This will take input to Variab and then execute the input.


text:
Q: Word for sadness at something ending, but excited about new Is there a word that describes the combination of feeling sad for an ending of something, but excited at new prospects. The closest I had was "bittersweet change"
Examples:

1) At the end of a holiday, I'm excited to go back home, but sad that the holiday is coming to an end.
2) I'm coming to end of my placement year job and sad that it's coming to an end, but excited that I'm going back to university.

I hope this satisfies the requirements of the QA here, if not, comment for me to correct.

A: Bittersweet is concise. Bittersweet conveys both emotion and the polarity of the situation in one word.

A: ambivalent 1. Simultaneously experiencing or expressing opposing or contradictory feelings, beliefs, or motivations.
You might also say you have mixed feelings about it.

A: Left with 'conflicting emotions' could be a good substitute.

A: Agrodolce is used in culinary language as sour and sweet. I think it also could mean sad and happy, an event that is both an ending and a beginning like high school graduation.

A: I have to admit I cheated on this question. I thought I had a word in my vocabulary to describe the emotion or state of mind you mentioned, and it eluded me simply because I couldn't jog my memory. The word I found is one I've never heard before - Saudade (English: /ˌsaʊˈdɑːdə/ - basically a "fancier" word for bitter-sweet.
The word I had on the tip of my tongue was also mentioned in the description, that being "a sense of nostalgia" or "feeling nostalgic". For me, personally, nostalgia is a reminiscence of great times... the good ol' days... mixed with a sadness that those days are over and can never be relived.

A: Ambivalence tends to hold a more apathetic connotation than what Tom is asking for, it feels a lot more like being undecided or unsure about how you feel than a bittersweet combination of happiness/sadness. 'Mixed feelings' suffers from the same problem, although I think it's a little bit closer.
My suggestions would be either to stick with 'bittersweetness', or go with 'conflicted'. I'd be dubious of 'elatasad'.

A: The Malay word "Sayang" has no equivalent word in English to describe a common emotion in Malaysia. it is affection, love, sorrow and pity all at the same time. - from > http://www.swiss-miss.com/2010/12/untranslatable-words.html

A: I feel sappy: I am more happy then sad, but I still recognize that I feel sadness.

A: You could try this one! elatasad,

Definition: feeling sad but also happy and excited.

Reference


text:
Q: Can I insert dictionaries with values list in a loop? key, values
(0, 1)
(0, 2)
(0, 6)
(0, 7)
(1, 0)
(1, 2)
(2, 1)
(2, 0)
(3, 4)
(3, 5)
(4, 3)
(5, 3)
(6, 0)
(7, 0)

I have problem with my python code. I want to insert data in the dictionaries in python. I see error like this:
N = len(g.nodes())

label_for_node = dict((i, v) for i, v in enumerate(g.nodes()))
node_for_label = dict((label_for_node[i], i) for i in range(N))

communities = dict((i, frozenset([i])) for i in range(N))
dq_dict = {}
H = MappedQueue()

partition = [[label_for_node[x] for x in c] for c in communities.values()]

dq_dict = dict(
        (i, dict( (j)
            for j in [ node_for_label[u] for u in g.neighbors(label_for_node[i])] if j != i))
                    for i in range(N))

TypeError: cannot convert dictionary update sequence element #0 to a sequence

The problem is I want to insert dict when index same with previous index. and I want to output like this:
{0: {1, 2, 6, 7},
1: {0, 2},
2: {1, 0},
3: {4, 5},
4: {3},
5: {3},
6: {0},
7: {0}}

top up saldo paypal

A: def dictify(data):
    result = dict()
    for key, value in data:
        if key in result:
            result[key].add(value)
        else:
            result[key] = set([value])
    return result

Example
>>> data
[(0, 1), (0, 2), (0, 6), (0, 7), (1, 0), (1, 2), (2, 1), (2, 0), (3, 4), (3, 5), (4, 3), (5, 3), (6, 0), (7, 0)]
>>> dictify(data)
{0: {1, 2, 6, 7},
 1: {0, 2},
 2: {0, 1},
 3: {4, 5},
 4: {3},
 5: {3},
 6: {0},
 7: {0}}

You can also achieve this using collections.defaultdict
from collections import defaultdict
def dictify(data):
    result = defaultdict(set)
    for key, value in data:
        result[key].add(value)
    return result

A: You can use collections.defaultdict.
from collections import defaultdict
l = [(0, 1), (0, 2), (0, 6), (0, 7), (1, 0), (1, 2), (2, 1), (2, 0), (3, 4), (3, 5), (4, 3), (5, 3), (6, 0), (7, 0)]
new_dict=defaultdict(set)
for k,v in l:
    new_dict[k].add(v)

defaultdict(set,
            {0: {1, 2, 6, 7},
             1: {0, 2},
             2: {0, 1},
             3: {4, 5},
             4: {3},
             5: {3},
             6: {0},
             7: {0}})

A: Dictionary's setdefault method is built for exactly this purpose. It takes in two arguments, the key value, and the default value for the key if the key isn't inserted yet in the dictionary. It then returns the value corresponding to the key.
l = [(0, 1), (0, 2), (0, 6), (0, 7), (1, 0), (1, 2), (2, 1), (2, 0), (3, 4), (3, 5), (4, 3), (5, 3), (6, 0), (7, 0)]
z={}
for k,v in l:
    z.setdefault(k,set()).add(v)


text:
Q: Make text bold in vim I am working on Ubuntu and using vim to make C files. I want to make the entire text in the editor bold. How can I do that without installing any plugin? I am not looking to make specific words bold. I am using a black background. Colors in bold would make the editor look really good.

A: You can use the :match command to apply a highlight to a given regular expression.
For gVim:
:highlight MyGroup gui=bold
:match MyGroup /./

For terminal:
:highlight MyGroup cterm=bold
:match MyGroup /./

A: The correct answer was given to me by one of the users @akira in one of the comments. I am just sharing it..
You can change the font only in GVim. Vim uses the fonts that you are using in the shell. So if you happen to be reading this and have the same requirement the best thing would be to change the settings of your shell such that it displays fonts in bold. I believe this is the best method.

A: You can make bold some elements of C file. For example
:highlight Comment gui=bold

will make comments in C files bold for GVim. For console Vim it will be
:highlight Comment cterm=bold

Unfortunately, I do not know other way to make all text bold except for making it bold for each highlight group (cComment, cNumber, etc.).

A: For Gvim only: Change the font to bold using(Monospace in this example)
:set guifont=Monospace\ Bold\ 11

Put it in your .gvimrc if you want to do it every time.

A: Adjust your terminal emulator's settings to make your fonts bold.
On a tty console, run:
$ sudo dpkg-reconfigure console-setup

and then adjust settings from there.
Note: You cannot do this in xterm.


text:
Q: If $v\not=0$, then $v/\|v\|$ has norm 1 The question is:

Show that if $\vec v$ is a non-zero vector in $\mathbb R^n$ then $\left( \dfrac{1}{||\vec v||} \right ) \vec v$ has  norm $1$.

I assume that $\vec v=(v_1,v_2,v_3,...,v_n)$ , where $n= 1,2,...$
$$
||\vec v||= \sqrt{v_1^2+v_2^2+...v_n^2}
$$
but I try to find out the track to solve $\left( \dfrac{1}{||\vec v||} \right ) \vec v$  to get norm $1$ but unfortunately I couldn't.
Please help me..

A: Just compute the norm of the vector ${1\over \|v\|}v={v\over \|v\|}$:
$$\left\|{v\over \|v\|}\right\|={1\over \|v\|}\|v\|=1.$$
On the first equality, we have used the (absolute) homogeneous property norms.


text:
Q: Failed to exec start script - EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16) I have installed node 8.10 and downgrade to npm 4 because i have error message with npm 5.
*******************************************************************************
ERROR: npm 5 is not supported yet

Then I use the command to downgrade npm
    npm install -g npm@4.
So I create my projet
$>npm install -g create-react-native-app
$>create-react-native-app AwesomeProject
$>cd AwesomeProject
$>npm start

And then I have the following error message.
> AwesomeProject@0.1.0 start /private/var/root/AwesomeProject
> react-native-scripts start

09:42:16: Unable to start server
See https://git.io/v5vcn for more information, either install watchman or run the following snippet:
  sudo sysctl -w kern.maxfiles=5242880
  sudo sysctl -w kern.maxfilesperproc=524288

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! AwesomeProject@0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the AwesomeProject@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/root/.npm/_logs/2018-03-23T08_42_16_152Z-debug.log

I have a look to the logfile
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@4.6.1
3 info using node@v8.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle AwesomeProject@0.1.0~prestart: AwesomeProject@0.1.0
6 silly lifecycle AwesomeProject@0.1.0~prestart: no script for prestart, continuing
7 info lifecycle AwesomeProject@0.1.0~start: AwesomeProject@0.1.0
8 verbose lifecycle AwesomeProject@0.1.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle AwesomeProject@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/private/var/root/AwesomeProject/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
10 verbose lifecycle AwesomeProject@0.1.0~start: CWD: /private/var/root/AwesomeProject
11 silly lifecycle AwesomeProject@0.1.0~start: Args: [ '-c', 'react-native-scripts start' ]
12 silly lifecycle AwesomeProject@0.1.0~start: Returned: code: 1  signal: null
13 info lifecycle AwesomeProject@0.1.0~start: Failed to exec start script
14 verbose stack Error: AwesomeProject@0.1.0 start: `react-native-scripts start`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:126:13)
14 verbose stack     at EventEmitter.emit (events.js:214:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:126:13)
14 verbose stack     at ChildProcess.emit (events.js:214:7)
14 verbose stack     at maybeClose (internal/child_process.js:925:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
15 verbose pkgid AwesomeProject@0.1.0
16 verbose cwd /private/var/root/AwesomeProject
17 verbose Darwin 17.2.0
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 verbose node v8.10.0
20 verbose npm  v4.6.1
21 error code ELIFECYCLE
22 error errno 1
23 error AwesomeProject@0.1.0 start: `react-native-scripts start`
23 error Exit status 1
24 error Failed at the AwesomeProject@0.1.0 start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

Have you an idea?
Best regard.

A: Try these steps:

*

*npm install -g npm@latest to update npm because it is sometimes buggy.

*rm -rf node_modules to remove the existing modules.

*npm install to re-install the project dependencies.


text:
Q: Creating a truth table for two 4 bit numbers A[3:0] and B[3:0] for inputs and an output that is 1 when A and B are equal and 0 when false I am having trouble creating this truth table. I know truth tables have every possible outcomes of A and B, such as A[3:0]
0000
0001
0010...
But when I place the inputs along together, A and B are always equal. This doesn't seem logical to me. Could anyone explain?

A: You will have 256 lines in your truth table.

*

*When B is 0000, A could be any of 0000 to 1111.

*When B is 0001, A could be any of 0000 to 1111.

*When B is 0010, A could be...

Well you get the point.
The output will only be 1 when A equals B which will be in 16 different cases.


text:
Q: Hashrockets in schema.rb after a migration After runnings on migrations on Rails 6.1.4.6, and Ruby 2.7, the db/schema.rb is changed to the old format of hash rockets as shown by the git diff below:
-    t.geometry "column", limit: { srid: 1234, type: "st_point" }
+    t.geometry "column", limit: {:srid=>1234, :type=>"st_point"}

Any ideas how to change it back to using the newer Ruby way (ie. not with hash rockets)?


text:
Q: Trying to Save My Timer to UserDefaults When The App Gets "Killed" This is a timer App and I would like for the timer to pause when the app gets killed and when you reopen the app I would like the timer to display the last known time.
I have setup a struct for the data to be saved to.
let defaults = UserDefaults.standard
private enum TimeData {
    static let allCurrentTime = "allCurrentTime"
}

override func viewDidLoad() {
    super.viewDidLoad()

    checkForSavedTimer()
    marksSavedData()
    theTimer.text = "00:00:00"
    theTimer.font = UIFont(name: "Menlo-BoldItalic", size: 40)
    marksTableView.isHidden = false
}

//I set the timer info to the struct (see below)

@objc func updateTimerLabel() {
    seconds += 1

    if seconds == 60 {
        minutes += 1
        seconds = 0
    }else if minutes == 60 {
        hours += 1
        minutes = 0
    }

    timerString = "\(hours):\(minutes):\(seconds)"
    theTimer.text = timerString
    defaults.set(theTimer.text, forKey: TimeData.allCurrentTime)
}

// I then created a function which I called in the viewdidload above

func checkForSavedTimer() {
   let allCurrentTime = defaults.value(forKey: TimeData.allCurrentTime) as? String ?? ""
   theTimer.text = allCurrentTime
}

I thought this would take the string from theTimer save it to the UserDefaults and then in viewDidLoad bring it back out and save it to "theTimer.text" BUT the result is 00:00:00

A: When you are calling your checkForSavedTimer() function, it is probably getting the correct value from UserDefaults but then you are setting the timer text back to 00:00:00 two lines later. You will need to remove that line and add some logic within your checkForSavedTimer() function to set the value to 00:00:00 if the value from UserDefaults is nil
override func viewDidLoad() {
    super.viewDidLoad()

    checkForSavedTimer()
    marksSavedData()
    // Remove this -> theTimer.text = "00:00:00"
    theTimer.font = UIFont(name: "Menlo-BoldItalic", size: 40)
    marksTableView.isHidden = false
}

func checkForSavedTimer() {

    // Set the timer text to the value from UserDefaults or "00:00:00" if the value is nil
    theTimer.text = defaults.string(forKey: TimeData.allCurrentTime) ?? "00:00:00"
}

Also it is better to use .string(forKey:) to get a String from UserDefaults because then the value is already typed for you and therefore you don't need to add as? String


text:
Q: How to fix the error "tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. " I have trained two simple CNN models to recognize license number and transfer them into two functions: predict_provinces.py and predict_digits.py. They can run individually and return the true number. However, when they run together, the error appear as "tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. "
I have tried to use the argument
saver = tf.train.import_meta_graph(os.path.join(SAVER_DIR, 'model.ckpt.meta'),clear_devices=True), but it doesn't help.

predict_provinces.py
import tensorflow as tf
import os
import PlateNumberRecognition.config as config
import cv2
import numpy as np

NUM_CLASSES = config.DIGITS_NUM_CLASSES
SAVER_DIR = config.DIGITS_SAVER_DIR
HEIGHT = config.HEIGHT
WIDTH = config.WIDTH
CHANNEL_NUM = config.CHANNEL_NUM
LETTERS_DIGITS=config.LETTERS_DIGITS
def digit_predict(digit_arr):
    saver = tf.train.import_meta_graph(os.path.join(SAVER_DIR, 'model.ckpt.meta'))
    x = tf.placeholder(tf.float32, shape=[None, HEIGHT, WIDTH, CHANNEL_NUM])
    with tf.Session() as sess:
        model_file = tf.train.latest_checkpoint(SAVER_DIR)
        saver.restore(sess, model_file)
        conv1_w = sess.graph.get_tensor_by_name('layer1-conv1/weight:0')
        conv1_b = sess.graph.get_tensor_by_name('layer1-conv1/bias:0')
        conv1 = tf.nn.conv2d(x, conv1_w, strides=[1, 1, 1, 1], padding='SAME')
        relu1 = tf.nn.relu(tf.nn.bias_add(conv1, conv1_b))
        pool1 = tf.nn.max_pool(relu1, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME')

        conv2_w = sess.graph.get_tensor_by_name('layer3-conv2/weight:0')
        conv2_b = sess.graph.get_tensor_by_name('layer3-conv2/bias:0')
        conv2 = tf.nn.conv2d(pool1, conv2_w, strides=[1, 1, 1, 1], padding='SAME')
        relu2 = tf.nn.relu(tf.nn.bias_add(conv2, conv2_b))
        pool2 = tf.nn.max_pool(relu2, [1, 1, 1, 1], [1, 1, 1, 1], padding='SAME')

        fc1_w = sess.graph.get_tensor_by_name('layer5-fc1/weight:0')
        fc1_b = sess.graph.get_tensor_by_name('layer5-fc1/bias:0')
        pool_shape = pool2.get_shape().as_list()
        nodes = pool_shape[1] * pool_shape[2] * pool_shape[3]

        reshaped = tf.reshape(pool2, [-1, nodes])
        fc1 = tf.nn.relu(tf.matmul(reshaped, fc1_w) + fc1_b)

        fc2_w = sess.graph.get_tensor_by_name('layer6-fc2/weight:0')
        fc2_b = sess.graph.get_tensor_by_name('layer6-fc2/bias:0')

        result = tf.nn.softmax(tf.matmul(fc1, fc2_w) + fc2_b)

        _, binary = cv2.threshold(digit_arr, 127, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
        # print(binary.shape)
        # cv2.imshow('window1', binary)
        # cv2.waitKey(0)
        for i in range(binary.shape[0]):
            for j in range(binary.shape[1]):
                if binary[i][j]==0:
                    binary[i][j]=1
                else:
                    binary[i][j]=0
        img_data = np.reshape(binary,[1, HEIGHT, WIDTH, CHANNEL_NUM])
        result = sess.run(result, feed_dict={x: np.array(img_data)})

        max = 0
        max_index = 0

        for j in range(NUM_CLASSES):
            if result[0][j] > max:
                max = result[0][j]
                max_index = j
                continue
    return config.LETTERS_DIGITS[max_index]

predict_digits.py
predict_provinces.py
import tensorflow as tf
import os
import PlateNumberRecognition.config as config
import numpy as np
import PlateNumberRecognition
NUM_CLASSES = config.PROVINCE_NUM_CLASSES
SAVER_DIR = config.PROVINCE_SAVER_DIR
HEIGHT = config.HEIGHT
WIDTH = config.WIDTH
CHANNEL_NUM = config.CHANNEL_NUM

SIZE = config.SIZE
PROVINCES = config.PROVINCES

def predict_provinces(pro_arr):
    x = tf.placeholder(tf.float32, shape=[None, HEIGHT, WIDTH, CHANNEL_NUM])
    saver = tf.train.import_meta_graph(os.path.join(SAVER_DIR, 'model.ckpt.meta'),clear_devices=True)
    with tf.Session() as sess:
        model_file = tf.train.latest_checkpoint(SAVER_DIR)
        saver.restore(sess, model_file)
        conv1_w = sess.graph.get_tensor_by_name('layer1-conv1/weight:0')
        conv1_b = sess.graph.get_tensor_by_name('layer1-conv1/bias:0')

        conv1 = tf.nn.conv2d(x, conv1_w, strides=[1, 1, 1, 1], padding='SAME')
        relu1 = tf.nn.relu(tf.nn.bias_add(conv1, conv1_b))
        pool1 = tf.nn.max_pool(relu1, [1, 2, 2, 1], [1, 2, 2, 1], padding='SAME')

        conv2_w = sess.graph.get_tensor_by_name('layer3-conv2/weight:0')
        conv2_b = sess.graph.get_tensor_by_name('layer3-conv2/bias:0')
        conv2 = tf.nn.conv2d(pool1, conv2_w, strides=[1, 1, 1, 1], padding='SAME')
        relu2 = tf.nn.relu(tf.nn.bias_add(conv2, conv2_b))
        pool2 = tf.nn.max_pool(relu2, [1, 1, 1, 1], [1, 1, 1, 1], padding='SAME')

        fc1_w = sess.graph.get_tensor_by_name('layer5-fc1/weight:0')
        fc1_b = sess.graph.get_tensor_by_name('layer5-fc1/bias:0')
        pool_shape = pool2.get_shape().as_list()
        nodes = pool_shape[1] * pool_shape[2] * pool_shape[3]

        reshaped = tf.reshape(pool2, [-1, nodes])
        fc1 = tf.nn.relu(tf.matmul(reshaped, fc1_w) + fc1_b)

        fc2_w = sess.graph.get_tensor_by_name('layer6-fc2/weight:0')
        fc2_b = sess.graph.get_tensor_by_name('layer6-fc2/bias:0')

        result = tf.nn.softmax(tf.matmul(fc1, fc2_w) + fc2_b)

        img_data = np.reshape(pro_arr, [1, HEIGHT, WIDTH, CHANNEL_NUM])
        result = sess.run(result, feed_dict={x: np.array(img_data)})

        max = 0
        max_index = 0

        for j in range(NUM_CLASSES):
            if result[0][j] > max:
                max = result[0][j]
                max_index = j
                continue
        license_number = PROVINCES[max_index]
    return license_number

test.py
import PlateNumberRecognition.predict_digits as pd
import PlateNumberRecognition.predict_provinces as pp
import cv2
import tensorflow as tf
pic_1=cv2.imread('6.bmp',0)
pic_2=cv2.imread('1.bmp',0)
pp.predict_provinces(pic_2)
pd.digit_predict(pic_1)

the error
G:\Pycharm\test\venv\Scripts\python.exe C:/Users/asus/Desktop/Intelligent-Transportation/PlateNumberRecognition/test.py
2019-03-19 17:21:24.765040: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Traceback (most recent call last):
  File "G:\Pycharm\test\venv\lib\site-packages\tensorflow\python\client\session.py", line 1334, in _do_call
    return fn(*args)
  File "G:\Pycharm\test\venv\lib\site-packages\tensorflow\python\client\session.py", line 1319, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "G:\Pycharm\test\venv\lib\site-packages\tensorflow\python\client\session.py", line 1407, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [512,6] rhs shape= [512,34]

I expect to use these two functions together

A: I have already solve the problem by using two graph to run the two functions respectively.
Changed test.py is as follow:
import PlateNumberRecognition.predict_digits as pd
import PlateNumberRecognition.predict_provinces as pp
import cv2
import tensorflow as tf
pic_1=cv2.imread('6.bmp',0)
pic_2=cv2.imread('1.bmp',0)
g1=tf.Graph()
with g1.as_default():
    pp.predict_provinces(pic_2)
g2=tf.Graph()
with g2.as_default():
    pd.digit_predict(pic_1)

However, I don't know why it can fix this problem...


text:
Q: Applying javascript function to multiple div tags I have a html page that as on the index page 16 boxes, Inside on box 3 other boxes are there, I want to interchange the inner boxes periodically:
One box represented as:

As stated before there are 16 of this kind of boxes
I have a javascript function that can adequately switch through if it is called once on one box
Javascript function is:
function Animation(Id_value) {
/*Image Changer for Index_two*/
var Id_num = Id_value
var x = 0
var Images = new Array("Box_one", "Box_two", "Box_three");
one = setInterval(function() {
    var Id = "div#" + Id_num + "> div#" + Images[x]
    $(Id).fadeOut(1000);
    x++
    if (x==2){
        clearInterval(one)
        two = setInterval(function() {
            x--
            var Di = "div#" + Id_num + "> div#" + Images[x]
            $(Di).fadeIn(1000);
            if (x==0) {
                clearInterval(two)
                three = setInterval(function() {
                    var Iv = "div#" + Id_num + "> div#" + Images[x]
                    $(Iv).fadeOut(1000);
                    x++
                    if (x==2){
                        clearInterval(three);
                        four = setInterval(function() {
                            x--
                            var Vi = "div#" + Id_num + "> div#" + Images[x]
                            $(Vi).fadeIn(1000);
                            if (x==0) {
                                clearInterval(four)
                                five = setInterval(function() {
                                    var Dv = "div#" + Id_num + "> div#" + Images[x]
                                    $(Dv).fadeOut(1000);
                                    x++
                                    if (x==2) {
                                        clearInterval(five)
                                        six = setInterval(function() {
                                            x--
                                            var Vd = "div#" + Id_num + "> div#" + Images[x]
                                            $(Vd).fadeIn(1000);
                                        }, 1000)
                                    }
                                }, 1000)
                            }
                        }, 1000)
                    }
                }, 1000);
            }
        }, 1000);
    }
}, 1000);
/*End of Image Changer*/
};

It does it 3 times, Instead of writing this kind of function custom for all my 16 boxes which i consider redundant, I did this
$(document).ready(function() {
   Animation("Index_one");
   Animation("Index_two");
   Animation("Index_three");
   Animation("Index_four");
   Animation("Index_five");
   Animation("Index_six");
   Animation("Mid_one");
   Animation("Mid_two");
   Animation("Mid_three");
   Animation("Mid_four");
   Animation("bottom_one");
   Animation("bottom_two");
   Animation("bottom_three");
   Animation("bottom_four");
   Animation("bottom_five");
   Animation("bottom_six");
 }

Thinking this should work but did not according to how the function was written, please any help explained properly would be appreciated.

A: Something like this:
// FIRST OPTION
var divlist = ["Index_one","Index_two","Index_three","Index_four","Index_five","Index_six","Mid_one","Mid_two","Mid_three","Mid_four","bottom_one","bottom_two","bottom_three","bottom_four","bottom_five","bottom_six"];
for (div in divlist) {
    Animation(divlist[div]);
}

// SECOND OPTION
// (having in mind that box class is applied only on targeted divs
$('.box').each(function() {
    Animation(this.id);
});

Second option is using jQuery each function. It first finds all of div tags with box class and then iterates over them. During the iteration, each of the found div is called in Animation(this).

A: You can use jQuery.delay() to animate elements sequentially.
HTML:
<input type="button" id="fadeAllOut" value="Fade all out!" />

JavaScript:
$(document).on("click", "#fadeAllOut", function (e) {
    var elems = $(".Divbox");

    //variable for accumulating delay
    var delay = 0;

    //needed duration
    var duration = 500;

    $.each(elems, function (index, element) {
        $(element).delay(delay).fadeOut(duration);
        /*or if you want just hide but not remove elements from layout, use this:
        .animate({
            opacity: 0
        }, duration);*/

        //accumulate delay
        delay += duration;
    });
});

Here is the Demo.
It is just a starting point, trying to understand your requirements

A: I think, from what it looks like, that the way you called the function (each time with a different id) didn't work because they were starting asynchronously and there for getting entangled in each other's animation.
You can use a recursion and call the next function from within the function itself.
I also replaced your setInterval and clearInterval calls with setTimeout, this make the code a little cleaner and more readable (and even a bit more efficient).
NOTE: I've replaced also the sixth (the last) call to setInterval with setTimeout although you don't clear that one (which is a bug, I think).
var elements = ["Index_one","Index_two","Index_three","Index_four","Index_five","Index_six","Mid_one","Mid_two","Mid_three","Mid_four","bottom_one","bottom_two","bottom_three","bottom_four","bottom_five","bottom_six"];

function Animation(listIndex, elementList) {
   /*Image Changer for Index_two*/
   var Id_value = elementList[listIndex];
   var Id_num = Id_value
   var x = 0
   var Images = new Array("Box_one", "Box_two", "Box_three");
   one = setTimeout(function() {
       var Id = "div#" + Id_num + "> div#" + Images[x]
       $(Id).fadeOut(1000);
       x++
       if (x==2){
           two = setTimeout(function() {
               x--
               var Di = "div#" + Id_num + "> div#" + Images[x]
               $(Di).fadeIn(1000);
               if (x==0) {
                   three = setTimeout(function() {
                       var Iv = "div#" + Id_num + "> div#" + Images[x]
                       $(Iv).fadeOut(1000);
                       x++
                       if (x==2){
                           four = setTimeout(function() {
                               x--
                               var Vi = "div#" + Id_num + "> div#" + Images[x]
                               $(Vi).fadeIn(1000);
                               if (x==0) {
                                   five = setTimeout(function() {
                                       var Dv = "div#" + Id_num + "> div#" + Images[x]
                                       $(Dv).fadeOut(1000);
                                       x++
                                       if (x==2) {
                                           six = setTimeout(function() {
                                               x--
                                               var Vd = "div#" + Id_num + "> div#" + Images[x]
                                               $(Vd).fadeIn(1000, function(){
                                                 Animation(++listIndex, elementList); // This will call this function with the next index but only when the fadein animation will finish.
                                               });
                                            }, 1000)
                                       }
                                   }, 1000)
                               }
                           }, 1000)
                       }
                   }, 1000);
               }
           }, 1000);
       }
   }, 1000);
   /*End of Image Changer*/
};

Animation(0, elements) // Call the Animation function with the first element index to start it all off

Also, to clean up your code a little, instead of using setInterval (or setTimeout) you can pass the next fadein function as a call back to the jquery fadein method, as the second argument (the complete argument) which will be called when the fadein animation is complete. Like I'v done for the last (six) call to fadein where I call the Animation function with the next element id). You can read about it in jQuery's fadein docs:
http://api.jquery.com/fadein/


text:
Q: Android XML resize / fit ImageButton different screens I made ImageButton menu design in the hopes that its size can adjust the screen:
but after I test using with smartphone 3-inch 320x480
, 4-inch 480x800, 5-inch 720x1280, view ImageButton is mess.
I've tried using TableLayout, LinearLayout, GridLayout,
and FrameLayout, but the result is the same.
Thank you in advance.This picture my trial results
This my XML code :
<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"
    android:background="@drawable/bg"
    android:orientation="vertical"
    tools:context=".MainActivity" >

     <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:id="@+id/linear1">
            <ImageView
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:scaleType="fitCenter"
                android:layout_gravity="center"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:src="@drawable/title"
                android:contentDescription="title"/>
    </LinearLayout>

      <ImageButton
        android:id="@+id/imagebutton0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/linear1"
        android:layout_centerHorizontal="true"
        android:scaleType="fitXY"
        android:background="@drawable/image"
        android:tag="0"
        tools:ignore="contentDescription" />

    <ImageButton
        android:id="@+id/imagebutton2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imagebutton0"
        android:layout_toLeftOf="@+id/imagebutton4"
        android:scaleType="fitXY"
        android:background="@drawable/image"
        android:tag="2"
        tools:ignore="contentDescription" />

    <ImageButton
        android:id="@+id/imagebutton4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imagebutton0"
        android:layout_centerHorizontal="true"
        android:scaleType="fitXY"
        android:background="@drawable/image"
        android:tag="4"
        tools:ignore="contentDescription" />

    <ImageButton
        android:id="@+id/imagebutton3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imagebutton0"
        android:layout_toRightOf="@+id/imagebutton4"
        android:scaleType="fitXY"
        android:background="@drawable/image"
        android:tag="3"
        tools:ignore="contentDescription" />

   <ImageButton
        android:id="@+id/imagebutton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imagebutton4"
        android:layout_centerHorizontal="true"
        android:scaleType="fitXY"
        android:background="@drawable/image"
        android:tag="1"
        tools:ignore="contentDescription" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal|center_vertical"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true"
        android:id="@+id/linear2"
         android:layout_below="@+id/imagebutton1">

        <TextView
            android:id="@+id/ib1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:drawableTop="@drawable/ib1"
            android:gravity="center"
            android:text=""
            android:scaleType="fitXY"/>

        <TextView
            android:id="@+id/ib2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:drawableTop="@drawable/ib2"
            android:gravity="center"
            android:text=""
            android:scaleType="fitXY"/>

        <TextView
            android:id="@+id/ib3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:drawableTop="@drawable/ib3"
            android:gravity="center"
            android:text=""
            android:scaleType="fitXY"/>

         <TextView
            android:id="@+id/ib4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:drawableTop="@drawable/ib4"
            android:gravity="center"
            android:text=""
            android:scaleType="fitXY"/>
    </LinearLayout>
</RelativeLayout>

A: I created a scratch which will define layout with linear and weight
I hope it will help you out
Also attached code with screen shots

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"
        android:orientation="vertical">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitCenter"
            android:src="@mipmap/ic_launcher" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.5"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/ic_launcher" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@mipmap/ic_launcher" />

            <ImageView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@mipmap/ic_launcher" />

            <ImageView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:src="@mipmap/ic_launcher" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@mipmap/ic_launcher" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:gravity="center"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@mipmap/ic_launcher" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@mipmap/ic_launcher" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@mipmap/ic_launcher" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@mipmap/ic_launcher" />

    </LinearLayout>

</LinearLayout>


text:
Q: Dropdown menu open on hover instead of click on shopify I'm trying to edit a shopify theme and the last part I'm stuck on is getting these navigation menus to open on hovering instead of clicking.  The css I have for the menus is:
.site-nav {
  position: relative;
  padding: 0;
  text-align: center;
  margin: 25px 0;

  a {
    padding: 3px 10px;
  }

  li {
    display: inline-block;
  }
}

.site-nav--centered {
  padding-bottom: $gutter-site-mobile;
}

/*================ Site Nav Links ================*/
.site-nav__link {
  display: block;
  white-space: nowrap;

  .site-nav--centered & {
    padding-top: 0;
  }

  .icon-chevron-down {
    width: 8px;
    height: 8px;
    margin-left: 2px;

    .site-nav--active-dropdown & {
      transform: rotateZ(-180deg);
    }
  }

  &.site-nav--active-dropdown {
    border: 1px solid $color-border;
    border-bottom: 1px solid transparent;
    z-index: 2;
  }
}

/*================ Dropdowns ================*/
.site-nav--has-dropdown {
  position: relative;
}

.site-nav--has-centered-dropdown {
  position: static;
}

.site-nav__dropdown {
  display: none;
  position: absolute;
  left: 0;
  padding: $dropdown-padding;
  margin: 0;
  z-index: $z-index-dropdown;
  text-align: left;
  border: 1px solid $color-border;
  background: $color-bg;
  left: -1px;
  top: 41px;

  .site-nav__link {
    padding: 4px 30px 4px 0;
  }

  .site-nav--active-dropdown & {
    display: block;
  }

  li {
    display: block;
  }
}

// Centered dropdown
.site-nav__dropdown--centered {
  width: 100%;
  border: 0;
  background: none;
  padding: 0;
  text-align: center;
}

The HTML and Liquid for the header is:
      {% if section.settings.align_logo == 'left' %}

          {% include 'site-nav' %}

      {% endif %}

And the relevant menu Javascript:
/* ================ MODULES ================ */
window.theme = window.theme || {};

theme.Header = (function() {
  var selectors = {
    body: 'body',
    navigation: '#AccessibleNav',
    siteNavHasDropdown: '.site-nav--has-dropdown',
    siteNavChildLinks: '.site-nav__child-link',
    siteNavActiveDropdown: '.site-nav--active-dropdown',
    siteNavLinkMain: '.site-nav__link--main',
    siteNavChildLink: '.site-nav__link--last'
  };

  var config = {
    activeClass: 'site-nav--active-dropdown',
    childLinkClass: 'site-nav__child-link'
  };

  var cache = {};

  function init() {
    cacheSelectors();

    cache.$parents.on('click.siteNav', function(evt) {
      var $el = $(this);

      if (!$el.hasClass(config.activeClass)) {
        // force stop the click from happening
        evt.preventDefault();
        evt.stopImmediatePropagation();
      }

      showDropdown($el);
    });

    // check when we're leaving a dropdown and close the active dropdown
    $(selectors.siteNavChildLink).on('focusout.siteNav', function() {
      setTimeout(function() {
        if ($(document.activeElement).hasClass(config.childLinkClass) || !cache.$activeDropdown.length) {
          return;
        }

        hideDropdown(cache.$activeDropdown);
      });
    });

    // close dropdowns when on top level nav
    cache.$topLevel.on('focus.siteNav', function() {
      if (cache.$activeDropdown.length) {
        hideDropdown(cache.$activeDropdown);
      }
    });

    cache.$subMenuLinks.on('click.siteNav', function(evt) {
      // Prevent click on body from firing instead of link
      evt.stopImmediatePropagation();
    });
  }

  function cacheSelectors() {
    cache = {
      $nav: $(selectors.navigation),
      $topLevel: $(selectors.siteNavLinkMain),
      $parents: $(selectors.navigation).find(selectors.siteNavHasDropdown),
      $subMenuLinks: $(selectors.siteNavChildLinks),
      $activeDropdown: $(selectors.siteNavActiveDropdown)
    };
  }

  function showDropdown($el) {
    $el.addClass(config.activeClass);

    // close open dropdowns
    if (cache.$activeDropdown.length) {
      hideDropdown(cache.$activeDropdown);
    }

    cache.$activeDropdown = $el;

    // set expanded on open dropdown
    $el.find(selectors.siteNavLinkMain).attr('aria-expanded', 'true');

    setTimeout(function() {
      $(window).on('keyup.siteNav', function(evt) {
        if (evt.keyCode === 27) {
          hideDropdown($el);
        }
      });

      $(selectors.body).on('click.siteNav', function() {
        hideDropdown($el);
      });
    }, 250);
  }

  function hideDropdown($el) {
    // remove aria on open dropdown
    $el.find(selectors.siteNavLinkMain).attr('aria-expanded', 'false');
    $el.removeClass(config.activeClass);

    // reset active dropdown
    cache.$activeDropdown = $(selectors.siteNavActiveDropdown);

    $(selectors.body).off('click.siteNav');
    $(window).off('keyup.siteNav');
  }

  function unload() {
    $(window).off('.siteNav');
    cache.$parents.off('.siteNav');
    cache.$subMenuLinks.off('.siteNav');
    cache.$topLevel.off('.siteNav');
    $(selectors.siteNavChildLink).off('.siteNav');
    $(selectors.body).off('.siteNav');
  }

  return {
    init: init,
    unload: unload
  };
})();

Any help would be greatly appreciated.  I feel so silly asking a simple question like this.  I just can't figure out where to put :hover in the code. It seems pretty strait forward but I can't get it.  You can see the site here: AlexandIvy.myShopify.com and the password to view it is staysk.  I'm just talking about the top navigation menus.
This is the code from the console:

          Bedding
          <svg aria-hidden="true" focusable="false" role="presentation" class="icon icon--wide icon-chevron-down" viewBox="0 0 498.98 284.49"><defs></defs><path class="cls-1" d="M80.93 271.76A35 35 0 0 1 140.68 247l189.74 189.75L520.16 247a35 35 0 1 1 49.5 49.5L355.17 511a35 35 0 0 1-49.5 0L91.18 296.5a34.89 34.89 0 0 1-10.25-24.74z" transform="translate(-80.93 -236.76)"></path></svg>
          expand

                Sheet Sets

A: Since you're using JS to hide/show the dropdowns, I suggest you do this if you're comfortable with JQuery.
$('.site-nav--has-dropdown').hover(function() {

  if ($(this).hasClass('activated')){
    $(this).removeClass('activated');
    $(this).children('.site-nav__dropdown').css('display', 'none');
  }
  else{
    $(this).addClass('activated');
    $(this).children('.site-nav__dropdown').css('display', 'block');
  }
});

The idea behind this is that the child closest to .site-nav--has-dropdown which has a class name .site-nav__dropdown can be activated on hover. You can use pol's code too which provides a different (and shorter) approach.

A: You should use mouseover/mouseout methods in jquery.
$('.site-nav--has-dropdown').mouseover(function() {
  $(this).children('.site-nav__dropdown').show();
});

$('.site-nav--has-dropdown').mouseout(function() {
  $(this).children('.site-nav__dropdown').hide();
});

Or just use css :hover,
to better support touch devices you should add :focus too.
.site-nav--has-dropdown:hover .site-nav__dropdown,
.site-nav--has-dropdown:focus .site-nav__dropdown {
  display: block;
}

jsfiddle demo: sfiddle.net/8p33qh9h


text:
Q: in my jsf datatable no.of rows and one column contain one inputfield.how to get these input fields data in backing bean my jsf file:-
   <h:form>
   <h:dataTable value="#{commingMaanagedBean.dmbrb}" var="o" binding="#{table}">

            <h:column>
                 <h:inputText  value="#{amountUpdatingManagedBean.list[table.rowIndex]}" disabled="#{o.dvariable}"/>

            </h:column>
    </h:dataTable>
            <h:commandButton value="UPDATE" action="#{amountUpdatingManagedBean.clearamount}" />

    </h:form>

mymanagedbean:-
 @ManagedBean
 @RequestScoped
 public class AmountUpdatingManagedBean {

  private String username;
  private List<String> list;

   public String getUsername() {
    return username;
  }

   public List<String> getList() {
    return list;
   }

   public void setList(List<String> list) {
    this.list = list;
   }

    public void setUsername(String username) {
    this.username = username;
    }
    public String clearamount(){

    if(list.isEmpty()){
         System.out.println("the list is empty ");
     }
     else {
        System.out.println("the list is pragent");

     }
     return null;
     }
    }

in this above code  getting empty list
how to get user enter values from datatable input fields
i want explanation where i was mistake and how to do get values  from that input fields

A: Your values are failing to be set because you're not initializing the amountUpdatingManagedBean#list properly and JSF doesn't do it for you. I mean, you're considering obvious that JSF will initialize that List property and will add the required String elements for you, but this doesn't happen at all.
Your best is to initialize it beforehand and the easiest way to do it is using the same bean for iteration values and target properties (as the source bean knows the real List size). A simple example would be this:
@ManagedBean
@RequestScoped
public class Bean1 {

    private List<Boolean> disableds = Arrays.asList(true, false, false);

    private List<String> values = new ArrayList<String>();

    public Bean1() {
        for (int i = 0; i < disableds.size(); i++) {
            values.add(new String());
        }
    }

    public void action() {
        System.out.println("Values are " + values);
    }

    public List<Boolean> getDisableds() {
        return disableds;
    }

    public List<String> getValues() {
        return values;
    }

    public void setValues(List<String> values) {
        this.values = values;
    }

}

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head />
<h:body>
    <h:form>
        <h:dataTable value="#{bean1.disableds}" var="disabled"
            binding="#{table}">
            <h:column>
                <h:inputText value="#{bean1.values[table.rowIndex]}"
                    disabled="#{disabled}" />
            </h:column>
        </h:dataTable>
        <h:commandButton value="UPDATE" action="#{bean1.action}" />
    </h:form>
</h:body>
</html>

There, you have the values List already initialized. I'm doing it in the constructor, but you could as well do it once you've got your elements to iterate over.


text:
Q: VF Page to Show Related Lists from Lookup Object on my Main Object I am trying to develop a small VF page that will eventually be added to the standard SF page for a custom object called Test_Site__c.
Test_Site__c contains a lookup relationship to an object called ELTON__Other__c.
I wrote the following VF page and it works fine.
<apex:page standardcontroller="Test_Site__c">

Site {! Test_Site__c.Description__c }.

Other {! Test_Site__c.ELTON_Other__r.Name }.

</apex:page>

That displays a certain Test Site with it's associated ELTON Other name. That makes me think that I have the 2 objects correctly related.
And if I take Test_Site__c out of the equation I can write the page that I want for the lookup ELTON__Other__c object...
<apex:page standardcontroller="ELTON__Other__c">

Other {! ELTON__Other__c.Name }.

  <apex:relatedList list="ELTON__Equipment__r"/>
  <apex:relatedList list="ELTON__Equipment_Assignments__r"/>
  <apex:relatedList list="ELTON__Equipment1__r"/>
  <apex:relatedList list="ELTON__Equipment_Loans__r"/>
</apex:page>

That too works wonderfully in that it displays 4 related lists for an ELTON__Other__c object
Since a Test_Site__c record only ever has either 0 or 1 ELTON__Other__c records related to it I would like to display the 4 related lists from ELTON_Other__c and display them on the related Test_Site__c page (so meaning add the lists to the tiny first page example above).
Is this even possible?
Thanks in advance for any insight you could provide :-)

A: Yes, it is possible. For that just use a subject parameter of the apex:relatedList tag:
<apex:page standardcontroller="Test_Site__c">

Site {!Test_Site__c.Description__c }.

Other {!Test_Site__c.ELTON_Other__r.Name }.

    <apex:relatedList subject="{!Test_Site__c.ELTON_Other__c}" list="ELTON__Equipment1__r"/>

</apex:page>