text:
Q: TypeError an invalid keyword argument for this function I am new to Python trying to make forms field and have a problem.
My forms shows correctly at html but when I am trying to submit data and save it to a database, but I have an error:

TypeError at /srdb/
  'send_date' is an invalid keyword argument for this function

Here is my code:
models.py
class Srdb(models.Model):
send_date = models.DateField()
send_weight = models.IntegerField(default=0, validators=[MaxValueValidator(10000), MinValueValidator(100)])
track_code = models.CharField(default=None, blank=False, max_length=20)
send_index = models.IntegerField(default=None, blank=False,
                                 validators=[MaxValueValidator(999999), MinValueValidator(100000)])
sender_fullname = models.CharField(default=None, blank=False, max_length=150)
sender_dob = models.DateField()
sender_adress = models.CharField(default=None, blank=False, max_length=400)

receiver_index = models.IntegerField(default=None, blank=False,
                                     validators=[MaxValueValidator(999999), MinValueValidator(100000)])
receiver_fullname = models.CharField(default=None, blank=False, max_length=150)
receiver_adress = models.CharField(default=None, blank=False, max_length=400)
sender = models.ForeignKey(Dostavshik, on_delete=models.CASCADE, default=None, blank=False)

def __str__(self):
    return str(self.id)

forms.py
class SrdbForm(forms.Form):
send_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Отправки')
send_weight = forms.IntegerField(initial=0, validators=[MaxValueValidator(10000), MinValueValidator(100)],
                                 label='Отправленный Вес (граммы)')
track_code = forms.CharField(max_length=20,
                             widget=forms.TextInput(attrs={'placeholder': 'Код Отслеживания Посылки'}),
                             label='Трек Код')
send_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
                                widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Отправления'}),
                                label='Индекc Отправления')
sender_fullname = forms.CharField(max_length=150,
                                  widget=forms.TextInput(attrs={'placeholder': 'Отправитель'}),
                                  label='ФИО отправителя')
sender_dob = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Рождения Отправителя')
sender_adress = forms.CharField(max_length=200,
                                widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Отправителя'}),
                                label='Адрес отправителя')

# Получатель
receiver_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
                                    widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Получения'}),
                                    label='Индекс Получателя')
receiver_fullname = forms.CharField(max_length=100,
                                    widget=forms.TextInput(attrs={'placeholder': 'Получатель'}),
                                    label='ФИО Получателя')
receiver_adress = forms.CharField(max_length=200,
                                  widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Получателя'}),
                                  label='Адрес Проживания Получателя')
sender = forms.ModelChoiceField(queryset=Dostavshik.objects.all(),
                                label='Отправил Доставщик')

views.py
def srdb(request):
form_srdb = SrdbForm()
if request.method == 'POST':
    form_srdb = SrdbForm(request.POST)
    if form_srdb.is_valid():
        Srdb.objects.create(**form_srdb.cleaned_data)
        messages.success(request, 'Данные Успешно Сохранены')
context = {
    'form_srdb': form_srdb
}
template = 'srdb.html'
return render(request, template, context)

After submit always have this error:

TypeError at /srdb/
  'send_date' is an invalid keyword argument for this function


text:
Q: UITableView: most performant way to create index? I have a pretty large UITableView (~ 10k entries) where I need an index and which should be sortable; on older devices (e.g. iPhone 4s, iPhone 5) it sometimes hangs a little bit during search, because I always have to re-create the index.
I do not need localization, but is UILocalizedIndexedCollation nevertheless the way to go? Or is there a standard iOS-thing to create performant indices?

A: 1、maybe you should try to save index height before,you can create a frame model,and save your index frame,every time you create a index will use frame data you create before such as
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *dict = self.dataList[indexPath.row];
CGRect rect = [dict[@"frame"] CGRectValue];
return rect.frame.height;}

then you can use this mode to crate cell.
2、you say i you have a so many cell need to create,i don't know what data source you use,but if use a web data, and loading in async, you probably open so many queue when your app running, and when you scrolling or when you network not so greate, it will be bad,so i suggest you should re-create data loading method,when you scroll fast, just loading cell around this area,when you scroll slowly, you can async loading image and text in your data source,
you can do this thing use uiscrollviewdelegate function
NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
    for (NSIndexPath *indexPath in visiblePaths)
    //get cell you can see
    {
    //get datasource object,when object loading complete,stop loading.

    }

when tableview stop scroll,loading image
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

     if (self.tableView.dragging == NO && self.tableView.decelerating == NO)
        {
           //star loading image,async

        }

redpajama_set_name: RedPajamaStackExchange


text:
Q: Express in interval notation where f is differentiable (graph)
The graph of the function is cut off in the vertical direction because the function escapes to negative infinity.
I know [2,-1)U(-1,1)U(1,3)U(3,4], but the system is telling me that my second set is incorrect.

A: Recall that the definition of $f'(0)$ is $$ \lim_{x \to 0} \frac{f(0 + h) - f(0)}{h}$$
From the graph you have shown, the function isn't even defined at $0$ thus the expression in the limit doesn't even make sense thus f can't be differentiable at $0$. So the second set should be $(-1,0) \cup (0,1)$.
Note that even if the function was defined arbitrarily at $0$, it still can't be differentiable at $0$. Because if it was differentiable at $0$, it would be continuous at $0$, and thus there is some interval around $0$ on which the function is bounded (this should be intuitively clear, but a rigorous proof of this is a straight forward exercise using the $\varepsilon - \delta$ definition of continuity... if you are unfamiliar with this, just take this statement for granted). However the bold statement is clearly false because from the graph, it is clear that $f$ is unbounded in every interval around $0$. Thus our initial assumption that $f$ is differentiable at $0$ is false.


text:
Q: Is there any way to encrypt and decrypt an arabic string in java or c#? I want to encrypt and decrypt an arabic string in java, When I try to encrypt arabic string it convert like this,
input :  كيف حالكم
apply encryption
output : ?????????
after decryption.
Can we encrypt arabic words like english words in and then decrypt them without any problem or weird text like ???? this.
 public static byte[] encrypt(String value)
{
    try
    {
        IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
        SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");

        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);

        byte[] encrypted = cipher.doFinal(value.getBytes());

        return encrypted;
        // return Base64.encodeBase64String(encrypted);
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }

    return null;
}

public static String decrypt(String encrypted)
{
    try
    {
        IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
        SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");

        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
        cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);

        byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));

        return new String(original);
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }

    return null;
}
public static String encryptAndEncodeString(String value)
{
    value = new String(new Base64().encode(encrypt(value)));
    value = encodeBase64(value);
    return value;
}

public static String decodeAndDecryptString(String value)
{
    value = decodeBase64(value);
    value = decrypt(value);
    return value;
}


text:
Q: A calculation detail about Hardy-Littlewood maximal operator from the book "Classical Fourier Analysis" When I learn the book "Classical Fourier Analysis 3rd"(GTM249) by Loukas Grafakos, I encounter a difficulty. On page 90 line 3, the author write:
$$\frac{6^{n}R^{n}}{(|x|+R)^{n}}+\sum_{k=0}^{\infty}\frac{1}{2^{nk}}\frac{6^{n}(2^{k+1}R)^{n}}{(|x|+2^{k+1}R)^{n}}\leq \frac{C_{n}\
\log(e+|x|/R)}{(1+|x|/R)^{n}} \,.$$ Then the author says:"where the last estimate follows by summing separately over k satisfying $2^{k+1}\leq |x|/R$ and $2^{k+1}\geq |x|/R$"
Frankly speaking, I really do not know how to prove the above inequality although the author write the hint. Thanks!

