w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Simple Form: How can I create a custom wrapper that does not wrap the input and create a label?
This code below may result in your expected HTML: config.wrappers :category_tab, tag: "ul" do |ul| ul.use :html5 ul.wrapper tag: "li" do |li| li.wrapper tag: "label" do |label| label.use :input, label: false end end end

Categories : Ruby On Rails

Unable to create a model with Eloquent create method. Error telling MassAssignMentException
Your model needs to have the $fillable variable set. See the documentation on mass-assignment for details. It will look something like this in your Author model: protected $fillable = array('user', 'info');

Categories : Laravel

When clicking a file to create a jstree leaf, it create many leafs using jquery
You can use .one() $(this).one("click", function(event) { if($.trim($(this).attr("value")) == "fileButton") { var fileID = setID(); $("#treeFile").jstree("create", null, "last", {"attr" : "SpecialFile", "id" : "file_"+fileID}) } });

Categories : Jquery

Can I create a user in AWS IAM that only has rights to create users and place them in a specific Group?
Yes, you need to create an IAM user and then give it this iam policy. { "Statement": [ { "Sid": "Stmt1375475989975", "Action": [ "iam:AddUserToGroup", "iam:CreateUser" ], "Effect": "Allow", "Resource": "arn:aws:iam::152997954706:user/AMISTACK-02-WEB-User-WYEMFOJZ4BDP" } ] } arn:aws:iam::152997954706:user/AMISTACK-02-WEB-User-WYEMFOJZ4BDP is an example user ARN. You'll need to add in yours specific user's arn. An easy way to create policy files is to use: http://awspolicygen.s3.amazonaws.com/policygen.html

Categories : Amazon

