Processing Field collection items with Rules is fun, really! Have a look at this Rule (in Rules export format):
{ "rules_calculate_sum_of_prices_in_all_field_collection_items" : {
"LABEL" : "Calculate sum of prices in all field collection items",
"PLUGIN...
The same example from above can also be done using what is known as field injection. Instead of annotating the constructor with @Inject, we annotate the fields we wish to have injected
public class Spaceship {
@Inject
private PropulsionSystem propulsionSystem;
@Inject
private ...
F() expressions can be used to execute arithmetic operations (+, -, * etc.) among model fields, in order to define an algebraic lookup/connection between them.
Let model be:
class MyModel(models.Model):
int_1 = models.IntegerField()
int_2 = models.IntegerField()
Now lets assum...
Here is an example of custom UITextField that takes only numerical text and discards all other.
NOTE: For iPhone it is easy to do this using Number type keyboard, but for iPad there is no keyboard with Numbers only
class NumberTextField: UITextField {
required init(coder aDecoder: NSCoder) ...
If we want to disable all the actions like Copy, Paste, Replace, Select, etc from UITextField then we can use following custom text field:
class CustomTextField: UITextField {
var enableLongPressActions = false
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
o...
For Swift 3.1:
In the first example one can see how you would intercept the user interacting with a textfield while writing. Similarly, there are methods in the UITextFieldDelegate that are called when a user has started and ended his interaction with a TextField.
To be able to access these method...
This example shows how to achieve an effect similar to FaceTime were a view is attracted to point once it enters a particular region, in this case two regions a top and bottom.
Swift
class ViewController: UIViewController
{
lazy var dynamicAnimator: UIDynamicAnimator =
{
let ...
Example of a TCA field configuration where you can select records from a table
'my_topfeatures' => array(
'label' => 'Select Topfeatures',
'config' => array(
'type' => 'group',
'internal_type' => 'db',
'size' => '4',
...
object CommonUtils {
var anyname: String ="Hello"
fun dispMsg(message: String) {
println(message)
}
}
From any other class, just invoke the variable and functions in this way:
CommonUtils.anyname
CommonUtils.dispMsg("like static call")
// Token from another example. This token is expired
var tokenString = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJleHAiOjE1MDAwLCJpc3MiOiJ0ZXN0In0.HE7fK0xOQwFEr4WDgRWj4teRPZ6i3GLwD5YCm6Pwu_c"
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error...
There are many ways to send _token on AJAX call
Get all input field's value within <form> tag using var formData = new FormData($("#cart-add")[0]);
Use $("form").serialize(); or $("form").serializeArray();
Add _token manually on data of Ajax. using $('meta[n...
Arrays of bit-fields, pointers to bit-fields and functions returning bit-fields are not allowed.
The address operator (&) cannot be applied to bit-field members.
The data type of a bit-field must be wide enough to contain the size of the field.
The sizeof() operator cannot be applied to a b...
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
public class JsonFieldsCollector
{
private readonly Dictionary<string, JValue> fields;
public JsonFieldsCollector(JToken token)
{
fields = new Dictionary<string, JValue>();
CollectFields...