A: It clearly suffices to prove that
$$\ \sum_{k=0}^{\infty}\frac{1}{2^{nk}}\frac{6^{n}(2^{k+1}R)^{n}}{(|x|+2^{k+1}R)^{n}}\leq \frac{C_{n}\
\log(e+|x|/R)}{(1+|x|/R)^{n}} \,. \tag{*}$$
In this bound, you can regard $n$ as a constant since a factor of $C_n$ is allowed on the RHS.
For $k$ such that $2^{k+1}R \le |x|+R$, replace the expression    $(|x|+2^{k+1}R)$ in the denominator by $|x|+R$. Then all the resulting  terms become
$$\frac{6^n (2R)^n}{|x|+R} \,,$$
and the number of such terms is at most $\log_2(e+|x|/R)$. This yields the RHS of $(*)$.
For $k$ such that $2^{k+1}R >|x|+R$, replace the expression    $(|x|+2^{k+1}R)$ in the denominator by $2^{k+1}R$. Then  these  terms form a geometric series (with decreasing summands),   that can be bounded by a constant multiple of the first term.
That first term (for which $|x|+R <2^{k+1}R  \le 2|x|+2|R|$) has the form
$$\frac{C_n'}{(1+|x|/R)^n}  $$
which is smaller than the RHS of $(*)$.


text:
Q: Using iron-router to go to a certain id section of the page (url#portion) in Meteor.js I have routes set up with iron-router that make sure the page goes to the top of the page:
Router.route('/services', {
    name: 'services',
    template: 'services',
  onAfterAction: function () {
          scrollTop();
  }
});

function scrollTop() {
    window.scroll(0, 0);
}

However, if I am on another route, and I have a link like /services#thisid
it will still take me to the top of the page (not to the portion of the page with the id=thisid).
Is there a way to get around this?

A: This should address your issue both for this issue and your layout override question.
Router.configure({
  layoutTemplate: 'main',
  onAfterAction: function(){
    console.log('hash', this.params.hash);
    if(!this.params.hash){
      scrollTop();
    }
  }
});
Router.route('/services', {
  name: 'services',
  template: 'services',
});

Router.route('/inquiry', {
  name: 'inquiry',
  template: 'inquiry',
  layoutTemplate: 'alternate'
});

The check for this.params.hash ensures that there is no value for the hash before executing the scrollTop. The layoutTemplate on the inquiry route overrides the layout while still respecting the global onAfterAction.


text:
Q: Is there a tool to convert a Buckminster project into Maven? I'm tasked with migrating our product's build/dependency-management technology from Buckminster to Maven.  I'm quite decent with Maven, but before I drill down into Buckminster's inner-workings (which I'm not currently very knowledgeable on), I thought I'd see if there was an available tool to automate this, as it would be a rather lengthy task if done manually.  If not, I guess I'll write one myself.
Any input would be much appreciated!  Thanks!


text:
Q: Boot time in Ubuntu 20.04 is more than 4 minutes. How to reduce it? The boot time for my Desktop PC is more than 4 minutes. I would love to know what processes and services should be terminated in order to fix this issue.
I have already tried fixing up startup applications, but since, the issue is boot time, it does not help in any manner.
System Details:
OS: Ubuntu 20.04 LTS, upgraded from 19.10
Processor: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz,
RAM: 8GB DDR4
GPU: Nvidia GeForce 940MX
Hard Drive: 1TB, Seagate

Output from systemd-analyze blame:
anubhav@anubhav-ubuntu:~$ sudo systemd-analyze blame
[sudo] password for anubhav:
46.599s plymouth-quit-wait.service
17.140s snapd.service
16.674s networkd-dispatcher.service
16.645s dev-sda2.device
16.136s NetworkManager-wait-online.service
15.605s udisks2.service
12.050s systemd-journal-flush.service
11.381s dev-loop10.device
11.374s dev-loop4.device
11.317s accounts-daemon.service
10.951s dev-loop15.device
10.908s user@124.service
10.419s dev-loop17.device
10.371s dev-loop19.device
10.363s dev-loop16.device
10.315s dev-loop14.device
10.260s dev-loop18.device
 9.566s dev-loop11.device
 9.499s dev-loop3.device
 9.197s dev-loop1.device
 9.162s NetworkManager.service
 9.086s polkit.service
 8.961s dev-loop5.device
 8.906s dev-loop12.device
 8.871s dev-loop8.device
 8.676s dev-loop7.device
 8.561s dev-loop13.device
 8.472s avahi-daemon.service
 8.459s bluetooth.service
 8.446s dev-loop2.device
 8.317s switcheroo-control.service
 8.309s thermald.service
 8.291s systemd-logind.service
 8.287s wpa_supplicant.service
 7.903s dev-loop0.device
 7.448s dev-loop6.device
 6.816s gpu-manager.service
 6.658s dev-loop9.device
 6.284s preload.service
 6.121s vboxdrv.service
 5.464s grub-common.service
 5.174s apport.service
 5.115s apport-autoreport.service
 5.099s ModemManager.service
 4.516s dhcpcd.service
 4.478s systemd-resolved.service
 4.475s secureboot-db.service
 4.457s grub-initrd-fallback.service
 4.293s systemd-udevd.service
 4.123s rsyslog.service
 3.654s systemd-tmpfiles-setup.service
 3.351s lpd.service
 2.666s gdm.service
 1.954s apparmor.service
 1.821s tlp.service
 1.723s e2scrub_reap.service
 1.522s snap-core-8689.mount
 1.488s nvidia-persistenced.service
 1.449s systemd-modules-load.service
 1.440s snap-core18-1754.mount
 1.424s snap-pycharm\x2dprofessional-196.mount
 1.409s snap-core18-1705.mount
 1.379s systemd-backlight@backlight:intel_backlight.service
 1.338s upower.service
 1.266s snap-gtk\x2dcommon\x2dthemes-1440.mount
 1.150s plymouth-start.service
 1.148s systemd-random-seed.service
 1.064s systemd-sysctl.service
 1.023s systemd-tmpfiles-setup-dev.service
 1.012s snap-clion-111.mount
  967ms systemd-journald.service
  965ms kerneloops.service
  957ms modprobe@drm.service
  950ms snap-vlc-1397.mount
  939ms snapd.seeded.service
  907ms snapd.apparmor.service
  872ms swapfile.swap
  827ms systemd-timesyncd.service
  755ms snap-gtk\x2dcommon\x2dthemes-1506.mount
  748ms snap-scrcpy-211.mount
  733ms binfmt-support.service
  702ms snap-scrcpy-217.mount
  645ms snap-goland-87.mount
  624ms snap-vlc-1620.mount
  561ms colord.service
  470ms systemd-remount-fs.service
  420ms openvpn.service
  392ms systemd-sysusers.service
  388ms setvtrgb.service
  354ms systemd-user-sessions.service
  348ms vboxautostart-service.service
  348ms vboxballoonctrl-service.service
  327ms keyboard-setup.service
  321ms kmod-static-nodes.service
  321ms snap-goland-86.mount
  316ms snap-pycharm\x2dprofessional-198.mount
  310ms vboxweb-service.service
  305ms snap-clion-112.mount
  250ms systemd-udev-trigger.service
  244ms snap-spotify-41.mount
  240ms snap-gnome\x2d3\x2d34\x2d1804-33.mount
  229ms user@1000.service
  224ms systemd-fsck@dev-disk-by\x2duuid-94AE\x2dCADC.service
  218ms systemd-tmpfiles-clean.service
  217ms snap-gnome\x2d3\x2d34\x2d1804-27.mount
  216ms console-setup.service
  182ms snap-snap\x2dstore-433.mount
  177ms dev-hugepages.mount
  177ms dev-mqueue.mount
  176ms sys-kernel-debug.mount
  175ms sys-kernel-tracing.mount
  160ms snap-core-9066.mount
  140ms pppd-dns.service
   88ms user-runtime-dir@124.service
   80ms user-runtime-dir@1000.service
   79ms ufw.service
   76ms systemd-update-utmp.service
   64ms boot-efi.mount
   52ms proc-sys-fs-binfmt_misc.mount
   16ms rtkit-daemon.service
   14ms alsa-restore.service
   13ms systemd-update-utmp-runlevel.service
   12ms plymouth-read-write.service
    3ms sys-kernel-config.mount
    2ms sys-fs-fuse-connections.mount
  697us snapd.socket

Output from systemd-analyze critical-chain graphical.target
anubhav@anubhav-ubuntu:~$ systemd-analyze critical-chain graphical.target
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.

graphical.target @1min 20.194s
└─multi-user.target @1min 20.194s
  └─kerneloops.service @51.394s +1.526s
    └─network-online.target @50.933s
      └─NetworkManager-wait-online.service @34.497s +16.433s
        └─NetworkManager.service @25.721s +8.774s
          └─dbus.service @25.718s
            └─basic.target @25.672s
              └─sockets.target @25.672s
                └─snapd.socket @25.671s +1ms
                  └─sysinit.target @25.368s
                    └─systemd-timesyncd.service @57.447s +310ms
                      └─systemd-tmpfiles-setup.service @22.090s +2.127s
                        └─local-fs.target @22.081s
                          └─run-user-124-gvfs.mount @59.648s
                            └─run-user-124.mount @44.537s
                              └─local-fs-pre.target @7.154s
                                └─systemd-tmpfiles-setup-dev.service @6.129s +1.024s
                                  └─systemd-sysusers.service @5.757s +371ms
                                    └─systemd-remount-fs.service @5.594s +115ms
                                      └─systemd-journald.socket @5.125s
                                        └─system.slice @5.057s
                                          └─-.slice @5.057s


text:
Q: How to add a button to html which will print my site to PDF? I would like to add a button which will have the same functionality as going to "Settings->Print->Print to file". It should work for IE only.
To be more specific, this button should be show on my website and should automatically redirect to me "Printing" window where I can choose whether print to file or not. Even better if it can choose the proper "printer" and generate pdf.
Thanks for help.

A: So you want this button to appear only in Internet Explorer and this has to print the page or generate the page to PDF?
Maybe you could try something like this in your head:

And your buttons should be like:

Print


text:
Q: Create model instance from dict containing different keys compared to model attributes in Django I am trying to create model/s from an api response. The response received has different keys as compared to the model attributes in our system. I would like to know the best way to create a model from that response.
class MyModel(BaseModel):
    external_id = models.IntegerField(blank=True, null=True)
    start_date = models.DateField(blank=True, null=True)
    end_date = models.DateField(blank=True, null=True)

    def save_to_db_from_external_data(response_data):
        map_dict = {
            'externalId': 'external_id',
            'startDate': 'start_date',
            'endDate': 'end_date'
        }

        if type(response_data) == 'dict':
            new_model_data_dict = {}
            for key in map_dict:
                if key in response_data:
                    new_model_data_dict[map_dict[key]] = response_data[key]
            MyModel.objects.create(**new_model_data_dict)

        elif type(response_data) == 'list':
            new_model_data_list = []
            for data_dict in response_data:
                new_data_dict = {}
                for key in map_dict:
                    if key in data_dict:
                        new_data_dict[map_dict[key]] = data_dict[key]
                new_model_data_list.append(new_data_dict)
            MyModel.objects.create(**(model_data_dict) for model_data_dict in new_model_data_list)

The above is the code that I have written. Is this the correct way to do the required task? Or is there any better way in django to achieve the same?

A: Your solution looks fine.
Tip:
avoid to copy and paste code pieces. Try to use functions and classes wherever you can.

class MyModel(BaseModel):
    external_id = models.IntegerField(blank=True, null=True)
    start_date = models.DateField(blank=True, null=True)
    end_date = models.DateField(blank=True, null=True)

    def create_object_from_external_data(response_data):
        MyModel.objects.create(
            external_id=response_data.get('externalId'),
            start_date=response_data.get('startDate'),
            end_date=response_data.get('endDate')
        )

    def save_to_db_from_external_data(response_data):
        if type(response_data) == 'dict':
            self.create_object_from_external_data(response_data)
        elif type(response_data) == 'list':
            for data_dict in response_data:
                self.create_object_from_external_data(data_dict)


text:
Q: Shopping cart checkout with JQuery draggable + droppable? I'm trying to make a drag + drop shopping cart and have looked into two options: JQuery UI draggable and Scriptaculous Draggable + Rails Helpers, but I'm having difficulty tying controller actions to items that have been dragged into the shopping cart.
E.g. I want users to drag items into the cart div, then click 'checkout' and continue on to providing payment information for all the items, etc...
Currently in my db I have a column that accepts the multiple item ids that they want to purchase as a hash. I've also tinkered with setting it up as a form with hidden fields, but this might not be the best choice.
Any ideas on how I could achieve this? Example code would be awesome if possible. Thank you very much for your help!

A: JQuery UI Droppable would work well. There is an example of using it for a shopping cart here:
http://jqueryui.com/demos/droppable/#shopping-cart
To integrate with Rails 3, one approach is to treat the page as a traditional (non-AJAX) web form, but use Javascript to manipulate hidden input elements.

*

*Use JSON to populate a JavaScript array/object with your data (your data model)

*Use Javascript with JQuery to manipulate the model

*Use a small Javascript function to write the model out to hidden input elements that are correctly named for Rails - the function gets run every time the data is changed

*Submit the form as usual when a submit button is clicked


text:
Q: htaccess rule for getting and setting the parameter after the domain name How can I write the htaccess rule for the below scenario:
Here is my domain: http://localhost/xyz/ : it is converting to http://localhost/xyz/#/ while hitting the url. My application is in angular js.
Currently, If I am entering http://localhost/xyz/dinesh/ which is not permissible and produce "404". I wish to allow the user pass his username in the url, and want to access the username in the whole application. here
'dinesh' is the username.
If http://localhost/xyz/dinesh/ entered, should be converted to http://localhost/xyz/
Plz help!

A: This should work:
RewriteEngine on
RewriteRule ^xyz/([a-zA-Z]+)/$ xyz/?username=$1 [QSA]

This will only accept alphabetical characters for the username, and convert it to a parameter username. Any existing query string will be preserved. Let me know if that needs tweaking.

A: RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ /? [R=301,NC,L]


text:
Q: Why aren't all elements in the list deleted? myList = ["Steven", "Jim", "John", "Eric", "Conor"]
print("My List: ", myList)
for elem in myList:
    myList.remove(elem)
print("My List: ", myList)

I want to delete each element of the list. I'm going through the each element of the list and remove it, but there's two left: Jim and Eric.
I've totally no clue why aren't they being deleted.
What's my problem? And how can I delete them?


text:
Q: Function that checks if a string occurs in another string I'm currently reading and doing each and every of the exercises in John Guttag's Introduction to Computation and Programming Using Python. One particular problem I cannot solve for the life of me:

Write a function isIn that accepts two strings as arguments and
  returns True if either string occurs anywhere in the other, and False
  otherwise. Hint: you might want to use the built-in str operation in.

I went through every discussion I could find here, tried with both in and find, constantly changing something in the code, but every time I would run my program to check if 'abc' occurs in 'efg' the answer would be True.
Any idea how to solve it? Again, I need to write a function, not simply go with in like:
x='abc'

y='efg'

if x in y:

    # Blah

else:

    # another Blah

The code I wrote (I'm adding this as apparently some would like to see it) was basically this:
def isIn(x,y):

    if x in y or y in x:

        return True

    else:

        return False

a='abc'

b='efg'

isIn(a,b)

if True:

    print "True"

else:

    print "False"

A: I'm getting the impression that you are a newcomer to Python, so here is the solution to your problem below laid out just as the question asks :)
def isIn(string_1, string_2): #This is the function that returns true/false

    if (string_1 in string_2) or (string_2 in string_1):
        is_in = True
    else:
        is_in = False

    return is_in

if __name__ == "__main__":
    string_1 = input ("String 1 here: ")
    string_2 = input ("string 2 here: ")

    is_in = isIn(string_1, string_2) #Calls function with strings as parameters
    print (is_in) #Prints the evaluation of the function after it has run

The problem with your code was that you say if True, but you aren't giving it anything to check against. if True on its own is always true.
If you want me to explain how this code works in more detail I'd be happy to do so :)

A: The problem is that you are completely ignoring the return value of the function isIn, and the reason why you always get True printed by the code is that the condition you are checking in the if statement is the boolean constant True, which is of course always True.
Try changing your code to:
a='abc'
b='efg'
r = isIn(a,b)

if r:
    print "True"
else:
    print "False"

A: Simply put:
x=input('Enter string #1: ')
y=input('Enter string #2: ')
#can also just define x and y separately in the console and invoke the
#    function on those values

def isIn(x,y):
    if x in y:
       return True
    elif y in x:
        return True
    else:
        return 'False'

print(isIn(x,y)) #invokes and prints the results of the function evaluating
#the x and y the user inputs; otherwise nothing is returned

A: you are not printing the isIn(x,y)
def is_in(x,y):
    if x in y or y in x:
        return True
    else:
        return False
print(is_in("hello","hello world"))

try this :)


text:
Q: Setting the cursor for a header in a QTreeWidget via PySide I'm trying to set the cursor for a QTreeWidget's header for when the user hovers over the header. I have tried setting the header in the class through self.header().setCursor( my_cursor ), but so far the cursor isn't changing when I hover my mouse over the header. I've searched through Google to try to track down how to do this, but so far I have found nothing. I have tested with PySide 1.2.0 (in Maya 2015) and 1.2.2.
Am I doing this wrong, or is there a workaround? Here's some example of code:
import sys
from PySide import QtCore, QtGui

class Tree( QtGui.QTreeWidget ):

    def __init__(self, parent = None):
        super(Tree, self).__init__(parent = parent)
        self.header().setCursor(QtGui.QCursor( QtCore.Qt.WaitCursor))

widget = Tree()
widget.show()

If I set the cursor on the tree widget itself, then the cursor is set as expected.

A:
Hacky way, but you could do this by casting self.header() into a QWidget, since setCursor() is a method of QWidget class.
import sys

from PySide import QtCore, QtGui

class Tree(QtGui.QTreeWidget):
    def __init__(self, parent=None):
        super(Tree, self).__init__(parent=parent)
        QtGui.QWidget(self.header()).setCursor(QtCore.Qt.WaitCursor)

widget = Tree()
widget.show()

And you don't really have to cast QtCore.Qt.WaitCursor to a QtGui.QCursor object.
Hope that was useful.

A: There is no need to reset the header of the tree.
Just set the cursor on the viewport of the existing header:
    self.header().viewport().setCursor(QtCore.Qt.WaitCursor)

A: Adding to kartikg3's answer. This will allow for the full length of the header to be used.
import sys

from PySide import QtCore, QtGui

class Tree(QtGui.QTreeWidget):
    def __init__(self, parent=None):
        super(Tree, self).__init__(parent=parent)
        header_widget = QtGui.QWidget()
        header_widget.setCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
        header_layout = QtGui.QHBoxLayout()
        header_layout.addWidget(header_widget)
        self.header().setLayout(header_layout)

widget = Tree()
widget.show()

The only problem with either approach so far seems to be that adding the widget will remove the ability to change the size of the columns.


text:
Q: Microprogramming vs. Machine Language programming I'm a bit confused between the microprogramming level vs machine language level.  For example:

*

*Where do both types of programs reside while being executed?

*Do either have a 1:1 mapping to assembly language true-op instructions?

*Is the format of either defined by the processor architecture?

A: Micro-code is another level of abstraction beyond machine code.  The actual CPU is running microcode, and a translation engine converts machine code into microcode on the fly.  This is done for a variety of reasons, including faster, smaller processors, easier to create a complex processor with less debugging, and for backwards compatibility.  For instance, the x86 instruction set contains some string processing instructions that are rarely used.  However, to remain backwards compatible, they must still be available in modern x86 processors.  Rather than hardwiring an execution path for these instructions, they are converted into microcode and executed.  This saves silicon, while still remaining backwards compatible.

Where do both types of programs reside while being executed?

The machine code resides in the cache (after being pulled from RAM).  The micro code resides in a micro code cache, depending on the particular machine architecture.  The cache may only be large enough to hold enough microcode to hold the converted microcode from the largest possible machine code instruction, or it may be a larger cache that stores the converted results of many machine codes so that it doesn't need to reconvert all the machine code on each iteration for small loops.
In some architectures the converted microcode isn't stored anywhere - the fetch/translate unit simply spits out a series of microcode instructions based on the currently executing machine code.  In this case the microcode is executing from a ROM of some sort, and the machine code is essentially an index into the ROM - pointing to the series of microcode instructions that must be run in order to fully execute the machine code instruction.

Do either have a 1:1 mapping to assembly language true-op instructions?

Machine code and assembly code, in general are 1:1 mapped to assembly instructions.  It depends on the assembler.  High level assemblers may have a large set of macros that allow one to write one line of assembly code and the assembler will produce several machine codes.
But in general "pure" assembly language can be converted directly into machine code using the instruction set table in the processor's manual.
I'm not sure what you mean by "true-op instructions" though.  Perhaps you can explain the reference.

Is the format of either defined by the processor architecture?

The format of both machine code and microcode are defined by the processor architecture.

A: Many processors are driven by a state machine whose transition sequence is affected by the instructions being executed.  Microcode "instructions" often specify the interactions among various registers and buses in a way which would not be visible to a programmer.
For example, a microcode instruction for an 8-bit CPU in state #1 might specify that output enables for both halves of the program counter should be active (causing the program counter to be output on the upper and lower internal address bus), the program-counter-increment signal should be active, the external address latch signals should be active (so the external address bus will track the internal one) and the RAM-read signal should be active, and the controller should switch to state #2.
In state #2, the external data bus should feed to the internal primary data bus, and the instruction register, which reads from that bus, should be loaded.  The program counter should as before be output on both halves of the address bus, and another RAM-read issued.  Bits 5-7 of the instruction register should be loaded into bits 0-2 of the state controller, bit 3 of the state register should be set unless bits 1-7 of the instruction register are all set, and other bits of the state register should be clear, the net result being that the next state will be #7-#15.
Note that microcode isn't really defined in terms of instructions, but rather in terms of combinations of control signals.  The hardware will not be set up to allow general-purpose instructions in microcode, but rather to load or output various registers from/to the buses on which they sit, or connect different buses to each other, and use various bits or combinations thereof to select different states.  Many aspects of the design will be hard-wired (e.g. opcodes FE and FF might be special-cased in hardware rather than in microcode).  The idea with microcode isn't to run programs, but to replace logic.

A: Basically, microcode expands a limited CPU instruction set to contain higher level instructions that would be cumbersome to implement in hardware, but relatively easy to build with existing instructions.  Microcode allows a processor with a small instruction set to function like one with a larger instruction set.
Lets say you're working with a MARIE instruction set and you would like an Add x,y function, but the architecture only allows a Add x (which just adds what's currently in the register to x)  so you add a microcode instruction:
LOAD x //Load x into the register
ADD y //Add y to the value in the register

Now when your machine language code says:
ADD x,y

it looks up the ADD function you added to ROM (your microcode) and executes it.  This is great because it increases your instruction set, which allows more readable machine code, and since your microcode is stored in ROM, it's also a little faster than calling the LOAD and ADD from RAM.
I used to work at a company that actually wrote microcode to perform custom measurements at very high speeds on their older systems.  However, with the advances in FPGAs they have switched over to those, which are much faster (since you actually are implementing the "custom instructions" in hardware instead of ROM).


text:
Q: Keep focus on field after Save I'm using a visual force page with an extended controller. When I click on the 'Save Only' button the page reloads to the top. How can I keep the focus on the field that a user was on prior to saving ? I am using the save action on the standard controller, not the extended controller. Below is my javascript and visual force snippet where the command button is calling the functions.
Any ideas as to why the page does not scroll down to the last field where the cursor was ?
<script src="/soap/ajax/30.0/connection.js" type="text/javascript"></script>
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" />
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" />
<script>
    var fileldId;
    function oncfoucs(){
        debugger;
       fileldId = $(document.activeElement);
    }
function focusComplete(){
    fileldId.focus();
}
</script>

............
<apex:outputPanel style="text-align:center" layout="block">
<apex:commandButton styleClass="myClass" action="{!save}" value="Save Only" />
<apex:commandButton styleClass="myClass" action="{!saveAndReturn}" value="Save and Return to Template" />
<apex:commandButton styleClass="myClass" action="{!ReturnMe}" value="Audit Template Screen" />
<apex:commandButton styleClass="myClass" action="{!save}" value="Save Test" onmouseover="oncfoucs();" oncomplete="focusComplete();" />

</apex:outputPanel>

</apex:pageBlockSection>

............
<apex:outputPanel id="ajaxrequest2">

<!-- OPERATIONS  -->

<!-- <apex:pageBlockSection columns="1" id="section2" title="Operations" rendered="{!RatingInformation=true}"> -->
<apex:pageBlockSection columns="1" id="section2" title="Operations" rendered="{!Operations}" >

<apex:actionRegion >
<apex:pageBlockSection columns="1" showHeader="false"  >
<apex:inputField value="{!Comm_Auto_Audit_Sample_Policy__c.Type_of_Operations__c}" id="operation" rendered="{!TypeOfOperations}" >
    <apex:actionSupport event="onchange" reRender="typeOperation" />
    </apex:inputField>
</apex:pageBlockSection>
</apex:actionRegion>

<apex:outputPanel id="typeOperation">
<apex:pageBlockSection columns="1" showHeader="false" rendered="{!TypeOfOperations}" >
<apex:inputField value="{!Comm_Auto_Audit_Sample_Policy__c.Service_Operation__c}" rendered="{!Comm_Auto_Audit_Sample_Policy__c.Type_of_Operations__c='Service' && TypeOfService}" />

A: This will need some adept javascript programming. I'm hereby providing a high level solution, considering you will be able to implement the same.

*

*You can create a String property in extension controller.

*Bind this property with a hidden control "id = hdnFocusedElement" (let's say a text box) on VF Page.

*For all controls (use jQuery for ease), add "onfocus" event handler, wherein the id of focued field will be set as value of hidden control "hdnFocusedElement"

*Create a javascript which works on page load (jQuery will again help here), and check if there is any value in "hdnFocusedElement" element, then set focus of the id present in value of "hdnFocusedElement" element.


text:
Q: EB Garamond, and fontspec for "optical bold" with small caps? This is somewhat a continuation of my EB Garamond (bold) small caps "suddenly" unavailable in lualatex? ; below, I had written some more details about this font for reference - but in brief, my question is:
Is there a way to set up fontspec with EB Garamond, so:

*

*normal text (within a \newfontfamily command) uses EB Garamond 12;

*then when text is bolded within the same \newfontfamily command (with \bfseries, \textbf) the font switches to EB Garamond 08;

*and when small-caps \textsc is used, either a) Letters=SmallCaps is used, or b) EB Garamond SC font is used?

... such that it would also get rid of these warnings:
LaTeX Font Warning: Font shape `EU2/EBGaramond(0)/bx/n' undefined
(Font)              using `EU2/EBGaramond(0)/m/n' instead on input line 31.

... when compiling the following MWE, test.tex, with lualatex:
\PassOptionsToPackage{dvipsnames}{xcolor}

% compile with: lualatex test.tex

\documentclass[10pt,a4paper]{article}

  \makeatletter
  \newcommand{\name}[1]{\def\@name{#1}}
  \makeatother

  \usepackage[margin=2cm]{geometry}
  \geometry{left=1.25cm,right=1.25cm,top=1.25cm,bottom=1.25cm}

  \usepackage{fontspec}

  \newfontfamily\titlenamefont{EB Garamond}[Ligatures=TeX]

  % NOTE: `SmallCapsFeatures={Letters=SmallCaps}`, as per https://tex.stackexchange.com/questions/114223/, does not force small caps here, only `Letters=SmallCaps` does!?
  \newfontfamily\titlenamefontB{EB Garamond}[Ligatures=TeX,Letters=SmallCaps]

  \newfontfamily\titlenamefontC{EB Garamond 08 Regular}[OpticalSize=0,Letters=SmallCaps,Ligatures=TeX]

  \usepackage[hidelinks=true]{hyperref}

\begin{document}

  \name{\hspace{4em}\addfontfeature{LetterSpace=10.0}\textsc{Brazen Discovery}}

  \begingroup
    \makeatletter
      {\ifcsname titlenamefont\endcsname\titlenamefont\fi \Huge\bfseries{\@name}\par}
    \makeatother
  \endgroup\medskip

  \begingroup
    \makeatletter
      {\titlenamefontB \Huge\bfseries{\@name}\par}
    \makeatother
  \endgroup\medskip

  \begingroup
    \makeatletter
      {\titlenamefontC \Huge\bfseries{\@name}\par}
    \makeatother
  \endgroup\medskip

  Testing some normal paragraph text here...

\end{document}

The current output of this is:

Since my original post, I have done a fresh install of TexLive 2015, and realized the following: originally, I had wanted to achieve bolded small caps; probably by accident, I managed to use EB Garamond 08 instead of EB Garamond 12, which does look slightly more bolded, but is otherwise considered simply a different optical size (How do I use EB Garamond 08?) - while there is no proper "bold" in EB Garamond.
So, I ended up believing that this "bolding" is a result of using \bfseries - so when I tried compiling at a later time and couldn't see the "bolding", I wrote my original post, suspecting installation issues.
Now, at least I can state that I have these 10 .otf font files in ~/.local/share/fonts (Ubuntu 14):
$ ls -la ~/.local/share/fonts/EBGaramond*
-rw-r--r-- 1 user user 200656 Apr  8  2014 ~/.local/share/fonts/EBGaramond08-Italic.otf
-rw-r--r-- 1 user user 259968 Apr  8  2014 ~/.local/share/fonts/EBGaramond08-Regular.otf
-rw-r--r-- 1 user user 212492 Apr  8  2014 ~/.local/share/fonts/EBGaramond12-AllSC.otf
-rw-r--r-- 1 user user 298252 Apr  8  2014 ~/.local/share/fonts/EBGaramond12-Italic.otf
-rw-r--r-- 1 user user 495300 Apr  8  2014 ~/.local/share/fonts/EBGaramond12-Regular.otf
-rw-r--r-- 1 user user  60240 Apr  8  2014 ~/.local/share/fonts/EBGaramond-InitialsF1.otf
-rw-r--r-- 1 user user   5120 Apr  8  2014 ~/.local/share/fonts/EBGaramond-InitialsF2.otf
-rw-r--r-- 1 user user  78512 Apr  8  2014 ~/.local/share/fonts/EBGaramond-Initials.otf
-rw-r--r-- 1 user user 226840 Apr  8  2014 ~/.local/share/fonts/EBGaramondSC08-Regular.otf
-rw-r--r-- 1 user user 353364 Apr  8  2014 ~/.local/share/fonts/EBGaramondSC12-Regular.otf

... and they have been obtained directly from http://www.georgduffner.at/ebgaramond/download.html ; my ~/.fonts directory is now empty.
I have also done fc-cache:
$ fc-cache -f -v ; fc-list | grep aramond
...
fc-cache: succeeded
~/.local/share/fonts/EBGaramond12-Regular.otf: EB Garamond,EB Garamond 12:style=12 Regular,Regular
~/.local/share/fonts/EBGaramond12-Italic.otf: EB Garamond,EB Garamond 12:style=12 Italic,Italic
~/.local/share/fonts/EBGaramondSC12-Regular.otf: EB Garamond SC,EB Garamond SC 12:style=12 Regular,Regular
~/.local/share/fonts/EBGaramond08-Regular.otf: EB Garamond,EB Garamond 08:style=08 Regular,Normal,obyčejné,Standard,Κανονικά,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
~/.local/share/fonts/EBGaramond08-Italic.otf: EB Garamond,EB Garamond 08:style=08 Italic,Cursiva,kurzíva,kursiv,Πλάγια,Italic,Kursivoitu,Italique,Dőlt,Corsivo,Cursief,Kursywa,Itálico,Курсив,İtalik,Poševno,Etzana
~/.local/share/fonts/EBGaramond-InitialsF1.otf: EB Garamond Initials Fill1:style=Regular
~/.local/share/fonts/EBGaramond-InitialsF2.otf: EB Garamond Initials Fill2:style=Regular
~/.local/share/fonts/EBGaramondSC08-Regular.otf: EB Garamond SC,EB Garamond SC 08:style=08 Regular,Normal,obyčejné,Standard,Κανονικά,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
~/.local/share/fonts/EBGaramond12-AllSC.otf: EB Garamond 12 All SC:style=AllSC
~/.local/share/fonts/EBGaramond-Initials.otf: EB Garamond Initials:style=Regular

And this is how the font appears in fontmatrix:

So, even if I have 10 .otf font files installed, I have only 6 entries in fontmatrix... So these entries here are I guess "font families", that is "EB Garamond" is one font family, "EB Garamond SC" is another?
This is what I get when I double-click the "EB Garamond" entry in fontmatrix:

So, here I can see the entries (I guess) for EBGaramond08-Italic.otf, EBGaramond08-Regular.otf, EBGaramond12-Italic.otf, EBGaramond12-Regular.otf. And when I select the "08 Italic" button, I'm told that the current font is "EB Garamond 08 Italic".
I get something similar, when I click on "EB Garamond SC":

The entries "08 Regular" and "12 Regular" probably represent EBGaramondSC08-Regular.otf and EBGaramondSC12-Regular.otf.
As a note, say LibreOffice Writes does not group these fonts, but each has a separate entry:

Anyways, to repeat my question in other terms now: is there a way for setting up a \newfontfamily, say \titlenamefont, in fontspec, such that:

*

*When {\titlenamefont \Huge{MYTEXT}} is used, the font rendered is "EB Garamond 12 Regular"

*When {\titlenamefont \Huge\bfseries{MYTEXT}} is used, the font rendered is "EB Garamond 08 Regular" (without generating warnings in latex log about nonexisting bold face)

*When {\titlenamefont \Huge\bfseries{\textsc{MYTEXT}}} is used, the font rendered is a) either "EB Garamond 08 Regular" with Letters=SmallCaps option; or b) "EB Garamond SC 08 Regular"

*When {\titlenamefont \Huge{\textsc{MYTEXT}}} is used (so without bold), the font rendered is a) either "EB Garamond 12 Regular" with Letters=SmallCaps option; or b) "EB Garamond SC 12 Regular"