undefined method `create' for nil:NilClass when trying to create profile in user model
after_create :create_profile is just enough, not necessary to define create_profile method, it's provided by rails. Example: class User < ActiveRecord::Base has_one :profile after_create :create_profile end

Categories : Ruby On Rails

How would I create a CBV using django rest framework which will either retrieve a model instance or create a new one?
for classbased views in django-rest-framework this is usually done by: a GET request to the resource will retrieve records a POST request to the same resource will create a record I believe there are a couple examples of this in the django rest framework documentation

Categories : Django

I try to create a build in ant were it create a html report which will start my .class file
Try the following build.xml. Please keep it in mind the following change you need to do manually in this file Project name in very first line lib.dir address should be the one where all of your jars are kept physically. I suggest create a dir, put all the jars in this and give the address over here. the report directory I have changed and now it is under the project directory, parallel to src. If you need you can change it. Please note that I have changed my build.xml having many other features to the one you are comfortable. I have updated it very carefully, though very few changes may left by mistake that I suppose you can do. still if you found any problem, I would love to help you as far as I can. <project name="ProjectName" basedir="."> <property name="home.dir"

Categories : Java

How to create custom view, which I create in code, but set its parameters in its XML layout resource
You can use <merge> tag along with all those attributes in your current <LinearLayout> tag. <merge xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/semesterInfo" android:visibility="visible" android:layout_marginLeft="6dp" android:layout_marginRight="6dp" android:layout_marginTop="4dp" android:layout_marginBottom="4dp" android:gravity="fill_horizontal" android:layout_weight="1" android:background="@drawable/card_ui_bg" > <!-- card_title and card_content --> </merge>

Categories : Android

How to create pie chart with pyqtgraph.GraphicsWindow and create custom scale in x axis
For the first problem, pyqtgraph has no built-in pie chart graphics. However, these should be fairly simple to construct by creating one QGraphicsEllipseItem for each wedge. For the second, use the following: majorTickValues = [(0,"5"),(1,"7"),(2,"16")] plotItem.getAxis('bottom').setTicks([majorTickValues])

Categories : Python

how to create an eclipse plugin to auto create read/ writeExternal methods of existing class
The easiest way is to build upon org.eclipse.jdt.ui.actions.GenerateMethodAbstractAction that is used by eclipse to implement GenerateToStringAction and GeneateHashCodeEqualsAction. Basically: Build a basic sub-class of GenerateMethodAbstractAction Implement logic that enumerates all the fields / properties etc. you want to process in generateCandidates(). You also need to decide if you recurse into superclass or not. Implement logic that generates MethodDeclarations for readExternal/writeExternal methods using data collected in step 2. Wrap generated MethodDeclarations into an IWorkspaceRunnable that applies them as edits (see GenerateToStringOperation) and return it from createOperation(...). Register your new action to "Source" menu so it can be used The code required is rather lo

Categories : Java

`create` script for Cordova Android fails to create new project - errors with java/ant configuration
Actually, the problem here seems to be the incompatibility between your java version and Cordova's compiled jars. For a quick fix, it is better to install Java 1.5 and use it for your development. Don't forget to restore your changes in build.xml to 1.5.

Categories : Java

How to dynamically create and remove a complex div and get input inside it to create dynamic link and textarea?
you are removing the $div if you click on the save button. How shall it work then? $div.remove(); also, $div is a local variable of another function, make it globally available. var $div; and whithin your function, dont write var $div = but simply $div =

Categories : Jquery

Why will Qt not create a text file when running or debugging from inside Qt, but will create it when directly from the debug folder?
You probably used a relative path, and inside QtCreator the "current directory" from where the executable is ran is not necessarily the directory where the executable is. Try: qDebug() << QDir::currentPath(); It will tell you where you should expect your file to be written.

Categories : C++

Do I need to create a module for: A user account, to create and save custom "objects" made of choices from a form
Drupal is great for such a project. And you don't need too much extra modules, just core modules. 1) Core user module is fine. 2) Node type A. Create the node with the described fields and a user Role that will be able to add new A nodes as also as edit/delete own A nodes. 4) Node type B. Just add relationship for the Node type A so users can make the connection. Use the EntityReference module here. Similar user role permissions here. 6) This needs more information but it seems you need to use Views module to achieve this. 7) Welcome to Drupal! This is a core functionality also.

Categories : Forms

How to create a MySql Job to create a database backup and a maintenace plan?
one possible way is run the following as daily cron. mysqldump -u <db_user> -p <db_password> <db_name> -h <db_host_if_any> > /home/backups/backup_<timestamp>.sql gzip it and store it(just a mechanism to reduce size) gzip /home/backup/backup_<timestamp>.sql

Categories : Mysql

Is it possible to create user account for only can create IPA file but cannot delete or touch anything else?
Yes, you can do that. If the user is only a member, he can't change anything. Only admins and agents can create provisioning profiles etc. To create users, you have to have a company account.

Categories : IOS

Neo4j Create Unique using params to create nodes using WithParams
Solved my problem! i was parameterising the relationship, which is supposedly a big no no. this c# query worked var createDocType = _connectedClient.Cypher .Start(new {docType = docTypeCategory}) .CreateUnique("(docType) - [r:"+ IsDocumentationType.TypeKey+ "]-> (newDocType {possiblyNewDocoType})") .WithParam("possiblyNewDocoType", docoType) .Return<Node<DocumentationType>>("newDocType"); ```

Categories : Neo4j

I want to create a source file that calls a function without having to create an object
Just put int mergesort(int *, int, int); in the header and then call mergesort(a,0,9); from your main.cpp and you will be fine. I suppose that you come from a true object oriented language (such as Java) background, where everything needs to be an object. In C++ a standalone function is perfectly fine. There is also no need for the public and static keywords, since those pertain to classes. I strongly recommend that you read a C or C++ book. Look here.

Categories : C++

Create a select from existing or create new in a form Rails 3
You need: before_validation :create_org_from_name and def create_org_from_name self.name = new_organization_name if not new_organization_name.blank? end You don't want to do a create in your before_validation method.

