Posts

Showing posts from June, 2013

C# JSON Get specific attribute with multiple roots -

so basically, building c# application retrieve specific values url. url url scrape the attributes need grab are: 'id', 'size', 'instock' , 'ats' each different size of product. example i have tried code this url no luck. string data = client.downloadstring(region).replace("\n", "").replace("\r", "").replace(@"\", "").replace("\t", ""); dynamic dynobj = jsonconvert.deserializeobject(data); var somevar1 = dynobj["variants"]["by1910_530"][1]["id"].tostring(); messagebox.show(somevar1); please try (as using jsonconvert, assume you've got newtonsoft.json nuget package): var client = new httpclient(); string json = await client.getstringasync(@"http://www.adidas.co.uk/on/demandware.store/sites-adidas-gb-site/uk_uk/product-getvariants?pid=by191"); var jobj = jobject.parse(json); console.writeline(jobj["variatio

php - Laravel upload file in different folder -

public function upload(request $request){ $user = user::findorfail(auth()->user()->id); $filename = time() . '.jpg'; $filepath = public_path('uploads/'); move_uploaded_file($_files['filename']['tmp_name'], $filepath.$filename); move_uploaded_file($_files['filename']['tmp_name'], public_path('uploads/newfolder').$filename); echo $filepath.$filename; } how can upload same image different folders. have tried above code , doesn't work in other folder. you can't run move_uploaded_file twice same file because name says, moves file, on second run, original file won't exist anymore. you must copy file: public function upload(request $request){ $user = user::findorfail(auth()->user()->id); $filename = time() . '.jpg'; $filepath = public_path('uploads/'); move_uploaded_file($_files['filename']['tmp_name'], $filepath.

python - How to update Celery Task ETA? -

i building simple waiting list app in django 1.10.3 using celery 4.1.0. i have following base tasks: @shared_task def start_user_counter(): logging.info('task executed @ {}'.format(datetime.datetime.utcnow())) # task executed when user reaches top of queue. # send email, perform other stuff in here ... @shared_task def update_queue(): curr_time = datetime.datetime.utcnow() logging.info('task called @ {}'.format(curr_time)) time_to_exec = curr_time + datetime.timedelta(seconds=10) # here, perform checks if task exists in redis # if not exist - create new 1 , store redis # if exist - update task's eta. task_id = start_user_counter.apply_async(eta=time_to_exec) logging.info('task id: {}'.format(task_id)) # ... update_queue.delay() each task represents 1 user on waiting list. new user assigned eta when suppose removed waiting list (he reached top @ eta). however, each user has possibility speed time whe

python - SARIMA model gave different results in Windows and macOS -

i've used sarima() in statsmodels.api forecasting on mac while , need switch work windows8. used same script, run in same ide(pycharm) , assuming python libraries used in project should samely installed. however, prediction got get_prediction() on fitted model different in part of data , different in of them. wonder if else encounter same problem?? i'd appreciate comment or advise! wiki

java - How to set my request focus event listener thread safe? -