(Side question: in the above MWE, why does SmallCapsFeatures={Letters=SmallCaps} not generate any small caps with \textsc, and just {Letters=SmallCaps} does?)

A: There's a free version of the EB Garamond family on GitHub that comes in different weights.  It's based on EB Garamond 12, though, not 8.  You can download regular, bold, italic and bold italic into your project directory or a subdirectory. Just Loading EB Garamond with the Path option to this subdirectory should work.
Then, create your font family using the Path, Scale, BoldFont, and BoldItalicFont options to \newfontfamily. For example, [Scale = MatchUppercase, Ligatures = {Common, TeX}, BoldFont = EBGaramond08-bold.otf, BoldItalicFont = EBGaramond08-BoldItalic.otf] (If you have such fonts.)  Use Scale=MatchUppercase to make the heights match, then whatever Ligatures, Numbers and other options you want.  You might also need BoldFeatures and BoldItalicFeatures. If you're loading the specific font files you downloaded into a directory yourself, you probably want to load them by filename with Extension = .otf.
If your copy of the bold font is recent, it should contain small caps already, and they should just work. If you need to load a separate font, you might need to set the BoldFeatures = { SmallCapsFont = ... } option as well.
There is a free version of a Garamond No8 with small caps at Arkandis.


text:
Q: Disable Scroll with dynamic content when its not necessary I have a page with a section of tabs in which each one of these tabs has more or less content and when I open a tab with a lot of content and then I go to a tab with less content the page keeps allowing scroll (even it the page is empty), I've just found answers about when the content grows up but nothing about when it shrinks out.
What I want to achieve is to be able to scroll when there is a lot of content on the screen and use just the view height when there is little content on the screen.
This is the basic scheme of the page
HTML:

