When you need a Python list object, you can utilize the tolist() method to convert your array to a list.
my_array = array('i', [1,2,3,4,5])
c = my_array.tolist()
# [1, 2, 3, 4, 5]
Sometimes, if an action should be bind to a collection view's cell selection, you have to implement the UICollectionViewDelegate protocol.
Let's say the collection view is inside a UIViewController MyViewController.
Objective-C
In your MyViewController.h declares that it implements the UICollecti...
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
Context is important if you ship your class for others to use.Context lets your class observer verify that its you observer which is being called.
The ...
If you are using library that contains (for example) AwesomeViewController with a wrong status bar color you can try this:
let awesomeViewController = AwesomeViewController()
awesomeViewController.navigationBar.barStyle = .blackTranslucent // or other style
Click the “Move examples” button
Select the examples you want to move
Click “Move”
Select “Search for a Topic”
Paste the URL of the topic in the search box
Click “Move Examples”.
Click “Submit Drafts” or “Edit Drafts”
Name-based virtual hosting on Apache is described on the Apache website as such:
With name-based virtual hosting, the server relies on the client to
report the hostname as part of the HTTP headers. Using this technique,
many different hosts can share the same IP address.
Therefore, more than...
This command will save the open file with sudo rights
:w !sudo tee % >/dev/null
You can also map w!! to write out a file as root
:cnoremap w!! w !sudo tee % >/dev/null
Add this to your $MYVIMRC:
" Source vim configuration file whenever it is saved
if has ('autocmd') " Remain compatible with earlier versions
augroup Reload_Vimrc " Group name. Always use a unique name!
autocmd! " Clear any preexisting autoc...
An SSH key has two pieces, the public key and the private key.
The private key:
Is usually in a file named id_rsa, but it can be given any name.
CANNOT BE REGENERATED IF LOST!!!! Do not lose this file!
If you lose it, you will not be able to get back into your instance. (StackOverflow is li...
RxSwift offers many ways to create an Observable, let's take a look:
import RxSwift
let intObservale = Observable.just(123) // Observable<Int>
let stringObservale = Observable.just("RxSwift") // Observable<String>
let doubleObservale = Observable.just(3.14) // Observable&...
Node Version Manager (nvm) greatly simplifies the management of Node.js versions, their installation, and removes the need for sudo when dealing with packages (e.g. npm install ...). Fish Shell (fish) "is a smart and user-friendly command line
shell for OS X, Linux, and the rest of the family&...
This is a custom JAX-RS @Provider to use Gson as the JSON parser. The example also shows how to use custom Java 8 date/time converters.
@Provider
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class JerseyServerGson
implements MessageBodyWriter<O...
2005
The following iterates over the characters of the string s. It works similarly for looping over the elements of an array or a set, so long as the type of the loop-control variable (c, in this example) matches the element type of the value being iterated.
program ForLoopOnString;
{$APPTYPE ...
Every Windows Phone project contains App.cs class:
public sealed partial class App : Application
This class is your global application context.
General Application class usage:
App entry point, particularly for various activation contracts.
Application lifecycle management.
Application g...
Many tasks require elevated privileges. You can elevate user privileges to Administrator level for your batch runtime using a shortcut:
Press alt+ and the batch file to a selected folder to create a shortcut.
Right click and select "Properties".
Select the "Shortcut&quo...
The following batch file will popup a UAC Prompt allowing you to accept elevated Administrator privileges for the batch session. Add your tasks code to :usercode section of the batch, so they run with elevated privileges.
@echo off
setlocal EnableDelayedExpansion
:: test and acquire admin rights
...
The behaviour of virtual functions in constructors and destructors is often confusing when first encountered.
#include <iostream>
using namespace std;
class base {
public:
base() { f("base constructor"); }
~base() { f("base destructor"); }
virtual co...
We can use the class DateInterval to add or subtract some interval in a DateTime object.
See the example below, where we are adding an interval of 7 days and printing a message on the screen:
$now = new DateTime();// empty argument returns the current date
$interval = new DateInterval('P7D');//th...