2018-10-22         Olive

Rails PostgreSQL sort by integer value of string

I made a strategic mistake when developing database architecture on my Rails appNow I have to implement sorting by price feature using MyModel.order('price DESC')price is a string type in the database, which cause 50 to be greater than 2000 for exampleAre there any ways to implement such .order() without changing database structure?EDIT:I switched to correct type (integer) for price column. It took me an hour only to refactor. With PostgreSQL you will want to cast your string to integer/float/decimal (after you decide you 100% will not go and change the column type to co...

 ruby-on-rails                     1 answers                     83 view
 2018-10-22         Olive

Change payment gateway option based on cart total in Woocommerce checkout

For my woocommerce shop, i have this filter in functions.php. It force 3DS with "woocommerce Stripe Gateway" plugin.add_filter('wc_stripe_require_3ds','__return_true');It work great.I would like this filter to be active only for order over 50€.I tried with this but it doesn't work, the order is validated without 3DS. $minsecure = 50; $order = new WC_Order( $order_id ); $total = $order->get_total(); if($total>$minsecure) { add_filter('wc_stripe_require_3ds','__return_true'); }I also try to get the cart amount instead of the order amount, but I ...

 php                     1 answers                     83 view
 2018-10-22         Olive

FOR loop parameter changes its reading position

I want to loop through File_1 and check the fourth column. If it's not empty write in File_2.Here is Files_1:1;2;3;;;;;;;101;2;3;4;;;;;;101;2;3;;5;;;;;10Here is my batch file:for /F "delims=; tokens=1-10" %%A in (File_1.txt) do ( if "%%D" NEQ "" ( echo hello World %%D >>File_2.txt ))Here is what comes in File_2:hello World 10 hello World 4 hello World 5 How come that it doesn't always read in the fourth column? The result that I was expecting is:hello World 4How can I manage to have this result? As your question was answered in the comments, and a solu...

 batch-file                     1 answers                     95 view
 2018-10-22         Olive

Using NSManagedObject manually - something wrong with the NSManagedContext I get?

I'm new to Cocoa programming, and decided for my first project to create a small application to monitor and remember certain battery stats for my laptop. (I have it plugged in most of the time, and apple recommend you discharge it now and again, so why not try to make a small program to help you remember to do this? :))Anyway, I have a standard Objective-C project, with a DataModel file.It contains an Entity, BatteryEvent, with properties, charge and event.I then have PowerListener.m (and .h).PowerListener.m is implemented as follows: @implementation PowerListenervoid my...

 objective-c                     1 answers                     47 view
 2018-10-22         Olive

Django REST framework post array of objects

I am using Django REST framework for API and Angular SPA with Restangular for comunication with the API. Sometimes I have to add more than one objects for adding and I think that I can send them together in array and make one request.When I try to do this from the Restangular I recive error for Wrong input. If I try to add more then one object from the REST framework web interface I am passing objects or array of objects:// this { "text": "gdhg", },{ "text": "gdhg", },{ "text": "gdhg", }// or this [{ "text": "gdhg", },{ "text": "gdhg", },{ "text": "gdhg", }]But I receive P...

 django                     4 answers                     22 view
 2018-10-22         Olive

Communicate multiple times with a process without breaking the pipe?

It's not the first time I'm having this problem, and it's really bugging me.Whenever I open a pipe using the Python subprocess module, I can only communicate with it once, as the documentation specifies: Read data from stdout and stderr, until end-of-file is reachedproc = sub.Popen("psql -h darwin -d main_db".split(),stdin=sub.PIPE,stdout=sub.PIPE)print proc.communicate("select a,b,result from experiment_1412;\n")[0]print proc.communicate("select theta,zeta,result from experiment_2099\n")[0]The problem here is that the second time, Python isn't happy. Indeed, he decided to ...

 python                     4 answers                     65 view
 2018-10-22         Olive

pygame input and image

I am new to pygame and i am having a problem with something i am working on. f=input('blahblablb')if f =='badafd': x=input'ajdfkladjsl'elif f ==...so i have this input and variable but later when i use the variablesclass A(pygame.sprite.Sprite):i made a class and had the code in it for an image and it appeared finei also put it in a group and it appeared fine later i addedif f=='badafd': all_sprites_list.add[A]but the image appears even though f does not equal badafd please tell me the problem and i will include the main loop because that might be the problemwhile Tru...

 python-3.x                     1 answers                     75 view
 2018-10-22         Olive

Element from loaders list should have 'loader' or 'loaders' with sass-loader webpack

I have this loader in my webpack loader array:{ test: /\.scss$/, exclude: /node_modules/, loaders: ExtractTextPlugin('style-loader', 'css-loader!sass-loader') }I am trying to have webpack build my SCSS to CSS but I am getting this error:/Users/bli1/Development/Django/CL/cherngloong/cherngloong/cherngloong/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:60 throw new Error("Element from loaders list should have one of the fields 'loader' or 'loaders'"); ^Error: Element from loaders list should have one of the fields 'loader' or 'loaders' at getLoade...

 sass                     1 answers                     40 view
 2018-10-22         Olive

How can I do a WHERE clause across 2 rows?

store_i tablestore_id, open_247996, 0 store_period tablestore_id, day, opentime, closetime996, 3, 00:00:00, 04:00:00996, 3, 08:00:00, 23:59:59996, 4, 00:00:00, 04:00:00996, 4, 08:00:00, 23:59:59In PHP I'm determining the current time, current day, time 30 minutes from now, and the day 30 minutes from now:currenttime: 23:42:01currentday: 3timeplus30: 00:12:01dayattimeplus30: 4I'm trying to determine whether a store is open now and will be open in 30 minutes.For the example data above, the store_id 996 should be considered open because of rows 2 and 3 of store_period.I want ...

 mysql                     1 answers                     36 view
 2018-10-22         Olive

My final mysql db, could someone check if the tables are correctly made?

I have these tables:category table:cat_id (PK)cat_namecategory_options table:option_id (PK)cat_id (FK)option_nameoption_values table:value_id (PK)option_id (FK)valueclassifieds table:ad_id (PK) (VARCHAR) something like "Bmw330ci_28238239832"poster_id (FK)cat_id (FK)headlinedescriptionpriceetc....posters table:poster_id (PK)name emailtelpasswordetc....Three main questions:1- Is the above good enough? It covers all my needs atleast... 2- Sometimes when I try out different queries, I get strange results... Could you write a PHP query string which will fetch one complete ad fro...

 php                     2 answers                     55 view
 2018-10-22         Olive

Find a certain column name in all views in one select statement

I'm searching for a certain column name in all views. I know that the following works for all tables but don't know how to do it for all views:What I use to find a column_name='SHORT_TITLE' in all tables but now need to search all views:SELECT table_name, column_name FROM all_tab_columns WHERE column_name='SHORT_TITLE'Thanks Oracle:Joining all_tab_columns with all_viewsSELECT table_name, column_nameFROM all_tab_columns, all_viewsWHERE all_tab_columns.table_name = all_views.view_nameAND column_name = ...Result of table_name will only be viewsSQL:We can do this by joining ...

 view                     1 answers                     99 view
 2018-10-22         Olive

SQL Server 2008 web management scripts?

does anyone know what SQL Server 2008 management scripts exists (except myLittleAdmin)?ThanksClarification: I'm looking for web based management script (which supports SQL Server 2008) other than myLittleAdmin. SeeSomething like phpMyAdmin but for SQL Server?Free or open source .Net database view/edit tools like phpMyAdmin [XXX]

 sql-server-2008                     1 answers                     12 view
 2018-10-22         Olive

PyQt: inheriting from PushButton

I'm working on an existing project and I have very little experience with PyQt so I'm not sure what I would need to produce a minimal working example here, maybe someone can help me out anyways.There is a part in the code where a QPushButton is created and added to a QGraphicsScene, like this:b = QPushButton('foo')scene.addWidget(b)I'd like to replace b with a class inheriting from QPushButton, something like:class Bar(QPushButton): def __init__(self): super(Bar, self).__init__('foo')I believe that the following should then behave identical to the first code sampl...

 python-3.x                     1 answers                     42 view
 2018-10-22         Olive

How to find nearest points using latitude and longitude from a DocumentDB collection?

I'm using Microsoft's DocumentDB to store locations of hundreds and thousands of geographic locations in the UK. A document from the database collection looks like the following. { "CommonName": "Cassell Road", "CommonNameLang": "en", "Street": "Downend Road", "StreetLang": "en", "Indicator": "SW-bound", "IndicatorLang": "en", "Bearing": "SW", "LocalityName": "Fishponds", "ParentLocalityName": "Bristol", "Easting": 364208, "Northing": 176288, "Longitude": -2.5168477762, "Latitude": 51.4844052488, },What type of DocumentDB query could...

 azure                     1 answers                     31 view
 2018-10-22         Olive

I have an issue with pdftron integration

I have an issue with pdf tron sdk integration I 've tried alone and that did not worked so i tried to run one of their samples but I ve always had 5 failed to resolve file error. They're documentation is not easy to read AND I did not undersand how to integrate their sdk via gradle or manually (I ve tried both). So If some one Had fully integrated their sdk I hope if they could send me a git hub repositorie or help with my issue.ps : I am on android studio 3.0.1this is a screenshot: the error To get the project running, you need to click Build -> Clean Project as describ...

 android                     1 answers                     35 view
 2018-10-22         Olive

How Do I make an Activity with a Relative Layout, a Framelayout, NavigationBarLayout, scrollable in Android Studio?

I want to make my Activity scroll able but only the Framelayout. I'm using fragments, a Toolbar and a BottomNavBar and the FrameLayout is between the BottomNav and the Toolbar.main menu<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/container"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/MainGreen"tools:context=".mainmenu"><include ...

 android                     4 answers                     99 view

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