css:
body {
  margin: 0;
  padding: 0;
  height:100%
}

.wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.content {
  flex: 1;
}
.footer{
  position:relative;
  bottom:0;
}

This is how it looks when I open a lot of content and then a little:

A: add max-width: 100vw; to your overflowing element replace 100vw with ur value


text:
Q: list of attributes associated with every element of text file I have a text file :
Name     Attribute
A         b1
B         b2
C         b3
B         b4
A         b5
C         b7

I want the output to be
Name    Attribute
A       (b1,b5)
B       (b2,b4)
C       (b3,b7)

Any python/pandas suggestions for this?

A: try this:
In [301]: df.groupby('Name')['Attribute'].apply(lambda x: tuple(x.tolist())).reset_index()
Out[301]:
  Name Attribute
0    A  (b1, b5)
1    B  (b2, b4)
2    C  (b3, b7)

A: Try this, No lambda:
df.groupby('Name')['Attribute'].apply(tuple).reset_index()

A: This is why dictionaries were made:
myfile = open('yourfile.txt','r').readlines()
mydict = {}
for line in myfile[1:]:
    data = line.split()
    if data[0] in mydict:
        mydict[data[0]].append(data[1])
    else:
        mydict[data[0]] = [data[1]]


text:
Q: Classic Login to new headless Mac with Apple Remote Desktop? I vaguely remember a trick from years ago that I'd find useful now.  I'm wondering if anyone remembers the details.  (I'm assuming this is no longer possible so no longer a "can this be done now" question.)
I have a new 2018 Mac Mini to configure as a headless server.  The typical way to do this is to attach a keyboard/mouse/monitor, then configure Remote Management, then disconnect the keyboard/mouse/monitor and reboot.
I'm reasonably certain there was once a method to configure a new (unconfigured) headless Mac 100% remotely.  I think you'd boot it on a LAN, find the DHCP-assigned IP address, then connect with Apple Remote Desktop.  There would be a default user/password for a virgin Mac, using the last six or eight digits of the MAC address.  At least that's how I remember it.
Does anyone remember the details?  It's even possible this is pre-OS X...
It's been suggested this question is a duplicate of How to setup a Mac (Mini 2015) without a monitor (or mouse or keyboard)?.  That question may verify that the method I remember either no longer works.  The question is more of a historical one, if anyone remembers this from years past.
[Update]: I found my manual of Apple Remote Desktop 2.0, from 2004 (Mac OS X 10.2.8).  It makes no reference to any of this.  I still think what I remember was a thing, but may have been from Classic MacOS days.  So I've added the classic-mac-os tag to clarify, and removed references to this being a current OS question.


text:
Q: openldap data files, what do they look like from my slapd.conf file, i see where my data is stored. when I look into that data directory i see two kinds of files, one type are .bdb files which appear to be the data files as that is the extension defined in the config file. But, I also have a bunch of log files, which appear to be binary when I try to read them in vi. I'm not sure if they are supposed to be there or if this is an oversight by someone previous to me. If I want to restore from an .ldif file, am I loosing anything by deleting all the log files? do I just need to delete the bdb files?

A: They are Berkeley DB files.
On Ubuntu 10.04, for example, you can install the db4.7-util package and get some information using the various db4.7_* utils (e.g. db4.7_dump or db4.7_stat). This being said, the structure of the database really depends on how OpenLDAP is coded (it's an internal format, so it's not particularly useful unless you really want to dig into it).
If you want to restore from an LDIF file, use LDAP clients or OpenLDAP commands such as ldapadd.


text:
Q: how to implement pagination based on upper and lower limit on recyclerview I'm working with recycler view and i am working on social module like facebook and want to implement Pagination on recycler view This is my method defination
** public void getUserSharedTimeline(int userId, int lowerLimit,int upperLimit )**
Now first time I send 0 to 10 to server and get ten records. and then I call it like this.

 mRecyclerView.addOnScrollListener(new EndlessScrollListener(mLayoutManager) {
            @Override
            public void onLoadMore(int page, int totalItemsCount) {
                getUserSharedTimeline(Utilities.UserTypeId,totalItemsCount,totalItemsCount+10);
            }
        });

On first call

*

*it works and get me 10 to 20 records

*Then on second call it gets 20 to 21 records

*and after that it's stop scrolling and do not load more data even records are more than thousand.

*The pagination is also done on server side and I can't request more than 10 records at a time.

Here is my class for pagination. I checked many tutorials but in vain. Please help  me in this issue.

package com.intelmanager.ithash.intelmanager.ui;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.widget.AbsListView;

public abstract class EndlessScrollListener extends RecyclerView.OnScrollListener {
    // The minimum amount of items to have below your current scroll position
    // before loading more.
    private int visibleThreshold = 10;
    // The current offset index of data you have loaded
    private int currentPage = 0;
    // The total number of items in the dataset after the last load
    private int previousTotalItemCount = 0;
    // True if we are still waiting for the last set of data to load.
    private boolean loading = true;
    // Sets the starting page index
    private int startingPageIndex = 0;

    RecyclerView.LayoutManager mLayoutManager;

    public EndlessScrollListener(RecyclerView.LayoutManager layoutManager) {
        this.mLayoutManager = layoutManager;
    }

    public EndlessScrollListener(GridLayoutManager layoutManager) {
        this.mLayoutManager = layoutManager;
        visibleThreshold = visibleThreshold * layoutManager.getSpanCount();
    }

    public EndlessScrollListener(StaggeredGridLayoutManager layoutManager) {
        this.mLayoutManager = layoutManager;
        visibleThreshold = visibleThreshold * layoutManager.getSpanCount();
    }

    public int getLastVisibleItem(int[] lastVisibleItemPositions) {
        int maxSize = 0;
        for (int i = 0; i < lastVisibleItemPositions.length; i++) {
            if (i == 0) {
                maxSize = lastVisibleItemPositions[i];
            }
            else if (lastVisibleItemPositions[i] > maxSize) {
                maxSize = lastVisibleItemPositions[i];
            }
        }
        return maxSize;
    }

    // This happens many times a second during a scroll, so be wary of the code you place here.
    // We are given a few useful parameters to help us work out if we need to load some more data,
    // but first we check if we are waiting for the previous load to finish.
    @Override
    public void onScrolled(RecyclerView view, int dx, int dy) {
        int lastVisibleItemPosition = 0;
        int totalItemCount = mLayoutManager.getItemCount();

        if (mLayoutManager instanceof StaggeredGridLayoutManager) {
            int[] lastVisibleItemPositions = ((StaggeredGridLayoutManager) mLayoutManager).findLastVisibleItemPositions(null);
            // get maximum element within the list
            lastVisibleItemPosition = getLastVisibleItem(lastVisibleItemPositions);
        } else if (mLayoutManager instanceof LinearLayoutManager) {
            lastVisibleItemPosition = ((LinearLayoutManager) mLayoutManager).findLastVisibleItemPosition();
        } else if (mLayoutManager instanceof GridLayoutManager) {
            lastVisibleItemPosition = ((GridLayoutManager) mLayoutManager).findLastVisibleItemPosition();
        }

        // If the total item count is zero and the previous isn't, assume the
        // list is invalidated and should be reset back to initial state
        if (totalItemCount < previousTotalItemCount) {
            this.currentPage = this.startingPageIndex;
            this.previousTotalItemCount = totalItemCount;
            if (totalItemCount == 0) {
                this.loading = true;
            }
        }
        // If it's still loading, we check to see if the dataset count has
        // changed, if so we conclude it has finished loading and update the current page
        // number and total item count.
        if (loading && (totalItemCount > previousTotalItemCount)) {
            loading = false;
            previousTotalItemCount = totalItemCount;
        }

        // If it isn't currently loading, we check to see if we have breached
        // the visibleThreshold and need to reload more data.
        // If we do need to reload some more data, we execute onLoadMore to fetch the data.
        // threshold should reflect how many total columns there are too
        if (!loading && (lastVisibleItemPosition + visibleThreshold) > totalItemCount) {
            currentPage++;
            onLoadMore(currentPage, totalItemCount);
            loading = true;
        }
    }

    // Defines the process for actually loading more data based on page
    public abstract void onLoadMore(int page, int totalItemsCount);

}


text:
Q: how can I disable home button in android.I am writing an screen lock app but cannot disable the home button I am writing a screen lock app for android.Overriding back button , power button is fine.
But it seems that we cannot disable home button.
Is there any way out to disable home button?


text:
Q: What OverrideAuthenticationAttribute is for? I've came across a controller method marked with System.Web.Http.OverrideAuthenticationAttribute in my current Web API project and I'm curious what this is for?
Searching in Google and Stackoverflow doesn't answer the question. MSDN documentation doesn't contain much information. It only says the following:

Represents a filter attribute that overrides authentication filters
  defined at a higher level.

Also, I've taken a look into the sources:
public sealed class OverrideAuthenticationAttribute : Attribute, IOverrideFilter, IFilter
{
    public bool AllowMultiple
    {
        get
        {
            return false;
        }
    }

    public Type FiltersToOverride
    {
        get
        {
            return typeof(IAuthenticationFilter);
        }
    }
}

But this doesn't shed much light.
So could anybody explain what is the purpose of using the OverrideAuthenticationAttribute? And please give some use cases of it for better understanding.

A: OverrideAuthentication is for overriding the authentication filters configured at higher levels. Say, you have an authentication filter applied globally like this.
// Applied globally in WebApiConfig
config.Filters.Add(new MyAuthenticationFilter());

And, you want to stop this filter from running for a specific action method or a controller. You can use OverrideAuthentication at that level, like this.
public class ValuesController : ApiController
{
    [OverrideAuthentication]
    public string Get()
    { ...  }
}

Now, in the above example, you have MyAuthenticationFilter applied globally. Say, you want to override that and run another filter, say MyAnotherAuthenticationFilter only for the Post action method. You can do something like this.
public class ValuesController : ApiController
{
    // Removes all filters applied globally or at the controller level
    [OverrideAuthentication]
    [MyAnotherAuthentication] // Puts back only MyAnotherAuthenticationFilter
    public string Post(...)
    { ... }
}

More info here. Check out the "Filter Overrides" section.

A: The OverrideAuthentication attribute is used to suppress global authentication filters, which means that all global Authentication filters (implementing IAuthenticationFilter) will be disabled when using this filter.
Let's say you have a global authentication filter called BasicAuth:
public class BasicAuthAttribute : ActionFilterAttribute, IAuthenticationFilter
{
    public void OnAuthentication(AuthenticationContext filterContext)
    { }

    public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
    {
        var user = filterContext.HttpContext.User;
        if (user == null || !user.Identity.IsAuthenticated)
        {
            filterContext.Result = new HttpUnauthorizedResult();
        }
    }
}

And the filter is configured as a Global filter for all controllers with this code:
public class FilterConfig
{
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
        filters.Add(new BasicAuthAttribute());
    }
}

