2018-10-22         Rock

Should I put folder .bundle under version control

I just started using bundler with rails 2.3.8. After running bundler install there is folder .bundle at the root of my project.Should I put .bundle under version control? I'd leave that out of version control. In general, adding generated files is bad - especially if they might have misleading information when someone else checks out the code. That would definitely be true in this case. [XXX]

 ruby-on-rails                     1 answers                     17 view
 2018-10-22         Rock

R: Parse date as year/quarter

I have a dataframe that looks like thisClasses ‘tbl_df’, ‘tbl’ and 'data.frame': 344479 obs. of 6 variables: $ REGION : chr "NSW1" "NSW1" "NSW1" "NSW1" ... $ SETTLEMENTDATE: POSIXct, format: "1998-12-07 02:00:00" "1998-12-07 02:30:00" "1998-12-07 03:00:00" "1998-12-07 03:30:00" ... $ TOTALDEMAND : num 3294 5337 5296 5266 5330 ... $ RRP : num 8.01 11.16 13.52 12.52 13.01 ... $ PERIODTYPE : chr "TRADE" "TRADE" "TRADE" "TRADE" ... $ month : num 12 12 12 12 12 12 12 12 12 12 ...I am attempting to create a year_quarter variable that is a str...

 r                     1 answers                     76 view
 2018-10-22         Rock

Can I append to a file using binary's Data.Binary?

I've got a [Something] value, I'd like to save this value to disk every n seconds.However this value could have a large number of elements, and writing the complete value each time could potentially cause unnecessary disk wear. Therefore, I'm looking to append to a file instead.The list itself ([Something]) would always be appended to, and wouldn't have it's 'original' content modified in any way.Is it possible to use Data.Binary for this purpose?I did find the append(http://hackage.haskell.org/package/binary-0.8.6.0/docs/Data-Binary-Builder.html#v:append) function, but thi...

 haskell                     1 answers                     8 view
 2018-10-22         Rock

Module.exports and require confusion

I am taking Stephen Grinders MERN course on Udemy. There are three files in the course. My understanding of node modules is that it runs independently, which is why we need to import everything that the module needs inside the module. My question is:Why is it that in authRoutes.js file we do not need to import the passport.js file? We are using passport.authenticate function is authRoutes.js file it is not configured in the module.index.jsconst express = require('express');require('./services/passport')const app = express();require('./Routes/authRoutes')(app);const PORT = p...

 node.js                     1 answers                     90 view
 2018-10-22         Rock

TypeError at /admin/auth/user/