i m using the focus event listener implement placeholder solution jtextcomponents (jtextfield, jtextarea ...) implementation below public class placeholderdecorator { public static void decorate(jtextfield field, string placeholdingtext) { field.setforeground(color.gray); field.addfocuslistener(new focuslistener() { @override public void focusgained(focusevent e) { if (field.gettext().equals(placeholdingtext)) { field.settext(""); field.setforeground(color.black); } } @override public void focuslost(focusevent e) { if (field.gettext().isempty()) { field.setforeground(color.gray); field.settext(placeholdingtext); } } }); } public static void decorate(jtextfield field, string placeholdingtext,color placeholdercolor,color textcolor) { field.setforeground(placeholdercolor); field.addfocuslistene

c# - Pull data from two linked tables to one View in MVC5 -

i have 2 tables associated many-to-many. menu table , ingredients table. want show ingredients based on menu item selected. i created tables , made connect multiple multiple. created initializer , context. inventoryinitializer.cs using inventorymanagementsystem.models; using system; using system.collections.generic; using system.linq; using system.web; using static inventorymanagementsystem.models.ingredient; namespace inventorymanagementsystem.dal { public class inventoryinitializer : system.data.entity.dropcreatedatabasealways<inventorycontext> { protected override void seed(inventorycontext context) { var ingredients = new list<ingredient> { new ingredient {name = "cheese", quantity = 20, cost= 2.5, category = ingredienttype.dairy}, new ingredient {name = "ham", quantity = 15, cost= 4.0, category = ingredienttype.protein }, new ingredient {name = &quo

javascript - How do I refresh a page if a field width changes? -

i'm trying edit page on knack allows js modifications in combination css formatting. change made lock header on each page uses excel format. seems break when user changes number of rows in drop down selection or navigates next page. i'm sure there few ways thought easiest way manage @ first row's style , refresh page if minimum width less desired length. if first entry in header not xxx amount of pixels, reload page using window.location.reload(); or similar. here example of js: $( document ).on ('knack-page-render.any', (function(event, view, data) { var $table = $('#view_60 > table'); var $bodycells = $table.find('tbody tr:first').children(); var newwidths = []; var colwidth = $bodycells.map(function(index, val) { /* debug message*/ //console.log("index: " + index + ". value=" + $(this).width()); return $(this).width(); }).get(); var $headercells = $table.find('thead tr').chi

linux - Multiple httpd processes running in Docker Container -

this dockerfile created installing httpd on centos : #installing httpd centos:latest maintainer xxx@gmail.com run yum install -y httpd expose 80 #entrypoint ["systemctl"] entrypoint ["/usr/sbin/httpd"] after building, when run container can see many httpd process running inside container: docker run -d -p 80:80 httpd:4.0 -dforeground output of docker top command: uid pid ppid c stime tty time cmd root 2457 2443 0 04:26 ? 00:00:00 /usr/sbin/httpd -dforeground apache 2474 2457 0 04:26 ? 00:00:00 /usr/sbin/httpd -dforeground apache 2475 2457 0 04:26 ?

php - Displaying Only the Items in the Cart? -

so need display items added on vend page , in cart array on onto cart page in list array ( [cart] => array ( [brb] => 1 ) ) here code cart page i'm working on: if (isset($_session['cart'])) { foreach ($vend $vendid => $items) { //if (array_search($vendid, $_session['cart'])) { echo "<article class ='cart' id='cart-$vendid'>"; echo "<h1 class = 'item-h1' id = 'h1'>{$items['title']}</h1>"; echo "<div class ='item-no'>"; echo "<p class = 'pro-id'><b>product id: </b>{$vendid}</p></div>"; echo "<div class ='img-div'>"; echo "<img src =../images/{$items['img']} alt='' height='196' width='200'></div>"; echo "<div class='pricing'>"; echo "<p><b>

java - Select to constructor OneToMany relationship in QueryDsl -

i want select elements database using querydsl. final quserentity user = quserentity.userentity; new jpaquery<userresponse>(em) .select(projections.constructor(user.class, user.id, user.name, projections.constructor(addressresponse.class, user.address.id, user.address.name), user.pets)) .from(user).fetch(); i want use constructor in user: public userresponse(final string id, final string name, final addressresponse address, set<pets> pets) { this.id = id; this.name = name; this.address = address; this.pets = pets; } the user , address works fine, don't know how handle pets, onetomany-entity , set of entities. 'pets' has following relation in user: @onetomany(fetch = fetchtype.lazy) @joincolumn(name = 'petid', referencedcolumnname = 'petid') private set<pet> pets; however, when try run following error:

Converting WSDL to java for android KSOAP2 -

i spent 2 days researching this, seems soap not recommanded on android , there no suite of tools. still, integrated project asked me convert wsdl file java use ksoap2 on android. the thing found http://easywsdl.com/ able want, employer not pay stuff , don't want me use web based service (no 1 beside allowed @ our wsdl) it's dead end. i found 2 other converter haven't been updated in years , seems work basic wsdl, i'm far beyond scope. https://github.com/spectrofinance/ksoap2-generator https://github.com/masc3d/wsdl2ksoap2-android do of know tool this? thanks. wiki

c++ - Is always the address of a reference equal to the address of origin? -

this looks basic topic important me. the following example shows address of reference variable equal address of original variable. know can expect concept of c/c++. however, always guaranteed these addresses equal under circumstance? #include <iostream> #include <vector> #include <string> class point { public: double x,y; }; void func(point &p) { std::cout<<"&p="<<&p<<std::endl; } int main() { std::vector<point> plist; plist.push_back({1.0,4.0}); plist.push_back({10.0,20.0}); plist.push_back({3.0,5.0}); plist.push_back({7.0,0.4}); std::cout<<"&plist[2]="<<&plist[2]<<std::endl; func(plist[2]); return 0; } result: &plist[2]=0x119bc90 &p=0x119bc90 unfortunately, many people confuse logical , physical meaning of c++ references. logical level there crucial thing found myself c++ references: as have initialized ref

azure powershell - Remove-AzureRmSqlDatabase keeps asking me to run LoginAzureRmAccount -

i have azure sql database want delete. command should be: remove-azurermsqldatabase -resourcegroupname $dbresourcegroup -servername $dbservername -databasename $dbtodelete -whatif -force the error keep getting remove-azurermsqldatabase : run login-azurermaccount login. i tried running login-azurermaccount myself, service principal use unattended scripts, , nothing worked. i able log azure rm portal , delete databases. able run invoke-sqlcmd against database query , manipulate data. how can make work? according error message, seems have not login azure whit right subscription. we can use command sql database's information, , check subscription. (get-azurermsqldatabase -databasename jasontest1 -servername jasontest -resourcegroupname jasontest).resourceid then can find subscription in powershell output. ps c:\users> (get-azurermsqldatabase -databasename jasontest1 -servername jasontest -resourcegroupname jasontest).resourceid /subscriptions/538

excel - Use id from parent table when importing child table in MySQL -

i have parent table, city, has 2 columns id , name in database, uploaded through '.csv' file, in format: id | name 1 | karachi 2 | hyderabad i have excel file has data in following format: city | sector karachi | jamshed town karachi | gulshan 13-d hyderabad| sarfaraz colony i want import data of sectors columns city_id, sector city table , not city name. how can id parent table. (since data in thousands in couple of files don't prefer writing formulas in excel) to honest, import city table excel , use vlookup() function map cities' id sectors , import sectors mysql after that. the other solution create table in mysql has city name , sector fields, , import sectors dataset table. can use insert ... select ... statement populate original sector table city id , sector: insert sector (city_id, sector) select id, sector city inner join sector_with_c_name s2 on city.name=s2.city wiki

c# - Keep alive on shared server support -

i have followup question this one. so, i'm using hangfire run recurring jobs dummy webform on shared server (somee.com). discovered iis goes idle in x minutes, jobs never executed (i mean executed when iis active). so, there way keep alive? shared server don't have access configuration. i've read having service ping website trick. i've tried uptimerobot didn't have luck. still goes sleep... any ideas? so, managed solve it. asked on hangfire forums , did it. here's link post: https://discuss.hangfire.io/t/keep-alive-on-shared-server/3723 tl;dr: basically, i'd tried ping , http requests uptimerobot , didn't work me. did keyword requests. , have windows scheduler simulated service. :) visit hangfire forums details. wiki

jquery - Issue appending newly changed variable and outputting with Javascript -

i have issue following code. i trying change content of variable if button clicked , output corresponding content part of larger output. output varies depending on if inner button within form clicked. can suggest fix code or improvements? in output should see longer version block appended on newly created block , grab new id values generated. great. here code: <script> $(document).ready(function() { var currentid = 1; $(':button#add').on('click',function() { currentid++; var clone = $('#content').clone(); clone.children('.content_title').attr('id', 'title_content-' + currentid); clone.children('.content_more').attr('id', 'more_content-' + currentid); clone.attr("id", "content_1"); clone.insertafter('#content'); if(currentid >= 2) { document.ge

ModX if statement in a parameter -

i new modx revolution, , can't figure out. need show pages parent url (e.g. clinic=21) , if no clinic set set parents list. i've got this: [[!getpage? &elementclass=`modsnippet` &element=`getresources` &parents=[[!if? `[[!searchfieldclinic? &field=`clinic`]]`=`` &then=`127,106` &else=`[[!searchfieldclinic? &field=`clinic`]]`]] ]] but if returns 127,106,70,76,83,93,92,99,113,120,134,148,155,162,169,176,704,975,183 what doing wrong? in advance figured out myself, :) [[!getpage? &elementclass=`modsnippet` &element=`getresources` &parents=[[!if? &subject=`[[!searchfieldclinic? &field=`clinic`]]` &operator=`eq` &operand=`` &then=`127,106,70,76,83,93,92,99,113,120,134,148,155,162,169,176,704,975,183` &else=`[[!searchfieldclinic? &field=`clinic`]]` ]] ]] wiki

javascript - Window onmessage/message event does not work in IE -

i trying data external window of messageevent of java script. function damcallback() { var callbackurl = 'url redirected'; var mywindow = window.open(callbackurl, "select content", "width=750,height=550"); // create ie + others compatible event handler var eventmethod = window.addeventlistener ? "addeventlistener" : "attachevent"; var eventer = window[eventmethod]; var messageevent = eventmethod == "attachevent" ? "onmessage" : "message"; // listen message child window eventer(messageevent, function(e) { var datareceived = json.parse(e.data); var imageid = datareceived.data[0].assetid; alert(imageid); if (datareceived) { mywindow.close(); } else { console.log("looks have not received data. here data " + datareceived + " "); } }, false); } this working fine in both chrome , firefox. failed work in ie. reason not work on ie? i h

javascript - ES6 Modules not importing as expected in React -

i've been having issue importing react class container my file organization follows: ├── components │ ├── header │ │ ├── header.js │ │ └── index.js │ └── index.js ├── containers │ └── headercontainer.js └── index.js where components/header/header.js exports with export default class header extends component {} components/header/index.js is import header './header'; import './header.scss'; export default header; and components/index.js is export header './header'; and containers/headercontainer.js trying import with import { header } '../components'; however, doesn't work, header undefined. if use import * components '../components'; , header listed, using components.header again undefined. however, works if instead do import header '../components/header'; can explain why first 2 methods don't seem working? i've done before way, , cannot figure out may have changed (admit

php - Symfony: get file in controller from web folder -

i want pdf file web folder in controller, can't figure out how it. i've try path this // 1 $file = __dir__ . '/../../../../web/1.pdf'; // 2 $file = $this->get('kernel')->getrootdir().'\..\web\1.pdf'; // 3 $issecure = $request->issecure() ? 'https://' : 'http://'; $file = $issecure . $request->gethost() . $this->container->get('assets.packages')->geturl('1.pdf'); and use file controller helper didn't work. how can file public directory? try - append autoload.php define('application_path', realpath(__dir__) . '/'); define('web_path', application_path . '../web/'); also can add folders then file_get_content(web_path . 'your_file.pdf'); another way - $path = $this->getparameter('dir.downloads'); but don't forget declare on parameters.yml this parameters: .... dir.downloads: var/www (your folder)

c# - how to Get input type file value from bootstrap model in mvc 5 controller using jquery ajax -

this question has answer here: file upload using mvc 4 ajax 3 answers jquery ajax upload file in asp.net mvc 4 answers i'm trying input type file value in mvc 5 c# controller unable value. i'm using bootstrap model , jquery ajax task. , dont use form submit this. following code. bootstrap model code : <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4>mark chargeback</h4> </div> <div class="modal-body" align="center"> <div> <in

php - How to properly use models to print an elegant outcome -

i've super new codeigniter 3 , i'm using build task manager ( claritask.com ). also, i'm starting learn how program, forgive me beforehand if i'm not making sense , i'll try clarify in comments. as i'm building specific project page lists specifc tasks, curious know if i'm doing right. what need on view is: tasks belonging specific project & name of project. can work fine, want learn if way of doing correct. i'm using 2 various methods the first method i'm using, deals having 2 functions on model, triggering 2 queries: // show project tasks function get_tasks($project_id) { $this->db->from('tasks'); $this->db->where('tasks.project_id', $project_id); $this->db->order_by('tasks.created_date', 'desc'); return $this->db->get()->result_array(); } // show single project name function get_single_project($project_id) { $this->db->from('projects'

java - Tomcat can't load my jsp file - server did not find a current representation -

Image
i'm getting error: the origin server did not find current representation target resource or not willing disclose 1 exists. warning [http-nio-8080-exec-6] org.springframework.web.servlet.pagenotfound.nohandlerfound no mapping found http request uri [/] in dispatcherservlet name 'springmvc' i'm trying use java configuration on simple code. have config class: package com.kemal.config; import org.springframework.context.annotation.componentscan; import org.springframework.context.annotation.configuration; @configuration @componentscan(basepackages = {"com.kemal", "com.kemal.controllers", "com.kemal.services"}) public class javaconfig { } this controller class: package com.kemal.controllers; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; @controller public class controller1{ @requestmapping("/") public stri

html - Setting element heights using jQuery giving improper height -

i have list of elements (cards i'm calling them) each 33% width in order fill page. inside them header , detail , want show detail of of them click of checkbox. length of detail variable between cards when user clicks show details attempt height of each card's detail, set them same, , show details on them all. i set heights correctly once slidedown() called on them given height greater set. able figure out has data-set-label , data-set-data being inline-block , having width of 50%. if remove that, slidedown() shows proper height. it's if slidedown() not taking consideration inline block elements on same line, doesn't seem right... what's going wrong? $(document).ready(function() { $("#showdetailscheckbox").change(function() { if ($(this).is(":checked")) { setcontentdataheights(); $(".cards-card-detail").slidedown(); } else { $(".cards-card-detail").slideup(); }

azure - How can I choose a different ClearDb MySQL database type within an ARM template? -

Image
i trying manually code cleardb mysql database resource within arm template of 'dedicated' type , of 'jupiter' tier, can't seem find documentation shows how within template. i know arm resource this: { "apiversion": "2014-01-01", "name": "[variables('databasename')]", "type": "successbricks.cleardb/databases", "plan": { "name": "jupiter", "product": "databases", "publisher": "cleardb" }, "location": "[resourcegroup().location]", "tags": {} } but property defines whether database shared or dedicated? i create cleardb mysql database different database types (shared , dedicated), , check , compare templates via automation options . templates: database type: shared { "$schema": "http://sche

javascript - Multiple Modals with same structure on one page -

i've been exploring how can make vanilla modals using example codepen: https://codepen.io/brandonb927/pen/wjaii/ . the problem universally every example i've seen relay on targeting class or id names. want can have multiple modals this: <div class="modal"> <a href="#" class="toggle-modal">toggle modal</a> <div class="modal-content"> <p>this first modal content</p> </div> </div> <div class="modal"> <a href="#" class="toggle-modal">toggle modal</a> <div class="modal-content"> <p>this second modal content</p> </div> </div> both of modals have exact same class names , formatting different content. possible target individual modals when share class names? javascript "this"? if provide working snippet, jquery fine, great :d thanks. if there "modal.js" javas

android - How to know the outgoing call has answered or not? -

i want know outgoing call answered or not in android program.i want know outgoing call has answered or not.i new in android.please me solve problem.for getting call answered time use this. i want know outgoing call answered or not in android program. want know outgoing call has answered or not. new in android. please me solve problem. getting call answered time use this. broadcastreceiver mreceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { if (intent.getaction().equals("android.intent.action.new_outgoing_call")) { savednumber = intent.getextras().getstring("android.intent.extra.phone_number"); } else { string statestr = intent.getextras().getstring(telephonymanager.extra_state); string number = intent.getextras().getstring(telephonymanager.extra_incoming_number); int state = 0; if (statestr.equals(telephonymanager.ext

ios - Cast session getting suspended due to "GCKConnectionSuspendReasonNetworkNotReachable" -

observed behavior : after starting casting of music files, user enters background. after few minutes of playing music file through cast, session gets suspended reason gckconnectionsuspendreasonnetworknotreachable , though sender device , cast device both connected working wi-fi connection expected behavior : session should continue sender app has background capability of playing audio , gckcastoptions have set property suspendsessionswhenbackgrounded no . you may want check resuming after app backgrounding in gckremotedisplaychannel class it's stated that, normally when ios app goes background, network connections closed , hardware encoder access terminated. means without special handling remote display session end upon app backgrounding. a session can kept alive in background doing following: initialize gckdevicemanager initwithdevice:clientpackagename:ignoreappstatenotifications: , specifying yes ignoreappstatenotifications argument.