Let's say you want to use a different authentication strategy on a single controller or controller action. In that case you could disable the global auth. filters using the OverrideAuthentication attribute, and then configure a new filter you want to use for that specific action. This is helpful when you are integrating with external login providers, and you don't want any existing Global auth filters to mess up your external login authentication.
In the code below the global authentication filters are disabled, and then the HostAuthentication filter is enabled for a single action to enable external login providers (e.g. Facebook):
// GET api/Account/ExternalLogin
[OverrideAuthentication]
[HostAuthentication(Startup.ExternalCookieAuthenticationType)]
[AllowAnonymous]
[HttpGet("ExternalLogin", RouteName = "ExternalLogin")]
public async Task<IHttpActionResult> ExternalLogin(string provider)
{
    // Auth code
}


text:
Q: Bottom border for StackPanel How do I make the StackPanel have a Bottom Border and a thickness of 1?
I've tried it a few ways, one of them is below but nothing I've tried works (including some of the answers I found on SO):
    <Border BorderBrush="#FF1986D1" BorderThickness="1" VerticalAlignment="Bottom">
        <StackPanel Background="#FFC6E1EE" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="13">

        </StackPanel>
    </Border>

A: I figured it out:
<Window x:Class=".MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="" Height="558" Width="328">
    <Grid>
        <Border BorderBrush="#FF1986D1" BorderThickness="0 0 0 1" VerticalAlignment="Top">
            <StackPanel Background="#FFC6E1EE" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="113">

            </StackPanel>
        </Border>
    </Grid>