Categories : Ruby On Rails

Should I let users create tables within the database or create views?
It depends on what you want to do with the data later and how much there will be. DBMS systems (such as MySQL) deal with large amounts of data very fast. You can also query the data in very sophisticated ways as opposed to your other choices. The trade-off is a little more complexity. I almost always come down on the side of a database solution. It gives you the most flexibility.

Categories : PHP

How to create a object/function with defined setting when create new?
You can check how many arguments the caller has provided. Or check for undefined values. function test(a, b) { // both ifs check b was not provided if (typeof b === "undefined") { } if (arguments.length == 1) { } } Your current functions probably won't work because you are returning from a callback. AJAX is (in most cases) asynchronous. So in your case, you have to add another argument for providing a callback. this.get = function (subject, callback) { $.ajax({ url: 'myurl', data: { id: id, class: class, subject: subject }, success: function (r) { callback(r); } }) } FYI, class is a reserved keyword by the ECMAScript specification.

Categories : Javascript

How to use javascript to create a custom window other than create a panel with Add-on SDK
Try this: Main.js[Content Script] var workers = []; var widget = widgets.Widget({ id: "my-link", label: "my-page", contentURL: self.data.url('mypage.ico')//, //emit the click event contentScript: 'self.port.emit('icon-click', 'icon clicked')' }); function detachWorker(worker, workerArray) { var index = workerArray.indexOf(worker); if(index != -1) { workerArray.splice(index, 1); } } var pageMod = require('sdk/page-mod').PageMod({ include: ['https://my-page.com'], //pass the click event to page Script contentScript: 'self.port.on("icon-click", function() {document.defaultView.postMessage({ action:"icon-clicked", msg: "my message", "https://my-page.com"}) })', onAttach: function(worker) { workers.push(

Categories : Javascript

Jquery - If parent has two or more children create ul else do not create ul
Try to replace $('.post_photo ul').has('li:nth-child(n+2)').addClass("photoset"); with this code : if (post.length == 2) { $('.post_photo ul').addClass("photoset") }

Categories : Jquery

Should you create new website or create virtual directories under it
If you create virtual directories, then all your "websites" will be running under 1 app pool. If one is hanging, they all hang. If you only have 1 IP, then if you don't use virtual directories, you'll have to assign each website a different port (can't all be using default port 80).

Categories : Asp Net

JFolder::create: Could not create directory in all pages
The 755 permission gives the group/others the read and execute permissions in the directory. This means, that non-group members cannot create new directories. Make sure that the owner of the directory is the user that the server is running as. To figure out which user that is, you can use: $ echo $(ps axho user,comm|grep -E "httpd|apache"|uniq|grep -v "root"|awk 'END {if ($1) print $1}') And if does not provide the desired result, simply explore the output of: $ ps aux | grep -E "httpd|apache" | grep -v -E "root|grep" You can find which group it belongs to by using: $ groups [userName] Next, change the owner of the joomla folder. I am using www-data as an example: # chown -R www-data:www-data path/to/your/joomla/root/dir PS, lines preceded by $ can be executed b

Categories : Joomla

Once we create trigger in php page then do we need to create same in Mysql?
Short answer - no, you don't have to because creating it in the code also creates it in MySQL. But you have bigger problems. Longer answer - Triggers are part of the database, and typically you wouldn't create a trigger from code. You would create triggers the same way you create tables - create them once in MySQL and they stick around until you drop them. Technically the code you have will work, but the CREATE TRIGGER statement will only succeed the first time it is called. In subsequent executions of that script the CREATE TRIGGER will error out because the trigger already exists. But since you aren't checking for errors, your script will probably continue on happily. Also, the way your trigger is made, it will always insert the same record into the details table that was insert

Categories : PHP

Difference between FactoryGirl.create and create
FactoryGirl allows you to have some default (that can be overridden) values for User in the factory or even generate values using Faker or similar. That being said, for fast tests in most cases you can use FactoryGirl.build_stubbed (or FactoryGirl.build) which doesn't save user in database. More info: https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md

Categories : Ruby On Rails

How can I to create a table and create 2 columns for each row on the fly
I would go with something like this: for ( ... each "gAssessorsArray" var time = arrayItem.Time; var cells = someCodeThatSplitsTime(time); // each "cell" would be a string // representing the cell content // i.e. "08:00 - 09:00" var table = $("<table />"); var row = $("<tr />"), col = 0; table.append(row); for ( ... each "cells" if (col == 2) { col = 0; row = $("<tr />"); table.append(row); } var chk = $("<input type='checkbox />'"); var span = $("<span />"); span.text(cell); // 08:00 - 09:00 var colEl = $("<td />"); colEl.append(chk); colEl.append(span); row.append(colEl); col++; }

Categories : Javascript

Rails controller create action difference between Model.new and Model.create
The Model.new method creates a nil model instance and the Model.create method additionally tries to save it to the database directly. Model.create method creates an object (or multiple objects) and saves it to the database, if validations pass. The resulting object is returned whether the object was saved successfully to the database or not. object = Model.create does not need any object.save method to save the values in database. In Model.new method, new objects can be instantiated as either empty (pass no construction parameter) In Model.new(params[:params]) pre-set with attributes but not yet saved in DB(pass a hash with key names matching the associated table column names). After object = Model.new, we need to save the object by object.save

Categories : Ruby On Rails

How do I create an index from a stored procedure or create index on every table in MySQL?
The core problem with your procedure was that PREPARE statement only works with a user variable or a string literal. It can't prepare a statement from a procedure variable. PREPARE Syntax PREPARE stmt_name FROM preparable_stmt ... preparable_stmt is either a string literal or a user variable that contains the text of the SQL statement. DELIMITER // CREATE PROCEDURE createModifiedIndex(t VARCHAR(256)) BEGIN DECLARE idx VARCHAR(256); DECLARE i INT; SET idx = CONCAT('idx_', t, '_modified_on'); SET i = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name = t AND index_name = idx); IF i = 0 THEN SET @makeIndexSql = CONCAT('CREATE INDEX ', idx, ' ON ', t, ' (modified_on);'); PREPARE stmt FROM @makeIndexSql; EXECUTE stmt;

Categories : Mysql

Groovy: CREATE VIEW from script fails with 'create view should be the first'
I dont know anything about Groovy. However, there are certain commands within SQL that should occur first. One of these is "create view". "GO" is a batch separator. So if you have multiple SQL statements that you are processing at one time, and one of them is "create view" it must be the first - or separated from the batch by "go". You may find this arbitrary, however there are good reasons behind this. In most cases its locking of objects and resources in general. Here is a discussion http://dba.stackexchange.com/questions/34654/sql-server-must-be-first-statement-in-query-batch-what-and-why The reason is probably bound up with how SQL handles the various objects and needs to maintain consistency across transactions and the like. You get many very good things with MS SQL, but there are som

Categories : Sql Server

How do I create a new scale() function in d3.js? I would like to create a cumulative distribution function
This is an example how we can add new functionality in d3.scale.liner(). For null values my function returns null (d3.scale.liner() returns 0 in this case). The primary approach is to wrap the original scale and all his methods. I didn't test this function for all cases. But for basic functionality it's working. Unfortunately I didn't found easier way to do it :( /** * d3.scale.linear() retrun 0 for null value * I need to get null in this case * This is a wrapper for d3.scale.linear() */ _getLinearScaleWithNull: function() { var alternativeScale = function(origLineScale) { var origScale = origLineScale ? origLineScale : d3.scale.linear(); function scale(x) { if (x === null) return null; //this is the implementation of new behaviour return

Categories : D3 Js

How to create unpublished page post for video using Ads api and what are the params required for create video unpublished pagepost?
Change service call from ← https://graph.facebook.com/ to ← https://graph-video.facebook.com/ then it will Works fine

Categories : Facebook

Create a TRIGGER to create a TRIGGER when a table is created
You cannot set triggers on tables in the information_schema database. Can you please provide a citation? – mbrownnyc http://dev.mysql.com/doc/refman/5.1/en/information-schema.html MySQL 5.1 Reference Manual Chapter 20. INFORMATION_SCHEMA Tables Usage Notes for the INFORMATION_SCHEMA Database INFORMATION_SCHEMA is a database within each MySQL instance, the place that stores information about all the other databases that the MySQL server maintains. The INFORMATION_SCHEMA database contains several read-only tables. They are actually views, not base tables, so there are no files associated with them, and you cannot set triggers on them.

Categories : Mysql

When to CREATE TABLE AS SELECT versus CREATE TABLE LIKE?
These do different things. CREATE TABLE LIKE creates an empty table with the same structure as the original table. CREATE TABLE AS SELECT inserts the data into the new table. The resulting table is not empty. In addition, CREATE TABLE AS SELECT is often used with more complicated queries, to generate temporary tables. There is no "original" table in this case. The results of the query are just captured as a table. EDIT: The "standard" way to do backup is to use . . . . backup at the database level. This backs up all objects in the database. Backing up multiple tables is important, for instance, to maintain relational integrity among the objects. If you just want a real copy of a table, first do a create table like and then insert into. However, this can pose a challenge with au

Categories : Mysql

create unique node or create unique index
I'm assuming this is for the stable version of neo4j(1.9) as 2.0 does change how indexing is presented. You're saying your User Node will have several properties, each unique, will these be used as a composite key, or will just the UserName be used as a Key? Neo4j has a special class for doing a type of "get or create" node, but it only works on one key, so if you were creating a composite key, you'd have to do something like concatenate yours keys. Look for the documentation here. Here is an example: public Node getOrCreateUserWithUniqueFactory(String username, GraphDatabaseService graphDb) { UniqueFactory<Node> factory = new UniqueFactory.UniqueNodeFactory(graphDb, "users") { @Override protected void initialize(Node createdNode, Map<String, Object> pr

Categories : Neo4j

when we create any objecet why we need to create base class of one class and instance of another class?
This is needed to not tie code to an implementation. This makes the application resistant to changes i.e. you don't have to refactor your entire application to incorporate new changes because you are coding to an interface and not to an implementation. Also inheritance provide code reusability by avoiding duplication.

Categories : C#

Create in class validation code OR create a validation class?
A third possible way is to use extension methods - I personaly like this, as it is as easy to use as the first one, but still seperates the logic: public class Person { string Name { get; set; } } public static class Validation { public static void ValidateName(this Person person) { if(person.Name.Contains("0", ..., "9")) throw new Exception("Name can't contain numbers.") } } As mentioned this can be used like: var person = new Person() { Name = "Test123" }; person.ValidateName(); P.S.: I renamed People to Person as it looks to me as it will hold one person and not multiple people - just ignore that if I am wrong on that...

Categories : C#

Create row with every CSV value
If you don't want use CTE or loops, try use approach with additional table of numbers: See http://www.sommarskog.se/arrays-in-sql-2000.html#tblnum-core Something like: CREATE FUNCTION inline_split_me (@param varchar(7998)) RETURNS TABLE AS RETURN(SELECT substring(',' + @param + ',', Number + 1, charindex(',', ',' + @param + ',', Number + 1) - Number - 1) AS Value FROM Numbers WHERE Number <= len(',' + @param + ',') - 1 AND substring(',' + @param + ',', Number, 1) = ',')

Categories : SQL

create c# dll which can be used from both c# and c++
You may want on creation of COM component: Create COM component and ActiveX controls in .Net If you are developing in Windows8, you may think of creation Windows Component: Creating Windows Runtime Components in C#

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.