text:
Q: Java: How can I add a name to a rectangle which is a node of a graph? I'm new in java and I'm having some trouble with the following exercise:
This is what I have to do:

From what I've seen, a Rectangle made with java.awt.Rectangle has an x and y coordinates and a width and height. So, I can create a Rectangle like that (for example):
Rectangle node = new Rectangle (5,10,15,20);

However, I'm not sure how can I add a name to that rectangle. So far I've created a Node class like that:
import java.awt.Rectangle;

public class Node {
    private int x;
    private int y;
    private int width;
    private int height;
    private String name;

    public Node(int x, int y, int width, int height, String name) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.name = name;
    }

}

I'm not sure if that's correct since from my understanding the Rectangle object already has 4 of the 5 parameters in my constructor for a node. So what is the right way of doing it? Should I make a parent class for a rectangle and then a node subclass where I just add a name in the constructor? Hope that was clear enough, I'm really confused... thank you for your time!

A: Your constructor is already looking good. For what I understand:
A node has a Rectangle and a Name.
So your class members should be:
public class Node{
    private String name;
    private Rectangle rectangle;

    ...
}

by keeping the same constructor signature you can initialise these two members name and rectangle.
For the third point you need to have a second constructor with no parameters that initialises the name  and the rectangle by default.
The default constructor looks like this:
public Node(){
      ...
}

EDIT (to answer your comment)
Almost :) It is not very clear to me if you have to pass a rectangle in your constructor or more like position and size. If it where up to me, I implemented both of them.
public class Node{

    private String name;
    private Rectangle rectangle;

    public Node(){
        this.name = "some default name";
        this.rectangle = // however you initialise your default rectangle
    }

   public Node(String name, int x, int y, int width, int height){
       this.name = name;
       this.rectangle = .... // use x,y, width and height to create a new rectangle
   }