</Window>


text:
Q: Angularjs: How to access specific item in ng-repeat I have a custom directive that consists of a list of buttons dynamically created through ng-repeat as follows:
HTML

        <button class="btn" ng-bind="btn.name" ng-click="click(btn)" ng-class="getClass(btn, toggleButton.selected)"></button>

CONTROLLER
 var app = angular.module('toggleButtonMod', [])
 app.directive('toggleButton', function() {
 return {
     restrict: 'E',
     scope: {
         setting: '='
     },
     templateUrl: "app/Shared/togglebutton/toggleButtonView.html"
 }
})
app.controller("toggleButtonController", function($scope) {
 $scope.init = function() {
     $scope.setupContent();
 }
 $scope.setupContent = function() {
     $scope.toggleButton = {selected: null};
 }
 $scope.click = function(btn) {
    $scope.toggleButton.selected = btn;
 }
 $scope.getClass = function(btn, toggleSelected){
    if(btn === toggleSelected){
        return 'btn-primary';
    }else{
        return 'btn-default';
    }
 }

})

The scenario here is to create a service or any other better implementations to change the ng-class of a specific button in the ng-repeat.
For example:
app.service('selectDefault', function(index) {
   //set button #2 to have ng-class="btn-primary"
}

A: I'm not definitely sure if this is what you're looking for. But this snippet will show how to add class on the fly in ng-repeat using a service. Hope it helps!
https://jsfiddle.net/cgdmqt8o/

A: Just change your ng-class to:
ng-class="{'btn-primary':(btn === toggleSelected), 'btn-default':(btn != toggleSelected)}"

That is assuming the variable toggleSelected is set somewhere in your code, although I don't see it being set in the above sample.


text:
Q: Calculation of magnetic field saturation inside coil core I want to try to make an electromagnet, but I don't have soft-iron available. I've read that ferrite MnZn are suitable as soft-iron to create a high efficiency magnets with the inconvenient of lower magnetic saturation.
I'd like to know If with my specifics I can occur in this saturation range. Magnet will be activated with a frequency of 10 kHz to control and keep current at 1A-1.5A. About 50 turns are applied. Dimensions of core are 10mm diameter and length 30mm Ferrite type is an MnZn. Relative permeability from datasheet 15000µ/µ₀ at 10kHz, permeability µ₀ 0.3*10-3 H/m at 10kHz.
Applying this equation: B = µ₀ * N * I / L
I've

*

*µ₀ 0.3*10-3 H/m

*N 50

*I 1.5A

*L 0.030m

B = 0.6 * 10-4
Can be this value be so low and can I be so far from saturation? Even if I apply 10A I'm very far from saturation. This mean that saturation is something that occur in very particular applications where high current, lengths and number of turn are involved?

A: Apart from the fact that you are probably misusing the length dimension of the ferrite, you are also miscalculating flux density quite badly (See further below).
The length dimension for a ferrite core is the closed loop length that the magnetic field travels along and, for an electromagnet, it has to include the air gap. Any small amount of air gap will reduce the effective pemeability of the core to a value closer to air. You need to calculate the effective permeability and not use the initial permeability stated in the material data sheets.

Values

*

*\$μ_0 = 4π × 10−7\$ H/m

*\$μ_0\cdot μ_R = 0.01885\$ H/m

*\$H = \dfrac{NI}{\text{length}} = \$50 turns x 1 amp / 0.03 metres = 1667 amp_turns per metre

Therefore B = 31.4 teslas.

Can be this value be so low and can I be so far from saturation?

No, you've made a math error somewhere.


text:
Q: C String parsing It's a relatively simple thing to do, but I've been having problems separating a string from a file into multiple variables. I've tried strtok and sscanf with delimiters, but I seem to be doing something wrong.
#define MAX 40
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    char brd_str[26];
    char board[26], Res[26], Ind[26], Cap[26];
    int i=0, n=0;
    FILE *data;

    data = fopen ("C:\\datafile.txt", "rt");
    fgets(brd_str, 26, data);
    sscanf(brd_str,"%d[^,],%f[^,],%e[^,],%e[^,]", &board, &Res, &Ind, &Cap);
    printf("%3d %6d %8e %8e", board, Res, Ind, Cap);

    fclose(data);
    printf("\nPlease enter something for the program to exit");
    scanf("%d", &i);
    return(0);
}

The string itself looks like this 2,4.57,2.01e-2,5.00e-8. The comma would be the delimiter in this case. When I compile it I have really large numbers which are incorrect.
This would have to be done multiple times (up to 40), and the variables themselves will be used for calculations.
There seems to be something wrong with the sscanf statement I've put in. I'm not really sure what the problem is.

A: Basically, your most immediate problem is
char board[26], Res[26], Ind[26], Cap[26];

So, you have strings ...
sscanf(brd_str,"%d[^,],%f[^,],%e[^,],%e[^,]", &board, &Res, &Ind, &Cap);

you can't read with "%e" into (addresses of) strings!
printf("%3d %6d %8e %8e", board, Res, Ind, Cap);

you can't print strings with "%e"

Also there are quite a few more problems with your code.

A: Change:
    char board[26], Res[26], Ind[26], Cap[26];

to:
   int board;
   float Res;
   float Ind;
   float Cap;

And, change:
printf("%3d %6d %8e %8e", board, Res, Ind, Cap);

to (perhaps):
printf("%3d %6f %8e %8e", board, Res, Ind, Cap);

A: Just for a hint at coding style, take a look at the following code...
#include <stdio.h>
#include <stdlib.h>

int main( int argc, char **argv )
{
FILE *file;
int c, cp;
char *buf = (char*)malloc( sizeof( char ) * 100 );

for (c = 0; c < 100; c++ )
{
    buf[c] = 0;
}

file = fopen( "input.txt", "r" );

cp = 0;
while( ( c = fgetc( file ) ) != EOF )
{
    if ( c != ',' )
    {
        buf[cp] = (int)c;
        cp++;
    }
    printf( "%c", c );
}

for (c = 0; c < 100; c++ )
{
    printf( "Buf%d: %c\n", c, buf[c] );
}

free( buf );

return 0;
}

This code loads characters in from file.  If you are wanting strings, consider simply that strings are arrays of characters... There are quite a few examples online you can look at including the following...
Read .CSV file in C
I hope this helps...

A: You may not combine a scanset format-specifier with other types of format-specifiers like that. Just like you may not have "%df" as a format-specifier for integer float (???), or "%si" for string integer (???), you may not have things like "%d[^,]".
"%d" alone would already abort reading when it encounters a ',' or any other non-digit character, so what you are trying to do there is extra and invalid precaution. Having that "[^,]" next to it, will cause sscanf to look for a '[' then '^' then ',' then ']' inside that string.
So, in short, you should rather be having something rather simple like the following:
#include<stdio.h>

int main( ){

    int board;
    float Res, Ind, Cap;

    scanf( "%d,%f,%e,%e", &board, &Res, &Ind, &Cap );
    // reads digit sequence until the non-digit input
    // reads that number into board as an integer
    // consumes a comma character
    // and so on...

    printf( "%d\n%f\n%e\n%e", board, Res, Ind, Cap );

    return 0;
}

A: Addressing only:
...I've tried strtok ... but I seem to be doing something wrong....
And
This would have to be done multiple times (up to 40)
It sounds like you have an input file with a variable number of inputs, up to 40?
So the way the data is read should accommodate, and stop reading at end of data.
Here is an example doing these things using strtok():
With a file containing these values:
1.2,345,23,78,234,21.4567,2.45566,23,45,78,12,34,5.678

I also verified it works with exponential notation, such as:
1.2,345,23,7.8e3,2.34e-2,21.4567,2.45e-8,2.3e3,45,78,12,34,5.678

And using this code, strtok will parse through using ", \n" as delimiters:
#include <ansi_c.h>

int main(void)
{
    FILE *fp;
    char *tok;
    double numbers[100];
    char tempBuf[260], lineBuf[260];
    int i=0;

    memset(numbers, 0, sizeof(numbers)/sizeof(numbers[0])*sizeof(int));
    fp = fopen("F:\\play3\\numbers.txt", "r");
    while(fgets (lineBuf, sizeof(lineBuf), fp))
    {
        tok = strtok(lineBuf, ", \n");
        while(tok)
        {
            strcpy(tempBuf, tok);
            if(strlen(tempBuf)>0)
            {
                numbers[i++] = strtod(tempBuf, NULL);
            }
            tok = strtok(NULL, ", \n");

        }
    }
    fclose(fp);
    return 0;
}

With the following results:


text:
Q: Horizontal line appears under posts that have deleted comments It appears that a recent update has introduced a design flaw: on posts that have had comments that have all been deleted, a gray horizontal line appears above the "add comment" button a few seconds after it loads. Here's an example post:

But on this post, which (to my knowledge) has never had any comments posted on it before, not even deleted ones, doesn't show such a horizontal line.
While it probably is a good idea to indicate publicly that comments have been posted on the post, but have all been deleted, I think this line is probably an unintentional design bug. Also, in my opinion, any such intentional indicator should be much more conspicuous.
Reproduced under both Internet Explorer 11 and Chrome on Windows 8.1.
Update: This appears to happen only when following a link to a deleted comment, not when following a link to the post itself. When following a link to a deleted comment on a post that has had all its comments removed, the line is visible; otherwise, when following a link to the post itself, it's not. The line appears a few seconds after the post has loaded.


text:
Q: When does git lose changes during a merge? Let's say that:

*