I get such an error when I try to delete a user from admin panel TypeError at /admin/auth/user/ 'bool' object is not callablemodels.pyclass PROFILE(models.Model):kullanıcı = models.OneToOneField(User,on_delete=True)birthday = models.DateField(verbose_name="Birthday", blank=False,null=False)gender = models.CharField(max_length=15, blank=False,null= False,choices=gender)language = models.CharField(max_length=20, blank=False,null=False, verbose_name="language",choices=languages)def set_token(s...

 django                     1 answers                     76 view
 2018-10-22         Rock

How to minify only specified file/part of page using PHP

How I can use this function to skip specified files and not minify them?Minifier:function sanitize_output($buffer) { $search = array( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s', '/<!--(.|\s)*?-->/' ); $replace = array( '>', '<', '\\1', '' ); $buffer = preg_replace($search, $replace, $buffer); return $buffer;}ob_start("sanitize_output");HTML:// this file contains above minifierinclude($_SERVER['DOCUMENT_ROOT'].'/include-minifier.php');// should be minified<p style='display: block'>custom text</p>// do not minif...

 php                     1 answers                     5 view
 2018-10-22         Rock

VueJS 2 does not report any errors (Sentry.io)

I have a Laravel (5.4) application with VueJs2 (2.1.10). I am using Sentry.io as error reporting for our Backend which works fine. When an error occurred from VueJs I am unable to catch it nor send it to Sentry.Here is the documentation which I used to install Sentry through NPM according to the Raven settings: https://docs.sentry.io/clients/javascript/integrations/vue/ My config in app.js is the following:import Raven from 'raven-js';import RavenVue from 'raven-js/plugins/vue';Raven .config('https://[filtered]@sentry.io/[filtered]') .addPlugin(RavenVue, Vue) .inst...

 vuejs2                     1 answers                     55 view
 2018-10-22         Rock

Arguments to JavaScript Anonymous Function

for (var i = 0; i < somearray.length; i++){ myclass.foo({'arg1':somearray[i][0]}, function() { console.log(somearray[i][0]); });}How do I pass somearray or one of its indexes into the anonymous function ?somearray is already in the global scope, but I still get somearray[i] is undefined The i in the anonymous function captures the variable i, not its value. By the end of the loop, i is equal to somearray.length, so when you invoke the function it tries to access an non-existing element array.You can fix this by making a function-constructing function ...

 javascript                     5 answers                     91 view
 2018-10-22         Rock

How to add where condition if result count is greater than one

I want to build SQL query that returns unique id.My problem is that i need to add another condition to query if i have more than one result.select u.idfrom users uwhere u.id in ('1','2','3')and u.active = 'Y'if i get more than one result i need to add:and u.active_contact = 'Y'I tried to build this queryselect * from (select u.id, count(u.id) as resultsfrom users uwhere u.id in ('1','2','3')and u.active = 'Y'group by u.id) tabIf(tab.results > 1) then where tab.u.active_contact = 'Y'endThanks in advanced.Hope i explained my self good enough. Here's a different appro...

 sql                     3 answers                     84 view
 2018-10-22         Rock

$lookup for each element in array mongo aggregation

I have users schema with people field containing viewers property which contains an array of ObjectIds as a reference of users collection itself for example{ "username": "user1", "password": "password", "email": "user1@gmail.com", "people": [{ "id": 1, "viewers": ["ObjectId....", "ObjectId...."] }, { "id": 2, "viewers": ["ObjectId....", "ObjectId...."] } ]}What I need to do is $lookup for each element inside viewers the problem is when I use below pipeline is pushing the same viewers for each do...

 mongodb                     1 answers                     51 view
 2018-10-22         Rock

How to delete a @ManyToOne @NotNull reference?

Assume I have an Entity0@Entitypublic class Entity0 implements Serializable { @Id private Long id; @ManyToOne @NotNull private Entity1 entity1; public Entity0() { } public Entity0(Long id, Entity1 entity1) { this.id = id; this.entity1 = entity1; } [getter and setter for id and entity1]}which references Entity1@Entitypublic class Entity1 implements Serializable { @Id private Long id; @Basic private String property0; public Entity1() { } public Entity1(Long id, String property0) { th...

 validation                     2 answers                     62 view
 2018-10-22         Rock

C#: Creating a new FileInfo in a directory that you have the DirectoryInfo of

I was just wondering when you have for example:var dir = new DirectoryInfo(@"C:\Temp");Is there an easier/clearer way to add a new file to that directory than this?var file = new FileInfo(Path.Combine(dir.FullName, "file.ext"));I'm thinking I can probably just make an extension method or something, but curious if something already exists that can't see here... I mean the DirectoryInfo does have GetFiles() method for example. What is it that you want to do? The title says "Creating a new file". A FileInfo object is not a file; it's an object holding information about a fi...

 c#                     3 answers                     25 view
 2018-10-22         Rock

Issue while using VPN with Web API

We have web api application in which we have used SQL database on cloud. To connect to a azure cloud we are using company's VPN.When we are connect to VPN and try to debug the Web API locally it gives the following error. an error occurred attempting to determine the process id of dotnet.exe which is hosting your application. One or more errors occurred.But if we disconnect from VPN and try to debug Web API then we are able to do it.Below is the url which we are using in local environment for debugging.https://localhost:44374/swagger/index.htmlWe have kept Enable SSL = Tr...

 c#                     2 answers                     68 view
 2018-10-22         Rock

Creating "zero state" migration for existing db with sqlalchemy/alembic and "faking" zero migration for that existing db

I want to add alembic to an existing ,sqlalchemy using, project, with a working production db. I fail to find what's the standard way to do a "zero" migration == the migration setting up the db as it is now (For new developers setting up their environment) Currently I've added import the declarative base class and all the models using it to the env.py , but first time alembic -c alembic.dev.ini revision --autogenerate does create the existing tables. And I need to "fake" the migration on existing installations - using code. For django ORM I know how to make this work, but ...

 python                     1 answers                     39 view
 2018-10-22         Rock

how to compress the image before uploading to s3 in django?

I am working on an application where a user can upload an image. I want to reduce the size of the image in 200-500kb.This is my models.py file class Report_item(models.Model): owner = models.ForeignKey(settings.AUTH_USER_MODEL) title = models.CharField(max_length=255, help_text='*Title for the post e.g. item identity') image = models.ImageField(default="add Item image", upload_to=get_uplaod_file_name) def __str__(self): return self.title + " " + str(self.publish)And this is my views.py file class ReportCreate(generic.CreateVi...

 python                     1 answers                     103 view
 2018-10-22         Rock

Please clarify my mistake while doing the dry run

The following code is all correct but I have a doubt. While I am doing the dry run I find in my mind that it should show 2 as NOT a prime number. Someone please clarify how the code is running all good. num = 4if num > 1: for i in range(2,num): if (num % i) == 0: print(num,"is not a prime number") print(i,"times",num//i,"is",num) break else: print(num,"is a prime number")else: print(num,"is not a prime number") 2 is a prime number, but your code will shows 2 as not a prime numberHere is the fix:num = 4if num > 2: fo...

 python                     1 answers                     55 view

Page 1 of 146  |  Show More Pages:  Top Prev Next Last