Uses C standard format codes.
from datetime import datetime
datetime_for_string = datetime(2016,10,1,0,0)
datetime_string_format = '%b %d %Y, %H:%M:%S'
datetime.strftime(datetime_for_string,datetime_string_format)
# Oct 01 2016, 00:00:00
malloc() often calls underlying operating system functions to obtain pages of memory. But there is nothing special about the function and it can be implemented in straight C by declaring a large static array and allocating from it (there is a slight difficulty in ensuring correct alignment, in pract...
Let's say we have 8 houses. We want to setup telephone lines between these houses. The edge between the houses represent the cost of setting line between two houses.
Our task is to set up lines in such a way that all the houses are connected and the cost of setting up the whole connection is mini...
FullCalendar can be downloaded from it's website: https://fullcalendar.io/download/
from NPM:
$ npm install fullcalendar
from Bower:
$ bower install fullcalendar
or CDNJS:
//cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.0.1/fullcalendar.min.js
//cdnjs.cloudflare.com/ajax/libs/fullca...
After enabling and creating migrations there might be a need to initially fill or migrate data in your database. There are several possibilities but for simple migrations you can use the method 'Seed()' in the file Configuration created after calling enable-migrations.
The Seed() function retrieves...
Sometimes we want to use a where query on a a collection of records returned which is not ActiveRecord::Relation.Hence we get the above error as Where clause is know to ActiveRecord and not to Array.
There is a precise solution for this by using Joins.
EXAMPLE:-
Suppose i need to find all user ...
Consider the following Java classes:
class Foo {
private Bar bar;
public void foo() {
bar.baz();
}
}
As can be seen, the class Foo needs to call the method baz on an instance of another class Bar for its method foo to work successfully. Bar is said to be a dependency for Foo sin...
The same examples as shown above with XML configuration can be re-written with Java configuration as follows.
Constructor injection
@Configuration
class AppConfig {
@Bean
public Bar bar() { return new Bar(); }
@Bean
public Foo foo() { return new Foo(bar()); }
}
Property in...
Dependencies can be autowired when using the component scan feature of the Spring framework. For autowiring to work, the following XML configuration must be made:
<context:annotation-config/>
<context:component-scan base-package="[base package]"/>
where, base-package is th...
Constructor injection through Java configuration can also utilize autowiring, such as:
@Configuration
class AppConfig {
@Bean
public Bar bar() { return new Bar(); }
@Bean
public Foo foo(Bar bar) { return new Foo(bar); }
}
Go through the steps:
Add 'NSAppleMusicUsageDescription' to your Info.plist for the privacy authority.
Make sure your music is available in your iPhone. It will not work in the simulator.
iOS 10.0.1
import UIKit
import AVFoundation
import MediaPlayer
class ViewController: UIViewControll...
Core Plot provides a podspec, so you can use cocoapods as your library manager which should make installing and updating much simpler
Install cocoapods on your system
In the project directory add a text file to your project called Podfile by typing pod init in your project directory
In the Podfil...
Sometimes you need a piece of code to execute when the program stops, such as releasing system resources that you open. You can make a thread run when the program stops with the addShutdownHook method:
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
ImportantStuff.someImportantIOStr...
Processing provides method rect() to draw a rectangle. This code draws a white 50 X 50 rectangle on black background.
void setup() {
size(500, 500);
background(0);
fill(255);
noStroke();
}
void draw() {
rect(225, 225, 50, 50);
}
The signature of method rect() is thi...
Instances have a lot of metadata that gets returned from a call to describe-instances, but often times you just want to see the basics. You can use a JMESPath query combined with table output to show concise instance information in an easily readable way.
aws ec2 describe-instances --output table -...
There are several packages which can run Processing sketches in the Atom editor. These instructions use the Script package. There are also available packages for syntax highlighting and autocomplete, which are required for Script to identify Processing filetypes.
Install the Script plugin. Either b...
First of all, Merged Cells are there only to improve the look of your sheets.
So it is literally the last thing that you should do, once your sheet and workbook are totally functional!
Where is the data in a Merged Range?
When you merge a Range, you'll only display one block.
The data will be ...