*We have a master branch where a coworker accidentally added a series of commits (let's call them A B C) that should have belonged to a new feature.

*I discover that, and I tell him to move those commits to a new branch, but keeping other unrelated commits that were done later in master. I send him this question I asked and tell him to follow the response: git: how to move a branch's root two commits back

*Days later, when the new feature branch is ready, I merge it into master.

*After solving all the conflicts in the merge, I commit the changes...

*...and I discover that those first commits (the A B C ones) have disappeared.

*I ask my coworker, and he says that "he thinks" that he moved those changes using the method mentioned in the link (basically: checking out the last common commit and then using git cherry-pick to pick only the commits that we wanted later), but he can't remember exactly.

*I check the repo's history, and A B C are in the feature branch, at the beginning. They look like they were successfully migrated from master.

Given the above, can anyone explain why git lost those changes? (My personal theory is that git somehow "remembered" that we had undone commits A B C, so when they came from the new feature branch, git decided not to merge them. EDIT: sorry if this explanation sounds too much like "magical thinking", but I'm at a loss. I welcome any attempt to put this explanation in more technical terms, if it's right).
Sorry for not being able to give more details, but I didn't make those changes in the repo personally, so can't give exact details of what was done.
EDIT: okay, as suggested here, I got my coworker to execute git reflog in his machine, so I am pasting here the results. To get back to my previous (linked) question, we had a tree like this:
A - B - C - D - E - F  master
            \
             \- G - H  new feature branch

And we wanted to move B and C to the new feature branch.
So, the git reflog he sent me is here. Commit 5acb457 would correspond to "commit A" in the graph above:
4629c88 HEAD@{59}: commit: blah
f93f3d3 HEAD@{60}: commit: blah
57b0ea7 HEAD@{61}: checkout: moving from master to feature_branch
4b39fbf HEAD@{62}: commit: Added bugfix F again
4fa21f2 HEAD@{63}: commit: undid checkouts that were in the wrong branch
1c8b2f9 HEAD@{64}: reset: moving to origin/master
5acb457 HEAD@{65}: checkout: moving from 5acb4576eca4b44e0a7574eea19cca067c039dc5 to master
5acb457 HEAD@{66}: checkout: moving from master to 5acb4576eca4b44e0a7574eea19cca067c039dc5
1c8b2f9 HEAD@{67}: checkout: moving from 1c8b2f9bf54ca1d80472c08f3ce7d9028a757985 to master
1c8b2f9 HEAD@{68}: rebase: checkout master
5acb457 HEAD@{69}: checkout: moving from master to 5acb4576eca4b44e0a7574eea19cca067c039dc5
1c8b2f9 HEAD@{70}: checkout: moving from 5acb4576eca4b44e0a7574eea19cca067c039dc5 to master
5acb457 HEAD@{71}: checkout: moving from master to 5acb4576eca4b44e0a7574eea19cca067c039dc5
1c8b2f9 HEAD@{72}: merge origin/master: Fast-forward
5acb457 HEAD@{73}: checkout: moving from master to master
5acb457 HEAD@{74}: checkout: moving from 5acb4576eca4b44e0a7574eea19cca067c039dc5 to master
5acb457 HEAD@{75}: checkout: moving from undo_branch to 5acb4576eca4b44e0a7574eea19cca067c039dc5
5acb457 HEAD@{76}: checkout: moving from master to undo_branch
1c8b2f9 HEAD@{77}: checkout: moving from undo_branch to master
525dbce HEAD@{78}: cherry-pick: Bugfix F
a1a5028 HEAD@{79}: cherry-pick: Bugfix E
32f8968 HEAD@{80}: cherry-pick: Feature C
8b003cb HEAD@{81}: cherry-pick: Feature B
5acb457 HEAD@{82}: checkout: moving from 5acb4576eca4b44e0a7574eea19cca067c039dc5 to undo_branch
5acb457 HEAD@{83}: checkout: moving from master to 5acb4576eca4b44e0a7574eea19cca067c039dc5
1c8b2f9 HEAD@{84}: checkout: moving from 1c8b2f9bf54ca1d80472c08f3ce7d9028a757985 to master
1c8b2f9 HEAD@{85}: pull origin HEAD:master: Fast-forward
5acb457 HEAD@{86}: checkout: moving from master to 5acb4576eca4b44e0a7574eea19cca067c039dc5
5acb457 HEAD@{87}: reset: moving to 5acb4576eca4b44e0a7574eea19cca067c039dc5
1c8b2f9 HEAD@{88}: merge origin/master: Fast-forward
5acb457 HEAD@{89}: reset: moving to 5acb4576eca4b44e0a7574eea19cca067c039dc5
1c8b2f9 HEAD@{90}: checkout: moving from 5acb4576eca4b44e0a7574eea19cca067c039dc5 to master
5acb457 HEAD@{91}: checkout: moving from master to 5acb4576eca4b44e0a7574eea19cca067c039dc5
1c8b2f9 HEAD@{92}: merge origin/master: Merge made by the 'recursive' strategy.
7b912cd HEAD@{93}: checkout: moving from 7b912cdf33843d28dd4a7b28b37b5edbe11cf3b9 to master
7b912cd HEAD@{94}: cherry-pick: Bugfix F
df7a9cd HEAD@{95}: cherry-pick: Bugfix E
d4d0e41 HEAD@{96}: cherry-pick: Feature C
701c8cc HEAD@{97}: cherry-pick: Feature B
5acb457 HEAD@{98}: checkout: moving from master to 5acb4576eca4b44e0a7574eea19cca067c039dc5
22ecc3a HEAD@{99}: checkout: moving from 5acb4576eca4b44e0a7574eea19cca067c039dc5 to master
5acb457 HEAD@{100}: checkout: moving from master to 5acb4576eca4b44e0a7574eea19cca067c039dc5
22ecc3a HEAD@{101}: commit: bugfix E
3b568bc HEAD@{102}: checkout: moving from feature_branch to master
57b0ea7 HEAD@{103}: commit: blah
152c5b9 HEAD@{104}: checkout: moving from master to feature_branch
3b568bc HEAD@{105}: commit: bugfix D
fe3bbce HEAD@{106}: checkout: moving from feature_branch to master
152c5b9 HEAD@{107}: commit: blah
2318ebc HEAD@{108}: commit: blah
cc5ea32 HEAD@{109}: commit: blah
a5c2303 HEAD@{110}: commit: blah
544a99a HEAD@{111}: commit: blah
299f86a HEAD@{112}: commit: Feature G
fe3bbce HEAD@{113}: checkout: moving from master to feature_branch
fe3bbce HEAD@{114}: commit: Feature C
3852e71 HEAD@{115}: commit: Feature B
5acb457 HEAD@{116}: merge origin/master: Fast-forward

Can anyone make any sense of those 4 cherry-picks in a row? I suspect that he didn't really do the git cherry-pick master~3 thing, specially not the ~3 part (which admittedly threw me off when I first saw it too).

A: The reason why commits A, B and C are lost, that is because this is what the link you shared to your coworker did. Let illustrate by below graphs:
1. Assume the original commit history your coworker did as,
...X---A---B---C---D---E  master

2. Move A, B and C to feature branch. So your coworker created a new feature branch from master (commit E) or any of a commit. And rebase with below steps:
git checkout -b feature
git cherry-pick master~5 master~2

...X---A---B---C---D---E  master
                        \
                         A'---B'---C' feature

3. Modify master branch by,
git checkout X
git cherry-pick master~2..master
git branch -f master
git checkout master

the commit structure will look like:
...X---D---E  master
     \
       A'---B'---C' feature

So the direct reason is the command git cherry-pick master~2..master. It will rebase commit D and E directly on commit X, so you can't find A, B and C on master branch.
Update:
Based on the git flog, it seems these HEAD information is not enough to show what your coworker did. And the feature branch seems to checkout from commit C not D by
3b568bc HEAD@{105}: commit: bugfix D
fe3bbce HEAD@{106}: checkout: moving from feature_branch to master
152c5b9 HEAD@{107}: commit: blah
2318ebc HEAD@{108}: commit: blah
cc5ea32 HEAD@{109}: commit: blah
a5c2303 HEAD@{110}: commit: blah
544a99a HEAD@{111}: commit: blah
299f86a HEAD@{112}: commit: Feature G
fe3bbce HEAD@{113}: checkout: moving from master to feature_branch
fe3bbce HEAD@{114}: commit: Feature C

So the structure should be:
A---B---C---D---E  master
         \
          G---H feature

If you only want to change the commit structure like:
A ---D---E  master
 \
  B---C---G---H feature

You can reset your master branch and feature branch as original, and then cherry-pick commits on master branch, details as:
git checkout master
git reset --hard <original commit id for E>
git checkout feature
git reset --hard  <original commit id for H>
git checkout master
git checkout <commit id for A>
git cherry-pick master~4..master~2 #To make the commits as A---D---E (drop B and C)
git branch -f master
git checkout master

A: Let's concentrate on the merge result, but start with a quick skim over this part (I've redrawn the graph a bit):

To get back to my previous (linked) question, we had a tree like this:
A--B--C--D--E--F   <-- master
          \
           G--H   <-- feature

And we wanted to move B and C to the new feature branch.

The result should have looked like this (with the tick-marks indicating that the commits you have now are copies, not the originals, so their hash IDs have changed, so everyone who got the originals has to scramble to make sure they use the new copies too).  But I'll just assume that it did in fact look like this:
A--D'-E'-F'   <-- master
    \
     B'-C'-G'-H'   <-- feature

(note that the only commit not copied-and-switched-to is A!).
When you now run:
git checkout master
git merge feature

Git will do these things in this order:

*

*Get the hash ID of the current commit (git rev-parse HEAD).

*Get the hash ID of the tip of feature (git rev-parse feature).

*Locate the (single, in this case) merge base of those two commits.  The technical definition of the merge base is the Lowest Common Ancestor in the DAG, but loosely speaking, it's just before the two branches diverge, which is simply "commit D'".

*Run what amounts to git diff D' F': diff the merge base with the tip of master.  This is "what we changed on master since the merge base": a big list of files (and their hash ID versions), along with any computed rename information and the like.

*Run what amounts to git diff D' H': diff the merge base with the tip of feature.  This is "what they changed on feature", in the same way as in step 4.  I use the word "we" for step 4, and "they" here in step 5, because we can use git checkout --ours and git checkout --theirs to extract particular files during a merge conflict: --ours refers to files in commit F', i.e., what "we" changed, and --theirs refers to files in commit H'.

*Attempt to combine the differences to get a single changeset.
If Git is able to do all this combining on its own, it declares victory, applies this single changeset to the base commit D', and makes a new commit—let's call this M for merge—in the usual way (so that master moves to point to M), except that M has two parents:
A--D'-E'-F'-----M   <-- master
    \          /
     B'-C'-G'-H'   <-- feature

If the automatic merge fails, however, Git throws up its metaphorical hands and leaves you a mess that you must clean up yourself.  We'll go into this in a moment.
Three inputs, one output
Note that there are three inputs to this three-way merge:

*

*the tree for the merge base

*the tree for the current (--ours, HEAD) tip commit

*the tree for the other (--theirs) tip commit