   // your solution:
   public Node(String name, Rectangle rectangle){
       this.name = name;
       this.rectangle = rectangle;
   }


text:
Q: Object containing multiple lists python I've stumbled upon a very strange variable in Python. I am doing a tokenizing operation on multiple unicode strings as follows :
with open ("verbatims.txt","r") as verbatims :
    for line in verbatims:
        line = line.decode("utf8")
        tokens = nltk.tokenize.word_tokenize(line)

& when I print(tokens)
[u'Vive', u'la', u'poste', u'...', u'.', u'Le', u'facteur', u'qui', u'a', u'la', u'flemme', u'de', u'sonner', u'pour', u'te', u'remettre', u'ton', u'colis', u'et', u'te', u'dis', u'que', u"t'es", u'absent']
[u'Une', u'honte', u'ce', u'petit', u'postier', u'fain\xe9ant', u'.', u'.']

I've got this strange output. It seems like tokens is an object containing multiple lists. Here it's just a sample but I have as multiple lists as sentences. Besides, I can't just call tokens as I would do in an ordinary list. I have to do a print.
The problem with having multiple lists inside the same object is that when I parse the object using a simple for...in loop, the parser will not work and will return only the last list of the object.
So my questions are :

*

*How are these kind of objects called ?

*How can I parse on this object ?

Thanks !

A: try this using encode 'utf-8' or 'latin1'
with open ("verbatims.txt","r") as verbatims :
    for line in verbatims:
        line = line.decode("utf8")
        tokens = nltk.tokenize.word_tokenize(line)
        tokens = [x.encode('latin1') for x in tokens] # add this or try with the another

but if you have tokens as [ [],[] ], should do other loop in x, for example (multiple lists):
with open ("verbatims.txt","r") as verbatims :
    for line in verbatims:
        line = line.decode("utf8")
        tokens = nltk.tokenize.word_tokenize(line)
        tokens = [a.encode('latin1') for a in x for x in tokens]

redpajama_set_name: RedPajamaStackExchange


text:
Q: Смена метки при клике Сайт на Drupal 7. Карта создана при помощи модуля Geofield Yandex Maps. Все объекты на карте выводятся с помощью geoQuery.
Нужно при клике на метку,менять цвет ( в моем случае  я меняю iconImageHref). Но при клике на другую метку,у предыдущей не меняется цвет на дефолтный. Нашел код,который все делает как надо,но он дублирует созданные объекты и отрабатывает только на них. Подскажите как сделать правильно. Вот код
Drupal.behaviors.addMap = {
  attach : function(context, settings) {
    (function ($) {
    $('#geofield-ymap-views-block-dilers-block-map').bind('yandexMapInit', function (event, map) {
      var myMap = Drupal.geofieldYmap.data['geofield-ymap-views-block-dilers-block-map'].map;
      var myPlacemark = Drupal.geofieldYmap.data['geofield-ymap-views-block-dilers-block-map'].map.geoObjects;
      var myBalloon = Drupal.geofieldYmap.data['geofield-ymap-views-block-dilers-block-map'].map.balloon;

 // Получаем список объектов в GeoJson
      var objects = $(this).data('map-objects');
      collection = ymaps.geoQuery(myPlacemark);
      if (collection.isReady()) {
          for (i = 0; i < collection.getLength(); i++) {
              var pm = collection.get(i);

              // Обработчик клика для метки
              pm.events.add('click', function (e) {

                  // Цвет всех меток
                  for (j = 0; j < collection.getLength(); j++) {
                      var currentPm = collection.get(j);
                      currentPm.options.set(
                          'iconImageHref', '/sites/default/files/images/map/datsun-clicked.png'
                      );
                  }

                  // Цвет текущей метки
                  e.get('target').options.set('iconImageHref', '/sites/default/files/images/map/datsun-icon.png');
              });

              map.geoObjects.add(pm);

          }

      }

    })(jQuery);
  }
};

РЕШЕНИЕ:
// Получаем список объектов в GeoJson
        var objects = $(this).data('map-objects');
        collection = ymaps.geoQuery(objects);
        var activePlacemark;
        myPlacemark.events.add('click', function(e){
          if (activePlacemark) {
            activePlacemark.options.set('iconImageHref', '/sites/default/files/images/map/datsun-icon.png');

          }
          activePlacemark = e.get('target');
          activePlacemark.options.set('iconImageHref', '/sites/default/files/images/map/datsun-clicked.png');

        })


text:
Q: django ForeignKey model filter in admin-area? Hi I need really very very simple example. First my models:
#This my student models
from django.db import models
SEX_CHOICES= (
    ('M', 'Male'),
    ('F', 'Female'),
)
class Students(models.Model):
    student_name = models.CharField(max_length=50)
    student_sex = models.CharField(max_length=8, choices=SEX_CHOICES)
    student_city = models.Charfield(max_length=50)
    student_bio = models.TextField()

    def __unicode__(self):
        return self.student_name

O.K. Let see my ClassRooms Model.
#This my ClassRooms models
from django.db import models
from myproject.students.models import *
class ClassRooms(models.Model):
    class_number= models.CharField(max_length=50)
    class_student_cities = models.ForeignKey(Students)
    class_year = models.DateField()

    def __unicode__(self):
        return self.class_number

How can i show in the class_student_cities area the Students.student_city datas? I guess that about django-admin area. When i do it withclass_student_cities = models.ForeignKey(Students) i just see in that area the Students.student_name data (ex: John Smith). I want to see JUST Students.student_cities data (ex: NewYork). Can you give me a little example?
Should i use something like that:
class_student_cities = models.ForeignKey(Students.student_cities)

Many Thanks!

A: Try redifinition unicode method.
def __unicode__(self):
        return self.student_city

So you'll see in the field student city.
Well, I tried to remake your application to set data with forms class. Something like this in admin.py in your application:
from django.contrib import admin
from django import forms
from myapp.models import *

class ClassRoomsAdminForm(forms.ModelForm):
    class Meta:
        model = ClassRoom
    def __init__(self, *arg, **kwargs):
        super(ClassRoomsAdminForm, self).__init__(*arg, **kwargs)
        self.fields[' class_student_cities'].choices = [(csc.id,csc.student_city) for csc in Students.objects.all()

class ClassRoomsAdmin(admin.ModelAdmin):
    form = ClassRoomsAdminForm

admin.site.register(ClassRooms,ClassRoomsAdmin)

Maybe you'll need to fix something, but I hope it will work. You will set init function to your forms, so in admin panel you set all choices to everything you keep in your Students model. csc.id you'll need to make this object iterable (cities aren't unique) and then you can choose everything from Students model to set in the field.


text:
Q: images from imgur not showing in my posts on SuperUser Using Chrome Version 78.0.3904.97 (Official Build) (64-bit) and it says it's up to date.
I cannot see some images in answers that I posted on this site. In my post I see the broken image icon. When I follow the image link, I'm getting the error

This site can't be reached i.stack.imgur.com unexpectedly closed the
  connection. Try:
Checking the connection Checking the proxy and the firewall Running
  Windows Network Diagnostics ERR_CONNECTION_CLOSED

Funnily enough, when I open the same post in another Chrome session, the images show fine. Also, for example I can see this image
https://i.stack.imgur.com/y4Wie.png
but not this one.
https://i.stack.imgur.com/GrWSR.png
I have already cleared cookies. If DNS were the problem, then I shouldn't be seeing the image in the other Chrome session either, right?
Any ideas?

A: Solution: disable VPN.
I was using VPN to work remotely on a client's system. Apparently that means that all my traffic goes through their network and restictions like website bans (imgur) are applied. The images I COULD see were probably from my cache.


text:
Q: Let M and N be normal subgroups of a group G such that $M \cap N=\{e\}$. Prove that $mn=nm$ for all $m\in M$ and all $n\in N$. Here is my progress:
$M$ and $N$ being normal in $G$, $\forall n\in N, \forall m \in M $, $nmn^{-1} \in M \implies nmn^{-1}m^{-1} \in M$.
By similar arguments, $mnm^{-1}n^{-1} \in N$ .
Now, consider the product,  $mnm^{-1}n^{-1}$ [ $\forall n \in N$ and $\forall m \in M$ ].
$mnm^{-1}=n_1 (say)\in N $, again $nm^{-1}n^{-1}=m_1 (say) \in M$ [by the property of normality].
But, the product  $mnm^{-1}n^{-1}=n_1n^{-1}=mm_1 \in N and$ $M$ $\implies mnm^{-1}n^{-1} \in M \cap N=\{e\}$
Therefore, $mnm^{-1}n^{-1}=e \implies mn=nm$ $\forall m \in M$ and $n\in N$.


text:
Q: Getting PID of MPlayer (without filtering all processes or loosing keyboard control) I'm frequently running some kids show, while I work. To do that, I need to extend screen to tv, change audio sink etc. AND move mplayer window from primary screen to desired + make that window sticky. I know how to do all of that, and I can write that script. But to do all of that, I need PID for just executed MPlayer. However if I run MPlayer from inside of bash script like mplayer ... & I can get PID via $! but I lose ability to control the mplayer when the script ends. I know about possiblity to execute mplayer via -slave option, but I'd like to control it in same manner as if you start MPlayer normally.
Does anyone know how to invoke MPlayer in bash script, be able to get it's PID and be able to control MPlayer via normal MPlayer console interaction when the script ends?
I'm open to other solutions as well, but essentially I need to start mplayer somehow first, then get it's PID to be able to run pacmd and wmctrl commands, and all of that without changing behavior of executed mplayer.

A: The script below executes the following procedure:

*

*Save the original stdin for later use. In your use case it most likely points to the terminal.

*Redirect stdin from /dev/null, so no process (including future children) uses the original one by default. Note processes that access /dev/tty directly (e.g. sudo asking for a password) may still interfere.

*Run mplayer in the background with stdin redirected to the original one. This way it's the only process that uses it. Command line arguments are passed as-is.

*Wait for the right window to appear.

*Do what you want to do.

*Wait for mplayer to exit.

If mplayer exits prematurely then the script will never pass beyond "wait for the right window". Therefore it's good to execute few steps in a subshell in the background. When mplayer exits, the main script should not let the subshell survive.
The script will misbehave if job control is enabled, so do not source it from a shell with job control. If sourced, it can also kill more than you expect. You should run the script as a standalone executable.
#!/bin/bash

trap 'kill 0' EXIT     # do not let children survive

manage_mp() {
   # wait for window to appear
   until wmctrl -lp | grep -q '\b'"$mppid"'\b.*\bMPlayer\b'; do sleep 1; done

   # do whatever you want to do; the PID is in $mppid in case you lose $!
   # test line below
   wmctrl -r MPlayer -b add,above
}

exec 17<&0             # save stdin
exec 0</dev/null       # redirect stdin, so the original is not used

<&17 mplayer "$@" &    # run mplayer in background
mppid="$!"

manage_mp &

wait "$mppid"          # wait for mplayer


text:
Q: How to intuitively understand prolongations This question is concerned with the algebraic side of the theory of prolongations as explained in this paper by V. Guillemin and S. Sternberg. Let me first introduce my notation.
We're working with a finite dimensional real vector space $T$ with basis $\{e_i\}_{i=1}^n$ and its dual space, $T^*$, with basis $\{x^k\}_{k=1}^n$.
First of all we consider the symmetric algebra $S(T^*)$, which can be identified with the algebra of polynomials $\mathbb{R}[x^1,\dots,x^n]$ and is graded as
$$
S(T^*)=\bigoplus_{k\in\mathbb{Z}}S^k(T^*),
$$
and each $S^k(T^*)$ can be identified with the homogeneous polynomials of degree $k$.
Every derivation $D\in\operatorname{Der}S(T^*)$ is uniquely determined by it's action in $S^1(T^*)$, so there aren't any derivations of degree less than $-1$. Also, there is a natural isomorphism between $T$ and $\operatorname{Der}S(T^*)_{-1}$ given by
$$
\partial_v(\eta) = \eta(v),
$$
for every $v\in T$ and $\eta\in T^*\cong S^1(T^*)$. With this we obtain the natural identification
$$
\partial_{e_i}\leftrightarrow\frac{\partial}{\partial x^i}.
$$
With all this it's easily shown that in general,
$$
\operatorname{Der}S(T^*)_k\cong\operatorname{Hom}(T^*,S^{k+1}(T^*))\cong S^{k+1}(T^*)\otimes T,
$$
and we can identify $S(T^*)\otimes T$ with the set of polynomial vector fields of $T$. With this we can equip $\operatorname{Der}S(T^*)$, seen as a subset of $\operatorname{End}S(T^*)$, with a Lie algebra structure that that preserves the graduation.
Definition
Given $h\subset\operatorname{Hom}(T^*,S^{k+1}(T^*))$ in the paper I mention they define the (first) prolongation of $h$ as the set
$$
j^{(1)}h:=\{\tau\in\operatorname{Hom}(T^*,h):\tau(u)v=\tau(v)u\,\forall\,u,v\in T^*\}.
$$
Now, consider a family of subspaces $g^k\subseteq S^{k+1}(T^*)\otimes T$ for $k=-1,\dots, i$, for some fixed $i$ and with $g^{-1}=T$. What we're going to do is prolong this family of subspaces to form a Lie algebra.
This obscure definition has eluded me for a some days now and I don't know yet how to understand what's really behind it. I've tried to show that my definition is equivalente to Definition 1.1 in this paper, but I no longer think that's true.
Also, according to this paper

A single prolongation of a system of order $q$ consists of augmenting the system with all possible derivatives of its equations [...]

yet I can't make sense of this in my framework.
I tried showing that
$$
j^{(1)}g^i\cong\{f\in S^{i+2}(T^*)\otimes T: \partial_w f\in g^i\,\forall\, w\in T\},
$$
but now I'm convinced (not a 100%) this is false.
Edit: This last statement seems to be also used in the book Will Jagy recommends in the comments.
Note: I'm creating a "prolongation-theory" tag which doesn't exist ATM. If the tag is so irrelevant it should be deleted so be it.
Bounty Edit: The jet-bundles tag may be misleading, since I'm interested mostly in the algebraic side of this. I'll leave it as it's a closely related topic.
(probably) Final edit: This question is mostly answered in chapter 4 of the book recommended by James S. Cook in the comments: 'Cartan For Beginners' by Ivey and Landsberg.


text:
Q: Sign Up Users in Bulk - Parse Platform I'm creating an app in iOS using Parse where a district administrator would bulk create accounts for all students in the district using their student information system data.
I'm wondering if any method exists where a bulk number of accounts can be created? I'm aware that I can setup a for-in statement to make them all one-by-one using signUpInBackground(), but this method causes the current user to be logged out and the newly created user to be logged in... thus losing the district administrator session.


text:
Q: Iphone Image fit Issue in Canvas I am working on HTML5 application for iPhone. Whenever I choose file from take photo option and place it in canvas. It gets squeezed towards top. I am unable to find out the reason.
I have asked this question before and searched many sites but could not find solution of this issue. Any help?
Demo Image
Please find this image to see the issue. Newly taken photo does not occupy space till clear button.
Html Code:
<canvas id="myCanvas" width="270" height="300"></canvas>
<input type="file" id="uploadImage" name="upload" value="Upload" onchange="PreviewImage();" />

Javascript Code:
function PreviewImage() {
    var oFReader = new FileReader();
    oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]);
    oFReader.onload = function (oFREvent) {
        var canvas = document.getElementById('myCanvas');
        ctx = canvas.getContext('2d');
        ctx.clearRect(0, 0, 270, 300);
        imageUrl = oFREvent.target.result;
        var base_image = new Image();
        base_image.src = imageUrl;
        base_image.onload = function () {
            ctx.drawImage(base_image, 0, 0, 270, 300);
        }
    };
}


text:
Q: Name is not defined but earlier it worked, now it doesn't; Exact same code Newbie at Python here and am practicing some questions online.
Somehow after working on another question, this code does not work anymore when it was the exact same code
def diff(a):
    a = int(input("Give me a number: "))
    if a > 17:
        return (a-17)*2
    else:
        return
diff(a)


text:
Q: Link print setting to a PDF document I have a PDF document and I want to know if there is a way that I can embed print setting into it - such as Page sizing to Actual size and print on both sides.
So when people print the PDF they don't need to change the print settings manually.

A: Parts of this can be done with the "Viewer Preferences" dictionary (see PDF 1.7 specification section 12.2 for details):

*

*PrintArea

*PrintClip

*PrintScaling

*Duplex

*PickTrayByPDFSize

*PrintPageRange

*NumCopies

However, as usual this depends on the PDF viewer actually using these options. So you might wanna try this out with the PDF viewers your clients use.


text:
Q: Performance Testing Java Http and Kafka is while loop slowing performance I've set up a spring-reactive server and an use a while loop inside of a Scheduled job to make fire and forget requests from a httpClient (backend just returns the same simple string via tomcat) it is configured as follows:
public ConnectionProvider getConnectionProvider(){
    int maxConnections = 20;
    ConnectionProvider connProvider = ConnectionProvider
    .builder("webclient-conn-pool")
    .maxConnections(maxConnections)
    .maxIdleTime(Duration.of(20, ChronoUnit.SECONDS))
    .maxLifeTime(Duration.of(1000, ChronoUnit.SECONDS))
    .pendingAcquireMaxCount(2000)
    .pendingAcquireTimeout(Duration.ofMillis(20000))
    .build();
    return connProvider;
}

public HttpClient getHttpClient(){
    return HttpClient
    .create(getConnectionProvider());
    //.secure(sslContextSpec -> sslContextSpec.sslContext(webClientSslHelper.getSslContext()))
    /*.tcpConfiguration(tcpClient -> {
            LoopResources loop = LoopResources.create("webclient-event-loop",
                        selectorThreadCount, workerThreadCount, Boolean.TRUE);

            return tcpClient
                    .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
                   .option(ChannelOption.TCP_NODELAY, true);*/
}

I've also created a job that uses @Autowired kafkaTemplate and makes a while loop that sends a short text string
For http / tomcat calls I am getting around 65 requests a second
For kafka I am maxing out around 50000 requests with a half second lag
application.props
spring.kafka.bootstrap-servers=PLAINTEXT://localhost:9092,PLAINTEXT://localhost:9093
host.name=localhost

Job to make calls
@Async
@Scheduled(fixedDelay = 15000)
public void scheduleTaskUsingCronExpression() {
   generateCalls();
}

private void generateCalls() {
    try{

        int i = 0;
        System.out.println("start");
        long startTime = System.currentTimeMillis();
        while(i <= 5000){
            //Thread.sleep(5);
            String message = "Test Message sadg sad-";
            kafkaTemplate.send(TOPIC, message + i);
            i++;
        }
        long endTime = System.currentTimeMillis();
        System.out.println((endTime - startTime));
        System.out.println("done");
    }
    catch(Exception e){
        e.printStackTrace();
    }
    System.out.println("RUNNING");
}

Kakfa partition config
@Bean
public KafkaAdmin kafkaAdmin() {
    //String bootstrapAddress = "localhost:29092";
    String bootstrapAddress = "localhost:9092";

    Map<String, Object> configs = new HashMap<>();
    configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
    return new KafkaAdmin(configs);
}

@Bean
public NewTopic testTopic() {
    return new NewTopic("test-topic", 6, (short) 1);
}

Kafka consumer consuming messge
@KafkaListener(topics = "test-topic", groupId = "one", concurrency = "6" )
public void listenGroupFoo(String message) {
    if(message.indexOf("-0") != -1){
        startTime = new Date().getTime();
        System.out.println("Starting Message in group foo: " + message);
    }
    else if(message.indexOf("-100000") != -1){
        endTime = new Date().getTime();
        System.out.println("Received Message in group foo: " + message);
        System.out.println(endTime - startTime);
    }
}

For hardware I have a 10900k with 64gb ram
5ghz clock speed
970 Evo single nvme disk
10 core 20 thread
All requests are from the same local server to the same local server
I can add more local servers for testing if needed
Is there a better way to organize / optimize the code to make a massive number of requests?
Theories:

*

*Multiple Threads?

*Changing configurations of servers such as tomcat configs (receiving or sending side)?

*Not use the kafkaTemplate that is autowired or creating multiple?

*Modify Hardware to have multiple disks?

*Improve server receiving http to allow more connections?

*Not use a job to make the requests?

*Anything else anyone can think of to help?


text:
Q: Encoded password does not look like BCrypt when using Spring Security UserDetailsService When i am using Spring Security UserDetailsService i am encounter Encoded password does not look like BCrypt, whereas without it working fine
Otherwise its working fine
database is here
enter image description here
From EmployeeServiceImpl
 @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        Employee employee = employeeRepository.findByUserName(username);
        System.out.println(employee);
        if (username == null) {
            throw new UsernameNotFoundException("Invalid user name or password");
        }
         return new User(employee.getUserName(),employee.getPassword(),
                mapRolesToAuthorities(employee.getRoles()));
}
   private Collection<? extends GrantedAuthority> mapRolesToAuthorities(Collection<Role> roles) {
        return roles.stream()
                .map(
                        role -> new SimpleGrantedAuthority(role.getName())).collect(Collectors.toList());
    }

For registration i am using BCryptPasswordEncoder
@Override
    public void save(ErmUser ermUser) {

        Employee employee = new Employee();

        // assign user details to the user object
        employee.setUserName(ermUser.getUserName());
        employee.setPassword(passwordEncoder.encode(ermUser.getPassword()));
        employee.setFirstName(ermUser.getFirstName());
        employee.setLastName(ermUser.getLastName());
        employee.setEmail(ermUser.getEmail());

        // give user role of "EMPLOYEE"
        employee.setRoles(Arrays.asList(roleRepository.findRoleByName("ROLE_EMPLOYEE")));

        // save the user in database
        employeeRepository.save(employee);
    }

https://github.com/TilmeezUrRehmanBhatti/thymeleafdemo-employees-db/issues/2
I don't think it's because of the password its somewhere in the code where we are not handling incoming passwords from the user to BCrypt and then matching, while debugging I noticed it try to match with the plain password with is entered by me(user) with BCrypt password from Database. And i don't know how to handle this or convert the input password to BCrypt  because normally it's handled by spring security (If I am not wrong)

A: This issue is related to column size. As I am using Postgres, it might be of type issue.
https://mkyong.com/spring-security/spring-security-encoded-password-does-not-look-like-bcrypt/
Alter the password column type from char to varchar, it solves my problem

A: I am not sure why you got that impression. Bcrypt encoder uses Strenth parameter with value from 4 to 31 to encode the text. When it's 4, you will see hashed value something like $2a$04 and when it's 10 (default value) hash will be of pattern $2a$10  now, the question is why three passwords in the database have same hash value. Was it generated and updated outside this program?


text:
Q: Uploading html file generated from R-animation package to wordpress I created a HTML file using the animation package in R.  Now I'm trying to upload the resulting HTML file to a wordpress blog but don't really know how to make it work.  It seems like I might need to upload some js or css files too but am not sure.  Also, it seems like I might need to upload the original data files as the HTML file is 2.5kb and the original CSV file is 2500kb.  Any suggestions would be appreciated.

A: I think I have addressed this issue in ?saveHTML if you are using the latest version of the animation package (the second paragraph in the Note section). Perhaps it is still not clear (I'll improve it in the next version), so let me explain it here:
What you need to upload are: the HTML file, the image folder, js and css. The CSV data is not required, since the animation is independent with the data now.


text:
Q: Get string byte length in delphi I want to find string byte length. Firstly convert to byte and then get the length so How can i get string byte length?
var
  val : String;
begin
  val:= 'example';
  ShowMessage(IntToStr(Length(val) * ???)); -> BYTE LENGTH
end;

A: You can use the SysUtils.ByteLength() function:
uses
  SysUtils;

var
  val : String;
begin
  val:= 'example';
  ShowMessage(IntToStr(ByteLength(val)));
end;

Just know that ByteLength() only accepts a UnicodeString as input, so any string passed to it, whether that be a (Ansi|Wide|UTF8|RawByte|Unicode)String, will be converted to UTF-16 (if not already) and it will then return the byte count in UTF-16, as simply Length(val) * SizeOf(WideChar).
If you want the byte length of a UnicodeString in another charset, you can use the SysUtils.TEncoding class for that:
var
  val : String;
begin
  val := 'example';
  ShowMessage(IntToStr(TEncoding.UTF8.GetByteCount(val)));
end;

var
  val : String;
  enc : TEncoding;
begin
  val := 'example';
  enc := TEncoding.GetEncoding(...); // codepage number or charset name
  try
    ShowMessage(IntToStr(enc.GetByteCount(val)));
  finally
    enc.Free;
  end;
end;

Or, you can use the AnsiString(N) type to convert a UnicodeString to a specific codepage and then use Length() to get its byte length regardless of what N actually is:
type
  Latin1String = type AnsiString(28591); // can be any codepage supported by the OS...
var
  val : String;
  val2: Latin1String;
begin
  val := 'example';
  val2 := Latin1String(val);
  ShowMessage(IntToStr(Length(val2)));
end;

A: var
  val : String;
begin
  val:= 'example';
  ShowMessage(IntToStr(Length(val) * SizeOf(Char)));
end;

Or use ByteLength to obtain the size of a string in bytes. ByteLength calculates the size of the string by multiplying the number of characters in that string to the size of a character.


text:
Q: How to add UIButtons and UILabels to a Scrollable View? I've seen almost every question about similar issues, and tried the given answers, but they are not working for me. The thing is: I have a home view, and I have a button, on click, it adds a new button and a label over it, and so on until you "fill" the area, and I want it to be resizable and scrollable, so you can see all the buttons and you can zoom-in to see just some buttons. I don't know if I'm explaining myself clearly...
So, I tried adding everything to a UIView, and it didn't work, I tried adding everything to a UIScrollView, and again it didn't work. I don't know what else to do. I've been dealing with this almost all week without any success. I have to say I am not very experienced on this, I just started to code for iOS about 4 months ago, so please be patient. I would really appreciate any help or guidance you can share.
Here's what I am doing:
- (IBAction) doneAdding:(id) sender{
        boxes = boxes+1;
        UIButton *newBox = [UIButton buttonWithType:UIButtonTypeCustom];
        UIImage *boxImage = [UIImage imageNamed:@"bluecube.jpg"];

    if (boxes <= 4) {
    switch (boxes) {
        case 1:
            newBox.frame = CGRectMake(519, 356, 162, 163);
            break;
        case 2:
            newBox.frame = CGRectMake(681, 519, 162, 163);
            break;
        case 3:
            newBox.frame = CGRectMake(357, 519, 162, 163);
            break;
        case 4:
            newBox.frame = CGRectMake(519, 844, 162, 163);
            break;
            default:
            break;
    }

    [newBox setBackgroundImage:boxImage forState:UIControlStateNormal];
    [newBox addTarget:self action:@selector(goToProject:) forControlEvents:UIControlEventTouchUpInside];
    [homeView addSubview:newBox];

            //I get the text of the label from a textfield
    UILabel *nameLabel= [ [UILabel alloc ] initWithFrame:CGRectMake(480.0,500.0, 150.0, 43.0) ];
    [[NSUserDefaults standardUserDefaults] setObject: newName.text forKey: @"SomeRandomText"];
    nameLabel.textAlignment =  UITextAlignmentCenter;
    nameLabel.textColor = [UIColor blackColor];
    nameLabel.backgroundColor = [UIColor clearColor];
    nameLabel.font = [UIFont fontWithName:@"Helvetica" size:(12.0)];
    nameLabel.text = [NSString stringWithFormat:@"%@", newName.text];
    [homeView addSubview:nameLabel];
    [newName release];

     }else {
        NSLog(@"No more boxes allowed");
     }
}

A: What do you mean with "it doesn't work"? Did you try setting the UIScrollView's contentSize property to a size large enough to contain all the subview's frames?


text:
Q: BASH script help for process restart #!/bin/bash

check=`monStatus.sh -p appName:Tomcat |head -2 |tail -1 | nawk '{print $2}'`

if [ "$check" != "offline" ]; then
  #echo "Tomcat still running"
  sleep 90
else
  #echo "Restarting Tomcat"
  RestartTomcat.sh
fi

Here is the shell snippet.  My issue is this.  I need the first then to be like sleep 90 AND then run through the if/then/else statement again basically until it is completes out on the else which will then restart Tomcat once it doesn't say running.  I can't wrap my brain around how to loop it.

A: If you need to repeat the scrip endlessly, you can use a nested while loop:
while true; do
    # Do something, for example output the current date and time:
    printf '%(%c)T\r' -1
done

*

*In your example code, you are using the old style for subshell output wrapping. As @ThomasWard says: "most Bash guides don't recommend the use of backticks, and instead suggest to wrap your commands within $( ), i.e. $(monStatus.sh -p appName:Tomcat | head -2 | tail -1 | nawk '{print $2}'). This is actually the more recommended way to do subshell output capture as a variable or as substitution nowadays."
As @dessert says, "note there's actually a difference between the backticks and the $(…) syntax: When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by $, `, or \. – compare the outputs of echo $(echo \\ ) and echo `echo \\ `!"

*In addition, you can simplify few more things:
Use nawk 'FNR==2{print $2}' instead of head -2 | tail -1 | nawk '{print $2}'.
Use Bash builtin test [ (see man test and this answer), the 'and' list operator &&, and positive (==, -eq) instead of negative (!=, -ne) condition.
#!/bin/bash
while true; do
    sleep 90
    [[ $(monStatus.sh -p appName:Tomcat | nawk 'FNR==2{print $2}') == 'offline' ]] && RestartTomcat.sh
done

But, according to the comment "after it runs the restart it should end", the correct suggestion is to use while with a condition:
#!/bin/bash
while [[ $(monStatus.sh -p appName:Tomcat | nawk 'FNR==2{print $2}') -ne offline ]]
do
    sleep 90
done
RestartTomcat.sh

Or if you want to use a positive condition, the until loop can be implemented in the same way:
#!/bin/bash
until [[ $(...) -eq offline ]]; do sleep 90; done; RestartTomcat.sh


text:
Q: Running a Cron job continuously sorry if this question has been asked before, however I could not find anything relevant when searching.
I currently have a PHP script which polls a database for the next record which is has not been updated. My question is this: If I then update the database to show that the record is processing while the cron job is running (which takes approx 30 seconds), and the cron job is set to run every second, at second 1 the cron job runs, but will this job wait to complete before the cron job runs for the second time, or will it run at second 2?
Thanks

A: If you are using cronjob and not using any kind of locking in your php script the cron will run more than one copy of the script if the time event occurs before the last script finished.
To avoid such issue you can do something like this:
$LOCK_FN = "/tmp/my-script.lock"
if(file_exists ($LOCK_FN)){
    //previous script is not finish exit.
    die("Previous script is not finished yet.");
}
//Create lock
$fp = fopen($LOCK_FN,"w");
fclose($fp);

/*

 Put your script logic here
 */

//Open the lock work is done.
unlink($LOCK_FN)

A: Use sockets to lock something. Because if script gets terminated, the socket port is automatically open again.
<?php
$port = 1080; // choose unused port
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$sock) {
    exit;
}
socket_set_nonblock($sock);
if (!socket_bind($sock, "127.0.0.1", $port)) {
    exit;
}

while(1) { ... }
?>

Use a different port per script.
Add this script to Crontab with * * * * *

A: The cronjob will not wait for the previous one to finish before launching a new instance. What you want is a daemon, see Run php script as daemon process


text:
Q: Why does my Socket IO and Phaser game keep disconnecting? I followed a tutorial to make a basic multiplayer Phaser game and decided to see if I could run it outside my localhost. It works completely fine no (relevant) bugs on the local machine.
Once it's on the server it sometimes works for a bit but will randomly disconnect from the server and then spit a bunch of errors on reconnect. This bug can be viewed live at: http://waste.kayleegrace.space/
I have googled this error but the responses I have read go straight over my head!
Here is the server part of my server code:
const express = require('express');
const app = express();

var http = require('http').createServer(app);
var io = require('socket.io')(http);

app.use(express.static('public'));

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/index.html')
});

http.listen(5000, () => {
  console.log('listening on *:5000');
});

And I connect to the server using:
socket = io();


text:
Q: Visual Studio 2015 is not auto completing Unity keywords I've installed Visual Studio 2015 and Visual Studio 2015 Tools for Unity and I had no problem in using Visual Studio as my default editor in Unity, however I've noticed that Unity's keywords and methods do not auto complete, only the VS do.
For example: GetComponent<>, or OnGui() and Input.GetMouseButton, these are specifically from Unity, when I was using MonoDevelop it displayed the available options of methods when I was typing Input.GetMouse... and if I clicked CTRL + Space it auto completed.
I would like to know if is there any way that I can make Visual Studio recognize Unity API.
Since I am new in Unity and C# I don't know if this is a default behavior, if I should set up something to enable this auto complete feature or if something is wrong and it should be working and somehow it is not.
I would appreciate any help.
Thanks in advance.

A: Import Unity VS Tools' package into unity, open visual studio and use Ctrl-Shift-Q to call Quick MonoBehavior Wizard
Configure Shortcuts: http://unityvs.com/documentation/shortcuts/
Good luck


text:
Q: Security: How to check if our server is hacked? Our server are hosting a website, but we find our database are added some tables, so we suspect if the server was hacked ?
How can I confirm this and solve it ?

A: The easiest first step is to use rootkit finding applications, you don't say which operating system you're using, but on Linux this would be chkrootkit or rkhunter. These should tell you if any of your binary files have been altered for malicious versions.
Generally, don't use any of the binaries on the system itself to look for hacking, as if they are malicious they likely will exclude output of exactly what you're looking for.
Next up, tools like unhide that help you find hidden processes and TCP/UDP ports.
After that, I'd do a vulnerability scan with something like openVAS to find out what holes you have in the system.
What you do after that depends on what you find, but in short if you find anything suspicious, nuke it and reinstall is my preferred option. Otherwise you're fighting on their terms.

A: If you truly suspect the server is hacked, you are best off setting up a new server, ensuring it is hardened for web hosting, restoring your data from a backup, and replacing the existing one with this.
Knowing whether or not your server truly has been hacked may take some time, during which you absolutely want to have the server offline and isolated from the rest of your network.
You say it is the presence of some extra database tables that makes you think the server has been hacked.  What do these tables relate to?  Web content?  I guess you are using IIS (version?) and some database.  You won't get much more help unless you provide more specific details.

A: Are you encoding and decoding your input from your website?
Are you using stored procedures etc???
Make sure they not "hacking" your system via the supplied user interface.
Look at the time stamp when the tables were created/modified and then look for similar entries and IPs in your web logs.. i.e. basic cross checking. If there is corresponding entries then try to determine which are legitimate entries and which may be the profile of an attacker. If there are no corresponding entries then they may have either been scrubbed or the website interface was not involved in the attack. i.e. server was otherwise compromised.
Then automate whatever checks you made and regularly check your system.


text:
Q: Can't resize main partition on CentOS 7 I ordered a dedicated server and it came with a primary partition of 20gb and a second partition of 1.8TB. I see no point in this as I plan to use it as a web server. As such I need to put pretty much everything into /var. I have rebooted in rescue mode and I have deleted the 1.8TB partition. My FS now looks like this
NAME   MAJ:MIN RM    SIZE RO TYPE MOUNTPOINT
sda      8:0    0    1.8T  0 disk
├─sda1   8:1    0 1004.5K  0 part
├─sda2   8:2    0   19.5G  0 part
└─sda4   8:4    0    511M  0 part

I thought I could use the partid app to resize the primary (sda2) partition (https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-disk-storage-parted-resize-part.html), but when I run the command it tells me it is no longer supported.

Error: The resize command has been removed in parted 3.0

I found another tutorial that said to use resize2fs. I ran the command and I get the following.
root@rescue:~# resize2fs /dev/sda2
resize2fs 1.42.12 (29-Aug-2014)
The filesystem is already 5119744 (4k) blocks long.  Nothing to do!

I have around 1.7TB of free space that is not assigned to any partition. All I want to do is assign all of this space to sda2. This is the primary partition and I want it to have all of the space. Am I missing something simple here?
The lvextend command seems to be along the right lines, but still it doesn't work.
root@rescue:~# lvextend -L +1700G /dev/sda2
  Path required for Logical Volume "sda2"
  Please provide a volume group name
  Run `lvextend --help' for more information.

A: resize2fs complains it has nothing to do because it only works at filesystem size. First you have to grow the partition size underneath it with fdisk,  cfdisk or parted.
https://geekpeek.net/resize-filesystem-fdisk-resize2fs/
Similar with LVM, it needs more free partition space to grow, or a new partition added to the LVM volume group.
https://www.turnkeylinux.org/blog/extending-lvm


text:
Q: How to identify and display images from a MATLAB .mat data file? I have a MATLAB file (xyz.mat), and apparently there are image data in this file but I have very little experience with MATLAB and have no clue how to 'extract/open' them.
This is the only clue I have:

The Matlab data file contains a structure "data" with a field "dataList" which is itself a structure array with one element per image.  So the first image can be found in data.dataList(1).img

After loading the file into MATLAB (nothing happened) and typing the command data.dataList(1).img (I got a huge list of numbers) I still get no image.
Any help/ideas?

A: If data.dataList(1).img are 2D or 3D (check using size), you can use imshow to visualize this 2D array (grayscale), or 3D array (color) as an image.
im = data.dataList(1).img;
figure; imshow(im, []);

You can find the range of this image using min(im(:)) and max(im(:)) or plot the distribution of it's values using imhist.
To view all images as a rectangular montage look into montage function:

montage(I) displays all the frames of a multiframe image array I in a
  single image object. I can be a sequence of binary, grayscale, or
  truecolor images. A binary or grayscale image sequence must be an
  M-by-N-by-1-by-K array.

In effect, you can put a number of K images (of the same M x N size) in an M x N x 1 x K array and invoke montage:
for k = 1:K
    I(:,:,1,k) = data.dataList(k).img;
end
figure; montage(I);


text:
Q: How to set ssh-client port My quession is like the follow

SSH session - fixed port on the client side

Is there any solution to use like tcp-client:1234 ------> tcp-server-ssh:22

A: I have fix it to compile openssh,I use version openssh-portable-V_8_3_P1

*

*add int  options.bind_port

*fix main()
char myaddress[100]={};
.....
    case 'b':
        sscanf(optarg,"%[^:]:%d",myaddress,&options.bind_port);
        options.bind_address = myaddress;
        break;

*fix sshconnect.c at line430
    ((struct sockaddr_in*)&bindaddr)->sin_port= htons(options.bind_port);
    if (bind(sock, (struct sockaddr *)&bindaddr, bindaddrlen) != 0) {
        error("bind %s: %s", ntop, strerror(errno));
        goto fail;
    }

*./configure && make

*ln -s .ssh  .myssh

*try

./myssh  -b 192.168.1.153:5566  root@xxx.xyz

*then  you can see

vmuser@ubuntu:~$ lsof | grep "myssh.*TCP"
myssh     110179                 vmuser    3u     IPv4            4018314      0t0        TCP ubuntu:5566->myother_ubuntu:ssh (ESTABLISHED)
myssh     110187                 vmuser    3u     IPv4            4017137      0t0        TCP ubuntu:5588->myother_ubuntu:ssh (ESTABLISHED)


text:
Q: How to enhance the speed of my C++ program in reading delimited text files? I show you C# and C++ code that execute the same job: to read the same text file delimited by "|" and save  with "#" delimited text.
When I execute  C++ program, the time elapsed is 169 seconds.
UPDATE 1: Thanks to Seth (compilation with: cl /EHsc /Ox /Ob2 /Oi) and GWW for changing the positions of string s outside the loops, the elapsed time was reduced to 53 seconds. I updated the code also.
UPDATE 2: Do you have any other suggestion to enhace the C++ code?
When I execute the C# program, the elapsed time is 34 seconds!
The question is, how can I enhance the speed of C++ comparing with the C# one?
C++ Program:
int main ()
{
    Timer t;
    cout << t.ShowStart() << endl;

    ifstream input("in.txt");
    ofstream output("out.txt", ios::out);
    char const row_delim = '\n';
    char const field_delim = '|';
    string s1, s2;

    while (input)
    {
        if (!getline( input, s1, row_delim ))
            break;
        istringstream iss(s1);
        while (iss)
        {
            if (!getline(iss, s2, field_delim ))
                break;
            output << s2 << "#";
        }
        output << "\n";
    }

    t.Stop();
    cout << t.ShowEnd() << endl;
    cout << "Executed in: " << t.ElapsedSeconds() << " seconds." << endl;
    return 0;
}

C# program:
    static void Main(string[] args)
    {
        long i;
        Stopwatch sw = new Stopwatch();
        Console.WriteLine(DateTime.Now);
        sw.Start();
        StreamReader sr = new StreamReader("in.txt", Encoding.Default);
        StreamWriter wr = new StreamWriter("out.txt", false, Encoding.Default);
        object[] cols = new object[0];  // allocates more elements automatically when filling
        string line;
        while (!string.Equals(line = sr.ReadLine(), null)) // Fastest way
        {
        cols = line.Split('|');  // Faster than using a List<>
        foreach (object col in cols)
            wr.Write(col + "#");
        wr.WriteLine();
        }
        sw.Stop();
        Console.WriteLine("Conteo tomó {0} secs", sw.Elapsed);
        Console.WriteLine(DateTime.Now);
    }

UPDATE 3:
Well, I must say I am very happy for the help received and because the answer to my question has been satisfied.
I changed the text of the question a little to be more specific, and I tested the solutions that kindly raised Molbdlino and Bo Persson.
Keeping Seth indications for the compile command (i.e. cl /EHsc /Ox /Ob2 /Oi pgm.cpp):
Bo Persson's solution took 18 seconds on average to complete the execution, really a good one taking in account that the code is near to what I like).
Molbdlino solution took 6 seconds on average, really amazing!! (thanks to Constantine also).
Never too late to learn, and I learned valuable things with my question.
My best regards.

A: As Constantine suggests, read large chunks at a time using read.
I cut the time from ~25s to ~3s on a 129M file with 5M "entries" (26 bytes each) in 100,000 lines.
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>

using namespace std;

int main ()
{
  ifstream input("in.txt");
  ofstream output("out.txt", ios::out);

  const size_t size = 512 * 1024;
  char buffer[size];

  while (input) {
    input.read(buffer, size);
    size_t readBytes = input.gcount();
    replace(buffer, buffer+readBytes, '|', '#');
    output.write(buffer, readBytes);
  }
  input.close();
  output.close();

  return 0;
}

A: How about this for the central loop
while (getline( input, s1, row_delim ))
{
    for (string::iterator c = s1.begin(); c != s1.end(); ++c)
        if (*c == field_delim)
            *c = '#';

    output << s1 << '\n';
}

A: It seems to me that Your slow part is within getline. I don't have precise documentation which would support my idea, but it's how it feels for me. You should try using read instead. Because getline has the delimiter, so it need to check every symbol whether it has found the delimiter symbol, so that looks like multiple in operations, so Your program accesses a symbol in a file, then write it to the memory of your program, in other words, the time consumed on disk head movement. But if You use read function, You will copy the block of symbols and then work with them within program's memory, that may reduce time consuming.
PS again, I don't have documentation about getline and how it works, but I'm sure about read, hope it is helpful.

A: If you know the max line length you can your stdio+fgets and null terminated strings, it will rock.
For c# if it will fit in memory (probably not if it takes 34 sec) I'd be curious to see how IO.File.WriteAllText("out.txt",IO.File.ReadAllText("in.txt").Replace("|","#")); performs!

A: I'd be really surprised if this beat @molbdnilo's version, but it's probably the second fastest, and (I would posit) the simplest and cleanest:
#include <fstream>
#include <string>
#include <sstream>
#include <algorithm>

int main() {
    std::ifstream in("in.txt");
    std::ostringstream buffer;
    buffer << in.rdbuf();
    std::string s(buffer.str());
    std::replace(s.begin(), s.end(), '|', '#');
    std::ofstream out("out.txt");
    out << s;
    return 0;
}

Based on past experience with this method, I'd expect it to be no worse than half the speed of what @molbdnilo posted -- which should still be around triple the speed of your C# version, and over ten times as fast as your original version in C++. [Edit: I just wrote a file generator, and on a file a little over 100 megabytes, it's even closer than I expected -- I'm getting 4.4 seconds, versus 3.5 for @molbdnilo's code.] The combination of reasonable speed with really short, simple code is often quite a decent trade-off. Of course, that's all predicated on your having enough physical RAM to hold the entire file content in memory, but that's generally a fairly safe assumption these days.


text:
Q: Stopping a Timer Task from within a Runnable thread when shutdown I have a TimerTask that gets started as the first thing in my run() method of my Runnable class.  I want to make sure that it gets stopped when the runnable is shutdown.
The runnable is started via an ExecutorService. I don't see a way to get a hook back to the runnable from the ExecutorService when shutdown() is called.
How can I make sure that the TimerTask is stopped?
Thanks

A: The method call TimerTask.cancel() should do the desired.
Your Runnable.run method could be designed like this:
public void run() {
    pingTask = new PingTimerTask(...);
    try {
        ...
    } finally {
        /* this code even gets executed when an exception
         * (for example an *InterruptedException*) was thrown:
         */
        pingTask.cancel();
    }
}

A: use ExecuterService.submit() to get back Future object once the task is completed.
ExecutorService.Submit()


text:
Q: How can I configure subversion / TortoiseSVN to handle Windows case-insensitivity nicely?
Possible Duplicate:
Can I make Subversion + TortoiseSVN case-insensitive for Windows?

There are two files named like this in a folder of our SVN repository:
NAME.ext
name.ext

TortoiseSVN is (naturally) only able to sync one of these files, not both, due to Windows' case-insensitivity.  Both files need to be kept with those names for our Linux builds to work, and branching isn't really an option.
This is pretty annoying for me since Tortoise constantly shows its red ! icon on the directory tree; I'd like a visual way of seeing the repo state without needing to do a manual check.  Is there some way to configure Tortoise to ignore the state of files that have the exact same name as another file, apart from case?
I know this is just the way svn is, but it should be simple for Tortoise to ignore what svn's telling it in this case ... assuming Tortoise has that functionality or it can be added in by an end-user.


text:
Q: terminal is garbled after install oh-my-zsh
My terminal show ? after i installed oh-my-zsh.
I searched on the internet, and i installed powerline-fonts. But it still shows ?. Help me please.
BTW: Theme i'm using is agnoster

A: I change the font from Menlo to Meslo LG M. And that's work for me.
If some one still meet same problem with me. If you are using iTerm2 or another terminal emulator that has separate selections for "non-ASCII" fonts, make sure the "Non-ASCII Font" in your terminal profile is also set to a Powerline font.
See #4091, #1096, #4756, #3713
Someone needs to write a FAQ on this. :D


text:
Q: True Full Screen in Firefox? In OSX, how do I have a true full screen? When I go to full screen mode, the tab and navigation bar are still showing. Those toolbars are annoying when I try to watch a movie, etc.
This is the shot of the top of the screen:
EDIT: I realized this may apply to other browsers such as Safari

A: 2022 update
This answer is no longer correct due to native integration of this feature into Firefox. Look to other answers for better options.
Original answer
By default there's no way to do this in native Firefox, but there is an extension called Toolbar Autohide that should do exactly that! It allows you to use your mouse to make it appear again by hovering at the top of the screen where the toolbar would normally be.
Simply install the extension at that link and restart Firefox when it prompts you to do so. After Firefox restarts, right-click the toolbar and select Maximized Autohide; you should then be ready to go!
I would recommend changing an option for the add-on in the add-on manager (command + shift + a), though: under General, change Transition Type to Slide-in to make it a little prettier.
Lastly, keep in mind that hovering your mouse at the top of the screen can make the OS X bar appear as well, which can be mildly annoying (which would happen for almost any extension that does this type of thing). To get around this, make good use of key commands!

*

*command + l brings up the address bar so you can immediately start typing in a new URL

*command + k brings up the Firefox menu so you can select your print options, preferences, etc.

*command + t creates a new tab and focuses on it

*control + tab and control + shift + tab allows you to cycle through tabs just like command + tab and command + shift + tab allows you to cycle through windows in OS X

Hope this helps!

A: I solved this by using Automator to create an Application that makes use of an Action > Utilities > Run Shell Script:
open -a Firefox
sleep 1
lsappinfo setinfo -app Firefox ApplicationType=UIElement
osascript -e 'tell application "System Events" to tell process "Firefox" to set value of attribute "AXFullScreen" of first window to true'
sleep 0.5
for f in "$@"; do open -a Firefox "$f"; done

I set the shell script Shell: to /bin/sh and Pass input: to as arguments, save it as "Firefox Full Screen" in /Applications, change its icon as explained here and add it as an exception in System Preferences > Security & Privacy > Privacy Tab > Accessibility.
I then can click the application icon or run any of the following and it works:

*

*open -a "Firefox Full Screen"

*open -a "Firefox Full Screen" --args "https://google.com"

*open -a "Firefox Full Screen" --args "https://google.com" "https://twitter.com"
I'm using this coupled with the following userChrome.css to both evade a well known issue with the macOS menu bar on full screen applications and another long standing address bar and tab auto-hide bug that Firefox have with macOS native full screen.
userChrome.css
#navigator-toolbox[inFullscreen] {
    position: relative;
    z-index: 1;
    height: 3px;
    margin-bottom: -3px;
    opacity: 0;
    overflow: hidden;
}

#navigator-toolbox[inFullscreen]:hover {
    height: auto;
    margin-bottom: 0px;
    opacity: 1;
    overflow: show;
}

#content-deck[inFullscreen]{
    position:relative;
    z-index: 0;
}

For a generic approach, check my other answer.
TIP

*

*Firefox, by default, does not have any issue on Linux or Windows to auto-hide address bar and tabs in full screen as expected. With that said, I grabbed this userChrome.css from my ArchLinux setup. I use it on i3 and sway tiling window managers, with all the [inFullscreen] removed, to get address bar and tabs to auto-hide in normal bordless windows.

A: One way to do this is by using JavaScript. For Firefox, execute this code:
document.getElementsByTagName('html')[0].mozRequestFullScreen()

On Safari, put this in a button href attribute:
javascript:if(!document.webkitFullscreenElement){document.getElementsByTagName('html')[0].webkitRequestFullscreen();} else{document.webkitExitFullscreen()}

Obviously, this isn't very graceful unless in an extension or bookmarklet.

A: On about:config, set browser.fullscreen.autohide to true 1.
Bonus: also set ui.prefersReducedMotion to 1 and you'll have a slightly faster animation on macOS (or a hugely faster animation on Windows or Linux).

A: I'm on MacOS, January 2022.  To accomplish what we want:

*

*Go to Firefox "full screen" mode as normal (e.g. Ctrl-Cmd-F)

*On upper right of the screen is the "hamburger menu" (three horizontal lines); right-click it, then select "Hide Toolbars".
No Firefox extension needed.

A: On the about:config page search for the following key
full-screen-api.allow-trusted-requests-only
and set it to false
Then you can create a bookmark 'link' with the following 'location':
javascript:document.documentElement.requestFullscreen()
Edit: new FF supports shorter syntax, thanks @trss for suggestion

A: One way to do this that is handier than a bookmarklet and does not require fiddling with userChrome.css is to install Tampermonkey, then create an user-script with these contents:
// ==UserScript==
// @name         Fullscreen
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add fullscreen to every website!
// @author       You
// @match        *://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.addEventListener("keydown", (e) => { if (e.ctrlKey && e.key == "F") {
        let button = document.createElement("button");
        button.innerHTML = "Switch to full screen";
        button.style.position = "fixed"
        button.style['z-index'] = "9999";
        button.style.left = "50%";
        button.style.top = "50%";
        button.style.width = "50%";
        button.style.height = "50%";
        button.style.transform = "translate(-50%, -50%)"
        button.style.background = "yellow";
        button.style.color = "black";
        button.style.border = "solid 10px green";
        button.onclick = (e) => {
            document.documentElement.requestFullscreen();
            button.remove()
        };
        document.documentElement.appendChild(button)
    }}, true);
})();

Then, Control+Shift+F will display a big button that you can click to make any page fullscreen.
The "button" step is needed because otherwise Firefox will refuse to switch to fullscreen as it believes the fullscreen request was not triggered by an user's action.

A: The only way I was able to get this working on FF Developer Edition v80 was the combination of:

*

*Installing the plugin @Paul mentioned: https://addons.mozilla.org/en-US/firefox/addon/fullscreen_plus/

*Setting full-screen-api.allow-trusted-requests-only: false in about:config

A: The Firefox add-on recommended by pat-s
https://addons.mozilla.org/en-US/firefox/addon/fullscreen-any-site/
doesn't work for me as of this date--it doesn't do anything.
I found a workaround to get a full screen with no search bar and related stuff at the top, suitable for those websites that don't have a full-screen button. Click the PIP button on the right side of the screen, and then double click the PIP screen, and it will make it a full screen without any search bar or bookmark toolbar. It has its own stop and start button, but it is not suitable for websites that have their own full screen button because, although it works for that, you lose the native controls of the websites full screen. To get out of it, click the X in the upper left corner and then click the PIP button on the right of the screen and you will be back to the original screen.

A: The extension Fullscreen Plus (https://addons.mozilla.org/en-US/firefox/addon/fullscreen_plus/) worked for me, for making full-screen of any website (note extensions do NOT function on mozilla extension web site, so you have to go to a different page).  CTRL-SHIFT-F full screens the current web site, including making the URL bar, tabs bar, and menu bar go away.
I did set full-screen-api.allow-trusted-requests-only to false and full-screen-api.macos-native-full-screen to true.  I don't think either of those were required.

A: For me, this addon currently works: https://addons.mozilla.org/en-US/firefox/addon/fullscreen-any-site/
Currently fixed to command + shift + o but maybe custom hotkeys are supported in future versions.


text:
Q: How to install colormap using pip for Spyder (Python 3.5) on Windows I want to use cmap_builder, So I tried
from colormap import cmap_builder.
When I tried, Spyder throwed me an error
ImportError: No module named 'colormap'
So I tried installing, pip install colormap as described in http://colormap.readthedocs.io/en/latest/
This didn't work and displayed a message
No matching distribution found
So is there a different way to install colormap for python 3.5 to use on Spyder ?

A: In principle matplotlib already has all the tools available to create custom colormaps. The two main options are to create a segmented colormap, LinearSegmentedColormap or a discrete colormap ListedColormap.
Find here an example of a continuous colormap between crimson, gold and blue:
import matplotlib.colors as mcolors
import matplotlib.pyplot as plt
import numpy as np

cmap = mcolors.LinearSegmentedColormap.from_list("n", ["crimson", "gold","steelblue"])

x = np.linspace(-1,2.7)
X,Y = np.meshgrid(x,x)
Z = np.exp(-X**2-Y**2)

im =plt.imshow(Z, cmap=cmap)
plt.colorbar()

plt.show()

A discrete colormap could be created like this:
cmap = mcolors.ListedColormap(["crimson", "gold","steelblue"])


text:
Q: Does declaration in c# allocate memory or is it the new operator that allocates memory? Does declaration in c# allocate memory for the variable to be created or is it the new operator that allocates memory and enables to invoke the constructor to initialize the allocated variable in memory?
To my understanding, you cannot call an constructor of any type without the new operator. Am I correct?

A:
Does declaration in c# allocate memory for the variable to be created or is it the new operator that allocates memory and enables to invoke the instructor to initialize the allocated variable in memory?

First let's make sure that you're asking the question you think you're asking. For a value type, the variable storage location and the value storage location are the same storage. For a reference type, the storage location associated with the variable contains a reference to the storage location associated with the object.  Those are completely different.
Second, let's clarify what you mean by "declaration" of a "variable". A static field, an instance field, a local variable and a formal parameter all have declarations. Moreover, the allocation semantics of local variables and formal parameters are different if they are closed-over outer locals of a lambda, and the semantics are also different when the local is in an async method or iterator block.
So let's assume that you have a local variable of reference type and there is nothing fancy about the local:
void M() {
    Animal x = new Giraffe();  ...

The storage location for the local variable x is allocated off of the short-term storage -- the stack, or a register, typically -- when method M() is activated.
When the "new Giraffe()" is evaluated the runtime allocates memory for a Giraffe on the long-term storage -- the GC heap -- and then passes a reference to that object to the constructor. When the constructor returns, the reference is then assigned to the local.
So there are two storage locations. There's the short-term location for x, which only lives as long as the activation of the method, and there's the long-term storage for the thing that is referred to, and that lives until the garbage collector cleans it up.
If that doesn't answer your question, clarify your question.

Can you call a constructor without the new operator?

I'm assuming that by "constructor" you mean an instance constructor and not a static constructor.
Not by any "normal" means, no.

A: declaration without specification allocates memory for (object)null in C#...
string x;
// x = null in memory

string x = "";
// x = string in memory with value.

MyObjectType x;
// x = null;

MyObjectType x = new MyObjectType();
// x = MyObjectType in memory.

A: Declaration of Reference types takes only space for the reference, until you create an object with new keyword.
Same is for Value types
so if you have:
string s; // only reference type memory, which is based on the machine architecture.

if you do have:
string s = "some string"; // reference (pointer) + memory allocated on the heap.

It is almost the same for Value types, though, their memory is allocated inline where the value type is declared.
And you're correct, you cannot call constructor on any type unless an object of the type is is instantiated / created.


text:
Q: How to store and then print a 2d character/string array horizontally for 5 times? I want to get 5 students' grades ({"A+","A","A-"} like that) in an array for 3 subjects. How do I get user inputs and print them horizontally line by line in a table? I have created code but it does not work.
student[i]=row,
subject[j]=colomn

while(j<5){
    for(i=0; i<n; i++){
        scanf("%3s",name[i]);
    }
}
// dispaying strings
printf("\nEntered names are:\n");
while(j<3){
    for(i=0;i<n;i++){
        puts(name[i]);
    }
}

A: You could do something like this.  Make a struct that represents an "entry" of a database.  Each entry contains a student name, and an array of grades depending on how many subjects they're taking.
When you're using scanf() for strings, you'll want to scan for one less than the length of the array, in order to leave space for a null terminator.
You'll also need to flush stdin after each scanf() in case the user enters more than they're supposed to.
#include <stdio.h>
#define NUM_STUDS 3
#define NUM_SUBJS 2

struct entry {
    char name[10];
    char grade[NUM_SUBJS][3];
};

struct entry entries[NUM_STUDS];

int main(void) {
    int i, j, c;

    /* Collect student names */
    for(i=0; i<NUM_STUDS; i++) {
        printf("Enter student name %d/%d: ", i+1, NUM_STUDS);
        scanf("%9s", entries[i].name);
        while ((c = fgetc(stdin)) != '\n' && c != EOF); /* Flush stdin */
    }

    /* Collect grades */
    for(i=0; i<NUM_STUDS; i++) {
        printf("Enter %d grades for %s: ", NUM_SUBJS, entries[i].name);
        for(j=0; j<NUM_SUBJS; j++) {
            scanf("%2s", entries[i].grade[j]);
            while ((c = fgetc(stdin)) != '\n' && c != EOF); /* Flush stdin */
        }
    }

    /* Print out table of results */
    printf("Results:\n");
    for(i=0; i<NUM_STUDS; i++) {
        printf("%-10s: ", entries[i].name);
        for(j=0; j<NUM_SUBJS; j++) {
            printf("%-3s", entries[i].grade[j]);
        }
        printf("\n");
    }

    return 0;
}

Sample input/output:
Enter student name 1/3: Bob
Enter student name 2/3: Alice
Enter student name 3/3: Joe
Enter 2 grades for Bob: B+
A
Enter 2 grades for Alice: A-
C
Enter 2 grades for Joe: D-
E
Results:
Bob       : B+ A
Alice     : A- C
Joe       : D- E


text:
Q: I am not able to connect to Oracle DB via unix server in JDBC I have written a simple code to connect to DB
static final String JDBC_DRIVER = "com.oracle.jdbc.OracleDriver";
static final String DB_URL ="jdbc:oracle:thin:@unix_server_name:1521:ab";

//  Database credentials
static final String USER = "xyz";
static final String PASS = "xyz";

public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
try{
    //STEP 2: Register JDBC driver
    Class.forName("oracle.jdbc.driver.OracleDriver");

    //STEP 3: Open a connection
    System.out.println("Connecting to database...");
    conn = DriverManager.getConnection(DB_URL,USER,PASS);
    System.out.println("Connection successful");

Whenever i run this code i get an error:

Connecting to database... java.sql.SQLRecoverableException: IO Error:
  The Network Adapter could not establish the connection at
  oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419) at
  oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:536)
  at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:228) at
  oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521) at
  java.sql.DriverManager.getConnection(Unknown Source) at
  java.sql.DriverManager.getConnection(Unknown Source) at
  PLSQL_JDBC.query_jdbc.main(query_jdbc.java:26) Caused by:
  oracle.net.ns.NetException: The Network Adapter could not establish
  the connection

Please help me..
Thank you


text:
Q: Surprising behavior of Java 8 CompletableFuture exceptionally method I have encountered strange behavior of Java 8 CompletableFuture.exceptionally method. If I execute this code, it works fine and prints java.lang.RuntimeException
CompletableFuture<String> future = new CompletableFuture<>();

future.completeExceptionally(new RuntimeException());

future.exceptionally(e -> {
            System.out.println(e.getClass());
            return null;
});

But if I add another step in the future processing like thenApply, the exception type changes to java.util.concurrent.CompletionException with the original exception wrapped inside.
CompletableFuture<String> future = new CompletableFuture<>();

future.completeExceptionally(new RuntimeException());

future.thenApply(v-> v).exceptionally(e -> {
            System.out.println(e);
            return null;
});

Is there any reason why this should be happening? In my opinion, it's quite surprising.

A: yes, the behavior is expected, but if you want the original exception which was thrown from one of the previous stages, you can simply use this
CompletableFuture<String> future = new CompletableFuture<>();

future.completeExceptionally(new RuntimeException());

future.thenApply(v-> v).exceptionally(e -> {
        System.out.println(e.getCause()); // returns a throwable back
        return null;
});

A: This behavior is specified in the class documentation of CompletionStage (fourth bullet):

Method handle additionally allows the stage to compute a replacement result that may enable further processing by other dependent stages. In all other cases, if a stage's computation terminates abruptly with an (unchecked) exception or error, then all dependent stages requiring its completion complete exceptionally as well, with a CompletionException holding the exception as its cause.

It's not that surprising if you consider that you may want to know whether the stage you have invoked exceptionally on failed, or one of its direct or indirect prerequisites.


text:
Q: Not able to read data from MariaDB using Pentaho I connected to my database, testeddthe connection and it's working fine
when I run a simple query using the input table transformation I get this error:
37:11 - Table input.0 - ERROR (version 9.3.0.0-428, build 9.3.0.0-428 from 2022-04-12 04.56.25 by buildguy) : Unexpected error
2022/12/13 11:37:11 - Table input.0 - ERROR (version 9.3.0.0-428, build 9.3.0.0-428 from 2022-04-12 04.56.25 by buildguy) : org.pentaho.di.core.exception.KettleDatabaseException:
2022/12/13 11:37:11 - Table input.0 - An error occurred executing SQL:
2022/12/13 11:37:11 - Table input.0 - SELECT * from patient limit 10;
2022/12/13 11:37:11 - Table input.0 -
2022/12/13 11:37:11 - Table input.0 - (conn=49) invalid fetch size
2022/12/13 11:37:11 - Table input.0 -
2022/12/13 11:37:11 - Table input.0 -   at org.pentaho.di.core.database.Database.openQuery(Database.java:1776)
2022/12/13 11:37:11 - Table input.0 -   at org.pentaho.di.trans.steps.tableinput.TableInput.doQuery(TableInput.java:242)
2022/12/13 11:37:11 - Table input.0 -   at org.pentaho.di.trans.steps.tableinput.TableInput.processRow(TableInput.java:143)
2022/12/13 11:37:11 - Table input.0 -   at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2022/12/13 11:37:11 - Table input.0 -   at java.lang.Thread.run(Thread.java:750)
2022/12/13 11:37:11 - Table input.0 - Caused by: java.sql.SQLSyntaxErrorException: (conn=49) invalid fetch size
2022/12/13 11:37:11 - Table input.0 -   at org.mariadb.jdbc.export.ExceptionFactory.createException(ExceptionFactory.java:282)
2022/12/13 11:37:11 - Table input.0 -   at org.mariadb.jdbc.export.ExceptionFactory.create(ExceptionFactory.java:336)
2022/12/13 11:37:11 - Table input.0 -   at org.mariadb.jdbc.Statement.setFetchSize(Statement.java:587)
2022/12/13 11:37:11 - Table input.0 -   at org.pentaho.di.core.database.Database.openQuery(Database.java:1754)
2022/12/13 11:37:11 - Table input.0 -   ... 4 more
2022/12/13 11:37:11 - Table input.0 - Finished reading query, closing connection
2022/12/13 11:37:11 - Table input.0 - Finished processing (I=0, O=0, R=0, W=0, U=0, E=1)

A: Maybe running the query without the ";" at the end?


text:
Q: Correct setting for git autocrlf as per use case I was searching for the proper setting to be used as per certain use cases but could not find any source describing the same. Therefore, I am asking this question to serve as a solution to anyone looking for the correct setting for git's autocrlf option.
Use Case 1: I am on Mac, the other developers are all on Windows. They are managing the source code before I joined in.
Use Case 2: I am on Windows, the other developers are all on Mac. They are managing the source code before I joined in.
Use Case 3: I am on Linux, the other developers are all on Windows. They are managing the source code before I joined in.
Use Case 4: I am on Windows, the other developers are all on linux. They are managing the source code before I joined in.
Use Case 5: I am on Linux, the other developers are all on Mac. They are managing the source code before I joined in.
Use Case 6: I am on Mac, the other developers are all on Linux. They are managing the source code before I joined in.
What setting of git core.autocrlf should I be using ?
EDIT:
Why this question is not a duplicate to many similar questions:
All other questions and their answers provide the required facts and knowledge that leaves a lot to be done by the reader. This question aims at asking the specific answer to specific scenarios.

A: Simple:
 git config core.autocrlf false

(for all and any scenario)
core.autocrlf is a config, which means it is not pushed or cloned with the repo: it has to be set by the user.
It was the legacy way to handle eol at the repo level.
What you want to use (add or modify depending on your scenario) are gitattributes core.eol directives.

*

*.gitattributes is a file which can be managed in the git repo like any other file. Once you agree on an eol policy, that policy will be enforced at each clone.

*you can set core.eol directives for a file, or group of files if you want (as opposed to the global repository-wide config core.autocrlf)

For heterogeneous environment, the core.eol (only for the files you deem problematic) should be native (if you suspect your editor insist on using the system eol instead of using the one already present in the file).
For more, see "Mind the End of Your Line".

A: Don't worry about core.autocrlf; add a .gitattributes file in the root directory and put the following line in:
* text=auto

This will cause git to automatically convert all line endings to LF on commit, and (for Windows machines) convert line endings to CRLF on checkout.
Note that for use case 1 and 3, where the existing developers are on Windows, adding this line to .gitattributes may make it look like you all of a sudden have a ton of changes to commit. That is because you have a lot of files with CRLF in them in the repository, and git knows it has to convert them all to LF. Go ahead and commit those changes, even though it looks like nothing has really changed.
One other thing to note is that if everyone is on the same OS, then I wouldn't even mess around with converting line endings; in that case, put the line * -text in your .gitattributes file so that no conversion happens.


text:
Q: Nested Collection View inside of table view cell swift iOS I am nesting a collection view inside of a table view cell. I need to implement a screen similar to that of the app store of netflix. Where you have categories such as
I would need to load the data from a JSON, for instance - "Popular" may have 11 videos, "Action" May have 3 videos and "Adventures" may have 20. So inside each table view cell, that specific collection view would load a different number of collection view cells depending on how many videos are in each category (Popular, Action, Adventure), which will be displayed within its own respective horizontal collection view.
So far with my code i display each category title in the table view header. But within that category, inside the collection view numberOfItemsInSection and cellForItemAt, i can't find a way to load each collection view interdependently. For example, collection view 1 that relates to Popular, should load 11 cells, Collection View 2 which relates to Action should load 3 cells. Below is my code so far
My TABLE VIEW METHODS WHICH ARE INSIDE OF VIEW CONTROLLER
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    guard let cell = tableView.dequeueReusableCell(withIdentifier: "categoriesCell") as? CategoriesTableViewCell else { return UITableViewCell() }

    return cell
}

func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {

    return arrayOfCategoryObjects[section].title
}

func numberOfSections(in tableView: UITableView) -> Int {
    return arrayOfCategoryObjects.count
}

 func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {

    if let cell = cell as? CategoriesTableViewCell {

        cell.moviesCollectionView.dataSource = self
        cell.moviesCollectionView.delegate = self

        cell.moviesCollectionView.reloadData()

    }
}

MY TABLE VIEW CELL
class CategoriesTableViewCell: UITableViewCell {

@IBOutlet weak var moviesCollectionView: UICollectionView!

}

MY COLLECTION VIEW DELEGATES WHICH ARE ALSO INSIDE THE VIEW CONTROLLER
func numberOfSections(in collectionView: UICollectionView) -> Int {
    return 1
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
   // print(arrayOfCategoryObjects[section].movies[section])

    return arrayOfCategoryObjects[section].movies.count

  }

  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "moviesCell", for: indexPath) as! MoviesCollectionViewCell

        cell.movieTitleLbl.text = arrayOfCategoryObjects[indexPath.item].movies[indexPath.item]

        return cell

  }

MY COLLECTION VIEW CELL
class MoviesCollectionViewCell: UICollectionViewCell {

@IBOutlet weak var movieTitleLbl: UILabel!

}

A: You need to set a tag for your UICollectionView as parent UITableViewCell's indexPath.section:
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {

    if let cell = cell as? CategoriesTableViewCell {

        cell.moviesCollectionView.dataSource = self
        cell.moviesCollectionView.delegate = self
        cell.moviesCollectionView.tag = indexPath.section
        cell.moviesCollectionView.reloadData()

    }
}

and then in your UICollectionView's delegate:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

    return arrayOfCategoryObjects[collectionView.tag].movies.count

  }

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "moviesCell", for: indexPath) as! MoviesCollectionViewCell

    cell.movieTitleLbl.text = arrayOfCategoryObjects[collectionView.tag].movies[indexPath.item]

    return cell

  }

Hope this helps!


text:
Q: Reading or exporting .yaml file in R I have a huge data set for doing analysis in R which has .yaml extension and I want to export that data in R.
How can I do it ? Is there any package for doing that?
I want to do it on Windows platform.


text:
Q: Render Blazor component to static HTML and return it as stream Is it possible to render blazor component as string so I can render static HTML. I know where is a way
to render MVC view to string. What I need to do is to make a way to create static HTML page that will be downloaded to WPF application where user can then open it in browser?
This is popular answer for MVC app: How to render an ASP.NET MVC view as a string?
So is there anything similar for Blazor? I don't need to do it in Blazor but web is done in Blazor so it would be nice.

A: From Blazor .Net 5 RC1 https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-5-release-candidate-1/#blazor-webassembly-prerendering
in your hosting app you can use component tag helper with render-mode="Static" or render-mode="WebAssemblyPrerendered"
@page "/static-counter"
@namespace Server.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<component type="typeof(Client.Shared.MyComponent)" render-mode="WebAssemblyPrerendered" />


text:
Q: Toc: subsection title of first line is not aligned with its second line My subsection title continues in the 2nd line with an indent in the beginning. I want it to be aligned with the first line of the subsection title. Any suggestions?
Solution should not contain \usepackage{tocloft} since this interferes with previous settings
\documentclass[11pt,a4paper,doc,donotrepeattitle]{apa6}
\begin{document}

 \renewcommand*\contentsname{Table of Contents}
 \tableofcontents

 \section{Title}
 \subsection{Long title that spans over two lines}

\end{document}

A: According to ToC: How to no-indent the second line of large entries? :
\documentclass[11pt,a4paper,doc]{article}

\usepackage{tocloft}
\renewcommand*\contentsname{Table of Contents}
\setlength{\cftsubsecnumwidth}{0pt}
\renewcommand{\cftsubsecaftersnumb}{\hspace{1.5em}}

\begin{document}

 \tableofcontents

 \section{Title}
 \subsection{Long title that spans over two lines Long title that spans over two lines}

\end{document}

A: \makeatletter
 \renewcommand*\l@section[2]{%
   \ifnum \c@tocdepth >\z@
   \addpenalty\@secpenalty
   \addvspace{1.0em \@plus\p@}%
   \setlength\@tempdima{0em}%
   \begingroup
    \parindent \z@ \rightskip \@pnumwidth
    \parfillskip -\@pnumwidth
    \leavevmode \bfseries
    \advance\leftskip\@tempdima
     \hskip -\leftskip
     #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
     \endgroup
    \fi}
   \renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{0em}}
   \renewcommand*\l@subsubsection{\@dottedtocline{3}{3.8em}{0em}}
   \makeatother


text:
Q: hive + too many connection to PostgreSQL DB We have ambari cluster with Hadoop version – 2.6.4
When we run query in order to verify connections in PostgreSQL DB , we found many hive connection – in our case around 90
This cause other application problems
So we suspect that hiveserver2 is not cleaning up connections like it should and files are not being released.
Any suggestion why hive is with a lot connection? to postgresql ? ,
And what is the solution for that?
One option that we found is to update the file /etc/security/limits.conf ( according to the answer in the link
https://community.hortonworks.com/questions/48351/hiveserver2-hive-users-nofile-ulimit-above-64000.html )
other interesting post is from - https://community.hortonworks.com/questions/48351/hiveserver2-hive-users-nofile-ulimit-above-64000.html
But we are not sure that this is the solution
su postgres
bash-4.2$ psql
psql (9.2.13)
Type "help" for help.

postgres=#
postgres=# select pid as process_id,
postgres-#        usename as username,
postgres-#        datname as database_name,
postgres-#        client_addr as client_address,
postgres-#        application_name,
postgres-#        backend_start,
postgres-#        state,
postgres-#        state_change
postgres-# from pg_stat_activity;
 process_id | username | database_name | client_address | application_name |         backend_start         |        state        |         state_change
------------+----------+---------------+----------------+------------------+-------------------------------+---------------------+-------------------------------
      24182 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.136194+00 | idle                | 2019-05-29 13:36:53.660075+00
      24184 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.330268+00 | idle                | 2019-05-29 14:06:24.794683+00
      24185 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.346594+00 | idle                | 2019-05-29 14:06:57.014266+00
      24186 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:12.352127+00 | idle                | 2019-05-29 14:07:01.373678+00
      24192 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:14.736059+00 | idle                | 2019-05-29 14:06:37.701989+00
      24499 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.801281+00 | idle                | 2019-05-29 14:06:37.701784+00
      24500 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.801537+00 | idle                | 2019-05-29 14:06:37.701784+00
      24501 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.801818+00 | idle                | 2019-05-29 14:06:37.701956+00
      24502 | ambari   | ambari        | 127.0.0.1      |                  | 2019-05-29 08:20:47.934395+00 | idle                | 2019-05-29 14:06:54.125167+00
      24628 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.959034+00 | idle                | 2019-05-29 14:06:11.004364+00
      24620 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:10.674515+00 | idle                | 2019-05-29 14:06:10.697886+00
      24621 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:10.866393+00 | idle                | 2019-05-29 14:06:10.900711+00
      24624 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.11398+00  | idle                | 2019-05-29 14:05:46.928607+00
      24625 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.139117+00 | idle                | 2019-05-29 14:06:14.719214+00
      24629 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:12.980466+00 | idle                | 2019-05-29 14:06:11.005997+00
      24750 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:17.681669+00 | idle                | 2019-05-29 14:06:14.713394+00
      24751 | hive     | hive          | 34.22.1.91   |                  | 2019-05-29 08:21:17.68909+00  | idle                | 2019-05-29 14:06:14.618542+00
      25223 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:27.016383+00 | idle                | 2019-05-29 14:06:22.918908+00
      25293 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:27.394022+00 | idle                | 2019-05-29 14:06:22.933555+00
      24818 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.344101+00 | idle                | 2019-05-29 13:54:22.786162+00
      24819 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.364094+00 | idle                | 2019-05-29 13:54:22.937269+00
      24820 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.377741+00 | idle                | 2019-05-29 13:57:22.797683+00
      24821 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.389561+00 | idle                | 2019-05-29 13:57:22.928034+00
      24822 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.397512+00 | idle                | 2019-05-29 14:00:22.808355+00
      24823 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.411604+00 | idle                | 2019-05-29 14:00:22.930902+00
      24824 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.420796+00 | idle                | 2019-05-29 14:03:22.872217+00
      24825 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:23.42768+00  | idle                | 2019-05-29 14:03:23.033186+00
      25196 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:25.651445+00 | idle                | 2019-05-29 14:06:22.79415+00
      24881 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:24.131849+00 | idle                | 2019-05-29 14:06:26.752754+00
      24884 | hive     | hive          | 34.22.1.93   |                  | 2019-05-29 08:21:24.16027+00  | idle                | 2019-05-29 14:06:26.754117+00

A: Most all Hadoop services tend to have a lot of open files.  It's not uncommon for a production environment to have a 100K-200K open file descriptor limit.
The easiest solution is to raise the file descriptor limit.
Reference:
https://unix.stackexchange.com/questions/8945/how-can-i-increase-open-files-limit-for-all-processes


text:
Q: 3D collision detection with MatGeoLib? I am writing a plug-in in C++ for some dedicated server software which hosts servers for a game.
I looked around for 3D Collision libraries but it's really hard to find any with examples, but I decided to use MathGeoLib because it looks promising - but it lacks examples and I am unable to find any.
So my question is: How would I define a sphere and a cube, a line (Point+direction)  and then get the Position XYZ of the first collision which the line encounters?
The documentation only shows the classes and which methods they have. But nothing show how to start using MathGeoLib. Are there any tutorials which are not findable on google?

Background information on my project:
I am making a collision detector for San Andreas Multiplayer, the server has no information whatsover on the game world so I decided to extract the collision files and object placement files and convert them to a usable format for my plug-in.
The objects have a position XYZ and quaternion rotation XYZW and the collision files, well, have lots of stuff in them [a project member is writing a parser for those .col files for the project].
The project goals are to provide a mechanism to determine the Z position based on the XY position and to provide a ray-tracer which tells you where a line (StartPos,EndPos) intersects (hit XYZ) in the game world.
This is why I need to know how to accomplish this with MathGeoLib. I'm going to load all the object collisions into one world and then execute the ray tracer functions. (Amount of objects is around 30,000 in a 6000x6000x1000 area)

A: Check out
http://bulletphysics.org/wordpress/
Bullet is an open source physics engine and comes with lots of example code. In particular you want to use the rayTest() method of a dynamics world to cast a ray and return the nearest collision point. To summarize you'll need to; create a dynamics world, load your sphere and cube data into it, and then call rayTest(startPoint, endPoint, resultCallback);
Assuming you haven't used bullet before start with the "hello world" example code to see how you can easily create a dynamics world and add rigid bodies to it.


text:
Q: Why is there a green border around the annotation? I wanted to have a blue annotation to explain one of the points, but it has a green outline, like the color of my mind map. How can I fix that
    \documentclass[12pt]{article}

    \usepackage[ngerman]{babel}
    \usepackage[a4paper, text={16.5cm, 25.2cm}, centering]{geometry}
    \usepackage[sfdefault]{ClearSans}
    \usepackage[utf8]{inputenc}
    \setlength{\parskip}{1.2ex}
    \setlength{\parindent}{0em}

    \usepackage{tikz}
    \usetikzlibrary{mindmap}

    \begin{document}

    \tikzstyle{every annotation}=[fill=blue!20, text width={}, align=left]
    \begin{tikzpicture}[mindmap, grow cyclic,
    every node/.style=concept,concept color=lime!80, level 1/.append style={level distance=5cm, sibling angle=120}, level 2/.append style={level  distance=3 cm, sibling angle=60}]

  \node{Lehramt}
        child{node{Pädagogik}
        child{node{Steop}}
        child{node{Erziehen und Beraten}}
        child{node{Lehren und Lernen}}
        child{node{Schul\-architek\-tur}}
}
child{node{Sport}
    child{node{Physio\-logie}}
    child{node{Anatomie}}
    child{node{Inklusives}}
}
child[level distance=6cm]{node{Französisch}
    child{node{Sprach\-kurs}}
    child{node (n2) {Fach\-didaktik}}
    child{node{Sprach\-wissen\-schaft}}
    child{node{Landes\-wissen\-schaft}}
    child{node{Medien\-wissen\-schaft}}
    child{node{Literatur\-wissen\-schaft}}
}
;
\node [annotation, right,] at (n2.east) {Französisch unterrichten lernen}
   ;
   \end{tikzpicture}

   \end{document}

Thank you :)

A: Use concept color=blue or draw=blue to override the inherited color settings from the mindmap nodes.
\documentclass[12pt]{article}
\usepackage[ngerman]{babel}
\usepackage[a4paper, text={16.5cm, 25.2cm}, centering]{geometry}
\usepackage[sfdefault]{ClearSans}
\usepackage[utf8]{inputenc}
\setlength{\parskip}{1.2ex}
\setlength{\parindent}{0em}

\usepackage{tikz}
\usetikzlibrary{mindmap}

\begin{document}

\begin{tikzpicture}[mindmap, grow cyclic,
  every node/.style=concept,concept color=lime!80, level 1/.append style={level distance=5cm, sibling angle=120}, level 2/.append style={level  distance=3 cm, sibling angle=60},
  every annotation/.style={concept color=blue,fill=blue!20, text width={}, align=left}%
]
  \node{Lehramt}
  child{node{Pädagogik}
    child{node{Steop}}
    child{node{Erziehen und Beraten}}
    child{node{Lehren und Lernen}}
    child{node{Schul\-architek\-tur}}
  }
  child{node{Sport}
    child{node{Physio\-logie}}
    child{node{Anatomie}}
    child{node{Inklusives}}
  }
  child[level distance=6cm]{node{Französisch}
    child{node{Sprach\-kurs}}
    child{node (n2) {Fach\-didaktik}}
    child{node{Sprach\-wissen\-schaft}}
    child{node{Landes\-wissen\-schaft}}
    child{node{Medien\-wissen\-schaft}}
    child{node{Literatur\-wissen\-schaft}}
  };
  \node[annotation, right] at (n2.east) {Französisch unterrichten lernen};
\end{tikzpicture}
\end{document}

A: This is no proper solution, but a workaround:
\tikzstyle{every annotation}=[fill=blue!20, text width={}, align=left, line width=0.0001pt,]

It is not nice, but I dont want to keep it for myself either.


text:
Q: In Mulesoft Api development, to integrate any application with salesforce do we need to use salesforce connector or http request? I am using a Mulesoft Salesforce connector for the integration of a system with Salesforce. To achieve it I was calling three-time Salesforce for an operation such as to get assets from Salesforce by using HTTP connector

*

*to get token

*to get salesforce API version

*the actual rest API call

to avoid three calls I used a Salesforce connector that is easy to configure and easy to use.
My question is here now that what is the best way for it? using HTTP call three times or a salesforce connector?

A: We did it using Salesforce connector and in MuleSoft I would say that's the best way to do it. It simplifies the whole process by handling the OAuth token services etc.
As Salesforce bought MuleSoft I believe there will be seemless integration options will come in future. There are many already.
That connector is just a wrapper over those multiple http calls actually.


text:
Q: Unable to download updates: The following packages have unmet dependencies Ubuntu 21.04 64 bits
The warning window doesn't show what software has the problem.

I typed sudo apt-get update showing this:
Hit:1 http://us.archive.ubuntu.com/ubuntu hirsute InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu hirsute-updates InRelease [115 kB]
Get:3 http://security.ubuntu.com/ubuntu hirsute-security InRelease [110 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu hirsute-backports InRelease [101 kB]
Hit:5 https://dl.winehq.org/wine-builds/ubuntu hirsute InRelease
Fetched 326 kB in 5s (61.9 kB/s)
Reading package lists... Done

A: Run the following commands to update the packages manually:
sudo apt update
sudo apt dist-upgrade

The first command only updates your package list to let the system know what packages need to be updated. The second command actually performs the upgrade (software updates).
Alternatively, you could also run the following commands to achieve the exact same result:
sudo apt update
sudo apt full-upgrade

On a related note, you can skip kernel updates by running the following commands instead (not recommended):
sudo apt update
sudo apt upgrade

If it still shows the same message in the software center, run the following command to update vim manually:
sudo apt update
sudo apt install --reinstall vim