How do I add two sets?

All you have to do to combine them is Sets are unordered sequences of unique values. a | b or a.union(b) is the union of the two sets (a new set with all values found in either set). This is a class of operation called a “set operation”, which Python sets provide convenient tools for.

How to “wait” a Thread in Android

You need the sleep method of the Thread class. public static void sleep (long time) Causes the thread which sent this message to sleep for the given interval of time (given in milliseconds). The precision is not guaranteed – the Thread may sleep more or less than requested. Parameters time The time to sleep in … Read more

cannot redeclare block scoped variable (typescript)

The solution for me was to convert my code from using CommonJS (require, module.exports, etc) to ES Modules (import, export, etc.) The TypeScript documentation also appears to recommend ES Module syntax: TypeScript Modules Of course there’s a lot more to it than this, but as a start: Replace instances of require with import, e.g. Replace: … Read more

How to revert the last migration?

You can revert by migrating to the previous migration. For example, if your last two migrations are: 0010_previous_migration 0011_migration_to_revert Then you would do: You don’t actually need to use the full migration name, the number is enough, i.e. You can then delete migration 0011_migration_to_revert. If you’re using Django 1.8+, you can show the names of all the … Read more

C printing bits

You are calculating the result correctly, but you are not printing it right. Also you do not need a second loop: If you’d like to show off, you could replace the conditional with two exclamation points:

Categories C Tags

How to use PHP inside css file

If you’re able to rename your CSS file “layout.php”, there’s no need for all of these workarounds: Your layout.php file would look like: Your HTML files would look like: This question is very similar: Include: css with php file extension?

How do I pass the this context to a function?

Javascripts .call() and .apply() methods allow you to set the context for a function. Now you can call: Which would alert FOO. The other way around, passing obj_b would alert BAR!!. The difference between .call() and .apply() is that .call() takes a comma separated list if you’re passing arguments to your function and .apply() needs … Read more