FAQ Database Discussion Community


Handle local files in default iOS application

ios,file,default
I have files that are stored in the Document directory. The url scheme for them is file:/// and so on. Is there a way to handle such files with appropriate default app. Lets say I have a video file there and instead of handling play in my app, it opens...

How to set default value for association with simple_form?

ruby-on-rails,forms,default,simple-form
I'd like to do something like this: <%= f.association :productgroup, default: params[:productgroup_id] %> The params should only be used if there is no value (lets say for new records), so selected: is not what I'm looking for because it overrides the value when I edit the record. Thanks, Andreas...

Default value doesn't work in SQLAlchemy + PostgreSQL + aiopg + psycopg2

postgresql,sqlalchemy,default,psycopg2
I've found an unexpected behavior in SQLAlchemy. I'm using the following versions: SQLAlchemy (0.9.8) PostgreSQL (9.3.5) psycopg2 (2.5.4) aiopg (0.5.1) This is the table definition for the example: import asyncio from aiopg.sa import create_engine from sqlalchemy import ( MetaData, Column, Integer, Table, String, ) metadata = MetaData() users = Table('users',...

How to open a file using specific application in cygwin?

linux,windows,cygwin,default,notepad
I know that you can open programs in cygwin using cygstart. I also know that you can open files in a similar fashion. However, I would like to open a file using a specific program. For example, I want to open a text file using sublime and I try: cygstart...

Datepicker set today's day as a default

javascript,jquery,datepicker,set,default
So I have a datepicker and when I select a day, the day of the week is inserted into another input. $( "#datepicker" ).datepicker({ dateFormat: "dd-mm-yy", onSelect: function(){ var seldate = $(this).datepicker('getDate'); var day = seldate.getUTCDay(); var weekday=new Array(); weekday[0]="Maandag"; weekday[1]="Dinsdag"; weekday[2]="Woensdag"; weekday[3]="Donderdag"; weekday[4]="Vrijdag"; weekday[5]="Zaterdag"; weekday[6]="Zondag"; var dayOfWeek = weekday[day];...

Get SSLContext for default system truststore in Java(JSEE)

java,security,ssl,default
I've been using custom keystore in my program by specifying javax.net.ssl.keyStore, javax.net.ssl.keyStorePassword, javax.net.ssl.trustStore, javax.net.ssl.trustStorePassword. My truststore contains self-signed certificates. Now I want to make some https request(say to https://google.com) and use default jre system trusstore that contains information about different CAs. To make http requests I use OkHttp library. Its...

Dictionary __gt__ and __lt__ implementation

python,python-2.7,dictionary,default
I've been experimenting with Python dictionaries and discovered that __gt__ and __lt__ are implemented for dictionaries. I've tested them and it appears that they somehow compare the keys, but it is not quite clear to me how that is done; for example, I'm not quite sure how {1: 1} >...

Set default query by var1 & var2

php,default
I have two variables: var1 & var2. I want to display var1 default, but if var1 is empty or null, show var2. Regardless of whether or not it has var2 value the basic: $var1:''; $var2:'volvo"; $var3 = empty($var1)? $var2 : $var1; working. but the complete script with query: <form class="form-wrapper...

Sorting through list of lists?

python,list,indexing,default
So I have a list of lists: nums = [[98, 90, 91], [46, 76, 62], [85, 90, 83], [77, 79, 81]] and I want to sort through them. When a number in a list(mini-lists) of the list(main list) is lower than a default I give in the argument, the function...

Override Spring form error messages

java,spring,default,custom-errors
In Spring how do I override default form error massages ? I'm using a Validator and a properties file to add my own error messages, but how do I override messages that get printed on conversion/encoding error for example ? They seem to be generated automatically and I don't think...

Unity3d c# - Vector3 as default parameter

c#,unity3d,default
How can we add Vector3 as default parameter for a method? for example: Void SpawnCube(Vector3 p = new Vector3(0,0,0)){...} I just tried the line about I got an error: Expression being assigned to optional parameter `p' must be a constant or default value I want to customise a function to...

Why printf is not printing garbage value?

c,gcc,default,undefined-behavior,garbage
#include<stdio.h> void foo(){ int i; printf("%d\n",i); //should print garbage value } void main(){ foo(); } foo should print garbage value of i. But instead it is printing zero. Why is that? I am using gcc version 4.9.2....

Mass change column default values in database project

visual-studio-2013,default,database-project
I have a Visual Studio 2013 database project, in which I would like to change all GUID columns with a default of newid() to newsequentialid(). Using the following query to identify the columns: SELECT so.name AS table_name, sc.name AS column_name, sm.text AS default_value FROM sys.sysobjects so JOIN sys.syscolumns sc ON...

Using angularJS click on enter form functionality in Internet Explorer

javascript,html,angularjs,internet-explorer,default
I have a form in angularJS like this: <form> <div class="row form-group"> <div class="col-xs-4"> <label>Product name:</label> </div> <div class="col-xs-8"> <input ng-model="vm.name" ng-disabled="vm.product.name"> </div> </div> <button ng-hide="1" ng-click="vm.addName()"></button> </form> The idea being that when a user enters a name the form locks it (inside addName()) and does an API call to...

Why using different (shared_ptr and normal) pointer constructors on the same class I get different results?

c++,c++11,constructor,initialization,default
Inspired by this question I wrote my own little program (using code from this answer) and discovered things that confused me. Namely: Having those classes: class A { public: A(){} int i; int j; }; class B { public: B() = default; int i; int j; }; I wrote 4...

How do I set the default value of an object equal to the current user's value for that same attribute of the current user? (Rails 4)

ruby-on-rails,ruby,default,default-value
What I want to do: Have a User who is currently logged on ("current_user") create a new instance of the Adult class ("adult") and - if current_user does not specify the number of kids (num_kids) that adult has AND current_user specifies that adult.relationship of adult to user is "husband", "wife"...

PHP - Creating a class named 'Default'

php,class,default
I know that default is a reserved keyword in PHP. I came up to this weird situation where I wanted to name my class Default, but it seems whenever I try to create it in any place in code my whole page turns blank and PHP is not showing any...

Set default webpage in vb.Net web-project

vb.net,default,webpage,web-project
I have a class api, and a function test in my web-project. To call this function, I type the link http://localhost/api/test in my browser. Now my question is it possible to call a default page, for example index.html, if i just call the class without the function like: http://localhost/api ?...

:Set project application settings to defaults

c#,visual-studio,default,application-settings
I'm trying to use the application setting in my c# project. However, Properties.Settings.Default.Reset() actually sets all properties to their system defaults (a String will be set to null and not the value i set as base). Is there a way to set default values for properties so that i can...

Node.js: Mongoose schema default rand-tokens are not random

node.js,mongodb,random,default,uid
I have a UserSchema like this and I cannot seem to generate unique random activation_token's. I am using rand-token for the generation. Found here. var UserSchema = new Schema({ activation_token: { type: String, default: randToken.generate(64), }, email: { type: String, unique: true, sparse: true }, first_name: { type: String },...

Java, default exception messages

java,exception,message,default
Given the following: public abstract class Test { public static void main(String[] args) { int[] testArray = {6, 3, 2}; System.out.println(testArray[3]); } } when I run the program I get: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 at Test1.main(Test1.java:5) In this case the JVM displays the index that is out of...

openerp many2many default disappear

many-to-many,openerp,default
I have a form which I pass some invoice ids through context by an act_window. Invoices are set as default in an many2many field (I tried both using a default function and overriding the default_get function), but when I add a record on another one2many field in the same form,...

How to make a default instance in Ruby as in Prime class?

ruby,class,module,instance,default
I would like to make a class or maybe a module which can be loaded / required with "require" or "require_relative". However, for simplicity I don't want to instantiate any objects, just start using its methods, similar to Ruby's Prime class. How can I achieve this? require "my_module" puts My_module.convert("data")...

Wrong value for window.innerWidth during onload event in Firefox for Android?

javascript,html,css,firefox,default
Okay, so, the problem I am facing is this: my mobile Firefox browser is not retrieving the correct values for window.innerWidth, document.documentElement.clientWidth, or even the width of a div styled to take up the whole client window after page load. I am not crazy, my code works just fine in...

how to have default value for a text field only for new form in rails? iam using :value => “0”.but in edit form also iam getting '0' value

ruby-on-rails,forms,default,textfield,value
How to have default value for a text field only for new form in rails? I am using :value => "0" in form partial. But the problem is though I have a value in database, I am getting 0 in edit form. actually in new form for a text field...

DateTimeOffset default value

default,datetimeoffset
I would like to set default value to DateTimeOffset - it should not be DateTime.Now but rather DateTime.MinValue or default(DateTime) Any thoughts how can I do it? This code: DateTimeOffset d = new DateTimeOffset(DateTime.MinValue) throws an exception...

Rails: Cloudinary gem - default image not loading

ruby-on-rails,ruby,image,default,cloudinary
I'm working on a pinterest-like app, using Cloudinary gem with Attachinary. I have added a line into my index.html.erb file which was supposed to display a default image if a created Pin didn't have one or the image didn't load properly. <% if pin.image.present? %> <%= link_to pin do %>...

How to make item selected in dropdown list

php,zend-framework,default
here is a piece of my php code, related to dropdown list creation: $s_t = array( "key1" => "value1", "key2" => 'value2', "key3" => 'value3'); $default_select = "value2"; $attr = array("id" => "name"); $form->addElement('select','name',"Choose your option:",$s_t, $attr); How to make default selected item in the list, according to $default_select value?...

PHPExcel setActiveSheetIndex not working properly

indexing,default,phpexcel,sheet,first-time
I'm using PHPExcel to make export xls with 2 worksheets. When I open the generated xls file , it open directly the second worksheet, even that I've declared on the code that generates the first worksheet : $objPHPExcel->setActiveSheetIndex(0) This happened after I've added the following lines in the code that...

Java default constructor without initialization

java,constructor,default,super
I have a class similar to the below one with all static methods. Hence the class was not initialized while used in other classes. I have to check a condition before invoking any static methods from this class. Even if i add a default constructor it will not get called....

SQL - SET DEFAULT doesn't work when deleting a value

sql,postgresql,default
I have 2 tables: CREATE TABLE REP ( PRIMARY KEY REP_NUM CHAR(2) DEFAULT ('00'), LAST_NAME CHAR(15), FIRST_NAME CHAR(15), STREET CHAR(15), CITY CHAR(15), PROVINCE CHAR(3), ZIP CHAR(5), COMMISSION DECIMAL(7,2), RATE DECIMAL(3,2) ); And: CREATE TABLE CUSTOMER ( CUSTOMER_NUM CHAR(3) PRIMARY KEY, FOREIGN KEY (REP_NUM) REFERENCES REP ON DELETE SET DEFAULT, CUSTOMER_NAME...

Set default option in select-element using php

php,html,select,default
I'm looking for a simple way to dynamically change the default item in a select-element without adding a ton of code into every option-element. This is an example of a select-element that allows you to select a month and it always sets the current month as the default item: <select...

Typo3: capture default generated css in lib

css,typo3,default
I need to capture the default generated CSS inside a lib, which will be displayed in an XML page type. For this, I tried: lib.defaultCss = COA lib.defaultCss { 10 < plugin.tx_cssstyledcontent._CSS_DEFAULT_STYLE wrap = <defaultCss><![CDATA[|]]></defaultCss> } page.1 < lib.defaultCss In the object browser I can see the correct value (default...

android default making default sms app

android,sms,default,telephony
So I am following this Tutorial here on setting my SMS as default, but for some reason my code is not working. I have tried to look this up as much as possible, but everything points back to this same tutorial or has been outdated. Do I need a receiver...

cakephp error. Connection to database …not …: Access denied for user 'my_app'@'localhost' (using password: YES)

database,cakephp,default,cakephp-3.0
I am trying to start CakePHP. I made bookmarker and tested by command bin\cake server. It showed one error as connection to database could not be established: SQLSTATE[HY000] [1045] Access denied for user 'my_app'@'localhost' (using password: YES). I read the config/app.default.php file. It says there is a database my_app and...

php function argument default value - how to know that def. value was applied?

php,function,default
I have a function function my_func($id,$arg1='aaa',$arg2='bbb'){ if($arg1=='aaa'){ //means that def. value applied, real argument has not been provided } if($arg1=='bbb'){ //means that def. value applied, real argument has not been provided } } I check if my values are default I will do one thing, if not - another thing....

laravel default localizations for other languages?

locale,default,laravel-5
A new Laravel project already comes with some localizations, in english. . └── en ├── auth │   ├── form.php │   └── message.php ├── button.php ├── general.php ├── groups │   ├── form.php │   ├── message.php │   ├── modal.php │   ├── table.php │   └── title.php ├── pagination.php ├── passwords.php ├── reminders.php ├──...

Priority language in multi language website

asp.net,resources,default,multilanguage,hindi
I'm following this guide to create a multi language page : http://www.codeproject.com/Articles/334820/Using-Globalization-and-Localization-in-ASP-NET But a problem is : I want my website default language is Hindi. But the browser often set English is default language. That cause when I load my site, the language on it is English, not Hindi (I...

Odoo8 - how can I sort status bar and set default as new?

default,statusbar,odoo,odoo-8
I have created a new module in Odoo for helpdesk and I have 2 problems that I can't seem to fix or find information on so need some help. I created a status bar (code): state = fields.Selection({('new','New'), ('open','In Progress'), ('closed','Closed')}, "Status") _defaults = { 'state': 'new' } <header> <field...

Can I have just getters and not setter?

groovy,default,setter,getter
I am quite new to groovy, and I have found out that by making a field public, groovy provides getters and setters by default. Is there a way to have just the getters but not the setters by default? The reason behind this is that I have a Builder and...

Oscommerce display default product image and prevent it from deletion

image,set,default,product,oscommerce
I am working on an oscommerce project where i want to display default product image (i.e no image available) if product image is not uploaded.And even i want it to prevent from deletion.I have tried to upload product not available image for 2-3 products but when deleting products i.e final...

Default value for username in SQL database

mysql,laravel,default,nullable,username
I'm writing a Laravel application, and for testing in sqlite you need to specify ->nullable() or ->default("123") for all fields in your migration. This confuses me as my User-migration currently looks like this: public function up() { Schema::create('users', function($table) { $table->increments('id'); $table->integer('role_id'); $table->string('username')->unique(); $table->string('password'); $table->string('name'); $table->string('email'); $table->integer('max_locations'); $table->string('auth_token');...

python argparse always set defaults related to an optional argument

python,default,argparse,optional-parameters
I use python 3, i want to set argparse to always set the default key in relation to a predefined optional argument of my choice. E.g. I pass some input files to the script. An optional argument specify if the input file should be rotated by the script. I get...

Python - how to set default parameter equal to another parameter

python,default,optional-parameters
I have a function, which should have one optional parameter. I want the optional parameter to be the same as other parameter. Something like this: def foo(arg1, arg2, src, dst=src): ... ... Parameter dst is the optional one. The thing is when dst is not given when calling foo, it...

Where does the default JSON errors response in spring-boot-starter-web comes from and how to adjust it?

spring-mvc,configuration,spring-boot,default
I am very happy with the spring-boot project so far, but I'd like to develop a deeper understanding, of how everything is glued together. Using spring-boot-starter-web, spring-boot-starter-data-jpa and hateoas I was able to assemble a nice working REST backend. But I am wondering, how it is done, that e.g. a...

Window Close Listener And setDefaultCloseOperation

java,swing,jframe,default,windowlistener
I have a question about the relationship between swing window listener and default close operation. The question occurs when I am dealing with below scenario: I add a window listener (WindowAdapter is used for the listener) for a JFrame, and override the windowClosing function: if the user closes the window,...

Template function default parameter

c++,templates,constructor,default
//template.h using MSVC++ 2010 #pragma once #include <iostream> using std::ostream; template <typename T, typename U> class Pair { private: T first; U second; public: // Pair() ; Pair ( T x = T() , U y = U() ) ; template<typename T, typename U> friend ostream& operator<< ( ostream& thisPair,...

View values as hexidecimal by default while debugging in Android Studio

android-studio,settings,default
My question is similar to "Android Studio" debugging - display variables as hexadecimal, but I want to know how to make this the default setting. I know how to change the setting for individual values: but for checking the values of all the characters in long strings, this becomes tedious....

php my admin default Timestamp is wrong even if I use correct timezone

php,timestamp,default
I am experiencing problem in default timestamps I have this column name dateCreated type is TIMESTAMP and default as CURRENT_TIME whenever I insert a new row in my add member page the time generated is late for 2 hrs. I currently live in ASIA/MANILA which is GMT +8. I tried...