The merge base works here because it is a—in fact, the best—common starting point from which the two commits have diverged.  Git is able to go straight for the two branch tips because each commit is a complete snapshot:1 it never has to look at all the intermediate commits, except in terms of the graph so as to find the merge base.
We're also deliberately glossing over a bunch of subtle technical issues, such as pair-breaking and rename-finding (see footnote 1), and things like merge strategies (-s ours means we don't even look at theirs) and strategy options (-X ours or -X theirs).  But as long as you are just running git merge feature and there are few or no renames to worry about, that's not a problem.
But—this is one of the key items—in order to figure out what Git is going to do, you must draw the graph, or otherwise identify the merge base.  Once you have the hash ID for the merge base commit, you can (if you want to) git diff the merge base against the two tip commits and see what Git will do.  But if the merge base is not the commit you are expecting it to be, the merge will not do what you expect it to do.

1Compare with Mercurial, where each commit is stored, more or less, as a delta or changeset from its parent commit.  You might think, then, that Mercurial must start at the merge base and march forward through each commit along each branch chain.  But there are two things to note here: first, Mercurial may well have to start before the merge base, because that too could be a changeset from an earlier commit.  Second, suppose that along the chain to either tip, some change is made, then backed out.  When Mercurial goes to combine the final changesets to implement the same merge as Git, the commit and its backing-out reversion have no effect on the final result.  So in that sense, none of the intermediate commits matter after all!  We need them only to reconstruct the two final changesets that are to be combined.
In fact, though, Mercurial doesn't do any of this, because each file in Mercurial is occasionally stored anew, fully intact, so that Mercurial won't have to follow extremely long changeset chains to reconstruct a file.  Hence what Mercurial does is effectively the same as what Git does: it just extracts the base commit, and then extracts the two tip commits, and does the two diffs.
There's one big technical difference here, which is that Mercurial does not have to guess about renames: the intermediate commits, which—again just like Git—it must traverse to find the merge base, each record any renames with respect to their parent commit, so Mercurial can be certain what the original name of each file was, and what its new name in either tip may be.  Git does not record renames: it simply guesses that if path dir/file.txt appears in the merge base, but not in one or both tip commits, perhaps dir/file.txt was renamed in one or both tip commits.  If tip commit #1 has other/new.txt that is not in the merge base, that's a candidate file for a rename.
In some cases, Git can't find renames this way.  There are additional control knobs.  There is one to break pairings if files have changed "too much", i.e., to have Git say that just because dir/file.txt is in both base and tip, that it may not actually be the same file.  There is another to set the threshold at which Git declares a file to match, for rename-detection purposes.  Last, there is a maximum pairing queue size, configurable as diff.renameLimit and merge.renameLimit.  The default merge pairing queue size is larger than the default diff pairing queue size (currently 400 vs 1000, ever since Git version 1.7.5).

The mess you get if there are conflicts
When Git declares a "merge conflict" it stops in the middle of step 6.  It does not make new merge commit M.  Instead, it leaves you a mess, stored in two places:

*

*The work-tree has its best guess at what it could do as an automated merge, plus all the conflicting merges written out with conflict markers.  If file.txt has a conflict—a place where Git was unable to merge "what we did" with "what they did"—it might have a few lines that look like this:
<<<<<<< HEAD
stuff from the HEAD commit
=======
stuff from the other commit (H' in our case)
>>>>>>> feature

If you set merge.conflictStyle to diff3 (I recommend this setting; see also Should diff3 be default conflictstyle on git?), the above is modified to include what's in the merge base (commit D' in our case), i.e., what text was there before both "we" and "they" changed it:
<<<<<<< HEAD
stuff from the HEAD commit
||||||| merged common ancestors
this is what was there before the two
changes in our HEAD commit and our other commit
=======
stuff from the other commit (H' in our case)
>>>>>>> feature

*Meanwhile, the index—the place where you build the next commit to make—has up to three entries per "slot" for each conflicted file.  In this case, for file.txt, there are three versions of file.txt, which are numbered:

*

*:1:file.txt: this is a copy of file.txt as it appears in the merge base.

*:2:file.txt: this is a copy of file.txt as it appears in our (HEAD) commit.

*:3:file.txt: this is a copy of file.txt as it appears in their (tip of feature) commit.

Now, just because there is a conflict in file.txt does not mean there were not some other changes that Git was able to resolve on its own.  Suppose, for instance, that the merge base version reads:
this is file.txt.
it has a bunch of lines.
we plan to change some of them on one side of the merge.
we plan to change other lines on the other side.
here is something to change without conflict:
la la la, banana fana fo fana
here is something else
to change with conflict:
this is what was there before the two
changes in our HEAD commit and our other commit
and finally,
here is something to change without conflict:
one potato two potato

In HEAD, let's make the file read this way, using however many commits we like to get to this point:
this is file.txt.
it has a bunch of lines.
we plan to change some of them on one side of the merge.
we plan to change other lines on the other side.
here is something to change without conflict:
a bit from the Name Game
here is something else
to change with conflict:
stuff from our HEAD commit
and finally,
here is something to change without conflict:
one potato two potato

(Note that we made two distinct regions of change.  By default git diff will combine them into a single diff hunk as there's only one context line between them, but git merge will treat them as separate changes.)
In the other (feature) branch let's make a different set of changes, so that file.txt reads:
this is file.txt.
it has a bunch of lines.
we plan to change some of them on one side of the merge.
we plan to change other lines on the other side.
here is something to change without conflict:
la la la, banana fana fo fana
here is something else
to change with conflict:
stuff from the other commit (H' in our case)
and finally,
here is something to change without conflict:
cut potato and deep fry to make delicious chips

Again, we have made two changes, but only one conflicts.
The work-tree version of the merged file will take each change that does not conflict, so that the file will read, in full:
this is file.txt.
it has a bunch of lines.
we plan to change some of them on one side of the merge.
we plan to change other lines on the other side.
here is something to change without conflict:
a bit from the Name Game
here is something else
to change with conflict:
<<<<<<< HEAD
stuff from the HEAD commit
=======
stuff from the other commit (H' in our case)
>>>>>>> feature
and finally,
here is something to change without conflict:
cut potato and deep fry to make delicious chips

It's your job, as the one doing the merge, to resolve the conflict.
You may choose to do this:
git checkout --ours file.txt

or:
git checkout --theirs file.txt

but either of these simply copies the "ours" or "theirs" index version (from slot 2 or 3) to the work-tree.  Whichever one you choose, you will lose the changes from the other branch.
You may hand-edit the file, removing the conflict markers and keeping or modifying some or all of the remaining lines to resolve the conflict.
Or, of course, you can use any of your favorite merge tools to handle the conflict.
In all cases, though, whatever is in your work-tree will be your final product.  You should then run:
git add file.txt

to wipe out the stage 1, 2, and 3 entries and copy the work-tree version of the file to the normal stage-zero file.txt.  This tells Git that the merge is now resolved for file.txt.
You must repeat this for all the remaining unmerged files.  In some cases (rename/rename conflicts, rename/delete, delete/modify, and so on) there is a bit more work to do, but it all boils down to making sure that the index has only the final stage-zero entries that you want, and no higher-stage entries.  (You can use git ls-files --stage to see all the entries in all their stages, although git status does a pretty good job of summarizing the interesting ones.  In particular, all files that have stage-zero entries that exactly match the HEAD commit are extremely boring, and git status skips right over them.  If there are hundreds or thousands of such files, that's very helpful.)
Once you have resolved all the files in the index, you run git commit.  This makes merge commit M.  What's in the commit is whatever is in your index, i.e., whatever you git add-ed to remove higher stage index entries and insert stage-zero entries.
Using git checkout to check out and resolve at the same time
As noted above, git checkout --ours or git checkout --theirs just gets the copy from index slot 2 or 3 and writes it to the work-tree.  This does not resolve the index entries: all the slot 1, 2, and 3 unmerged entries are still there.  You must git add the work-tree file back to mark it resolved.  As we also noted, this loses any changes from the other tip commit.
If that's what you want, though, there is a short-cut.  You can:
git checkout HEAD file.txt

or:
git checkout MERGE_HEAD file.txt

This extracts the version of file.txt from the HEAD (F') or MERGE_HEAD (H') commit.  In so doing, it writes the contents to stage zero for file.txt, which wipes out stages 1, 2, and 3.  In effect, it gets the --ours or --theirs version and git adds the result, all at once.
Again, this loses any changes from the tip commit.
It's easy to get this wrong
It's very easy to get these resolving steps wrong.  In particular, git checkout --ours and git checkout --theirs, and their short-cut versions using HEAD and MERGE_HEAD, drop the other side's changes to a file.  The only indication that you will have of this is that the merge result is missing some changes.  As far as Git is concerned, that's the correct result: you wanted those changes dropped; that's why you set the stage-zero index entry that way before you made the merge commit.
It's also easy to get a surprise merge base, particularly if you try to do a lot of git rebase or git cherry-pick work to copy commits around and move branch names to point to the new copies.  It's always worth carefully studying the commit DAG.  Get help from "A DOG": git log --all --decorate --oneline --graph, all decorate oneline graph; or use gitk or some other graphical viewer, to visualize the commit graph.  (Instead of --all you might also consider using the two branch names in question, i.e., DOG rather than just any old A DOG: git log --decorate --oneline --graph master feature.  The resulting graph is likely to be simpler and easier to read.  However, if you did a lot of rebasing and cherry-picking, --all may reveal more.  You can even combine this with specific reflog names such as feature@5, though this gets a bit long-winded and makes for quite messy graphs.)

A: You got very long and good answers already. Let me add this:

My personal theory is that git somehow "remembered" that we had undone commits A B C, so when they came from the new feature branch, git decided not to merge them.

Git never "somehow" "remembers" anything about the contents of your repository. Nor does it ever decide to do or not to do anything based on what you did before. It is very clean in that regard. All its commands are just tools to work on the directed acyclic graph that its commits (and on a lower level, all other objects it stores) are building. And to make it even easier, it only ever adds stuff, never changes or deletes anything.
Except for the commits (i.e., author, timestamp, parent commits etc.), trees (i.e. directories), blobs (i.e., binary data) and a few less important things, there are literally no data structures or further management information about your files and such in the repository. A merge commit does not leave any information that is specific to the "merge"; it is simply a commit with multiple parents.
There is certainly no magic, undocumented stuff going on. The repository is very open, you can literally look at everything using git commands, and everything is fully documented (google "git data structures" or "git internals" if you are interested). Even modifying the internal objects is quite easy if you so wish.
There is one little bit where bit keeps historic information around, this is the so-called "rerere cache" which stores previous conflict resolutions and thus can indeed change the behaviour of future merges. Very handy indeed, but not enabled by default, and certainly not related to the topic at hand.

EDIT: sorry if this explanation sounds too much like "magical thinking", but I'm at a loss. I welcome any attempt to put this explanation in more technical terms, if it's right

Trust the source, luke. It is great that you are trying to get your head around git, and a strong belief that everything is plain and non-magical should help, hopefully.