Posts

Showing posts from September, 2015

.net - Generate assembly with Roslyn -

Image
is possible build .net core or better .net standard library roslyn can referenced project? my goal build assembly on server , have people download can reference , use in own visual studio projects. i'm using roslyn generate c# code , compile it. seems work ok when "emit" compilation result memory stream, load assembly , execute code using reflection. using (var ms = new memorystream()) { var compilationresult = compilation.emit(ms); if (compilationresult.success) { ms.position = 0; var assembly = assemblyloadcontext.default.loadfromstream(ms); .. .. is can "save" assembly proving path emit method. results in .dll file on disk. var compilationresult2 = compilation.emit(@"d:\testassembly.dll"); i wonder kind of format .dll file is. doesn't seem "normal" assembly. i searched internet couldn't find doing this. misunderstand something? so questions are: what kind of format file create emit? full...

java - Can't get itext Rectangle to work correctly with annotations -

i'm new itext , can't annotation icons appear correctly. i'm trying create rectangle annotation icon. example below: rectangle rect = new rectangle(164, 190, 164, 110); chunk_text.setannotation(pdfannotation.createtext(writer, rect, "warning", comments, false, "comment")); pdfcontentbyte pdb = new pdfcontentbyte(writer); chunk_free.setannotation(pdfannotation.createfreetext(writer, rect, comments, pdb)); chunk_popup.setannotation(pdfannotation.createpopup(writer, rect, comments, false)); but, icon fails appear or small dot in pdf. i cant find im doing wrong. you create rectangle this rectangle rect = new rectangle(164, 190, 164, 110); according javadocs : public rectangle(float llx, float lly, float urx, float ury) constructs rectangle -object. parameters: llx - lower left x lly - lower left y urx - upper right x ury - upper right y as l...

javascript - Inserting HTML text in js code -

how import html file in javascript code? currently have like: document.getelementbyid("menu").innerhtml = '<li class="topline"><a href="#">some text</a></li> <li><a href="#">some text </a></li> <li><a href="#">some text</a></li> <li><a href="#">some text</a></li> <li><a href="#"some text</a></li> <li><a href="#">some text</a></li> <li><a href="#">some text</a></li>'; how separate js code , html code in separate files. later load html code javascript easily? you can this! taken below reference link! you need put ul , li tags inside file called import.htm , needs in same place current file. var ajax =...

javascript - Set attribute for custom DOM nodes in text preview component -

i want add / setattribute class custom dom nodes while writing text in custom bbcode -like text editor. when innerhtml of <item></item> not empty i'm filtering through items array in order find value matches. there can unlimited amount of item nodes. (i.e 2, 5, 10) so whenever click on icon named item shows in textarea [item][/item] , in preview component <item></item> . once item written, lets [item]id123[/item] have in dom <item>itemname123</item> . now, i'm doing manipulating dom outside react with: const setattributes = (el, item) =>{ el.dataset.img = item.img; el.setattribute('class', _.tolower(item.color)) }; const updateitems = () =>{ if(document.queryselectorall('item')) { document.queryselectorall('item').foreach(el => items.find(item => { if(_.tolower(el.innerhtml) === _.tolower(item.id)) setattributes(el, item) })); } } the prob...

typescript - Disable a button based on text field values in angular 2 -

i have requirement there multiple text boxes , drop down fields in ui. need enable button on ui when 1 of multiple field has values. calling function based on ngmodel values given these fields somehow disable property value never changes based on values when drop down selected, same old value, property value not change. html code goes <button [disabled]="searchbuttonstatus(x,y, z, a, b, c, d, e, f, g, h, i, j)" </button> <tbody class="position cell-height"> <tr> <td class="empty-cell" id="checkbox" ></td> <!--funding status--> <td class="input-cell" id="status"> <div class="dropdown"> <select [(ngmodel)]="x" (ngmodelchange)="onselectstatus(selectedstatus)" name="status" class="form-control form-textbox input-sm"> ...

javascript - Syntax error : Unexpected identifier -

i making chrome extension , have problems i want make fetch() anilist.co , avoid problems, want use await have syntax error : https://i.imgur.com/icygref.png here code : async function getanimeprogress(animeid) { var result; chrome.storage.local.get('access_token', function (items) { var query = ` query ($id: int, $page: int) { page (page: $page) { media (id: $id) { id medialistentry { status progress } } } } `; var variables = { id: animeid, page: 1 }; var url = 'https://graphql.anilist.co', options = { method: 'post', headers: { 'content-type': 'application/json', 'accept': 'application/json', 'authorizat...

batch file - filebot superstrict script: need tiny video sample or other solution -

seeing how filebot can make massive mistakes (even in strict mode) when renaming videos created script make sure there's no mistakes , lets me check suspicious ones manually. it uses dummy 0-size copy of video in dedicated folder figure out new name renamed , doesn't tagged video , audio info since it's not real video. it simpler , more accurate have variable tags in place need tiny part of video (with tracks) instead of 0-size dummy. what's easy way this? all unknown variables see extrapolated video filename in other script, should not relevant here ask away if need be. @echo off /f "tokens=*" %%f in ("%full%") ( set "fullpath=%%~dpf" set "file=%%~nxf" ) :: prep fake temp file set tempdir=%temp%\%date:~3,2%%date:~6,2%%date:~11,2%%time:~1,1%%time:~3,2%%time:~6,2% mkdir "%tempdir%" && copy /y nul "%tempdir%\%file%" >nul :: filebot string (to shorten lines) if "%type%"...

Amazon Lex Calls Wrong Lambda Function -

while working on test lexbot orders pizza, had error lexbot calling wrong lambda function , outputs result. i have 2 intents, "orderpizzasize" , "orderpizzatoppings". the orderpizzasize intent has slot type pizzasize. slot type contains values "small pizza", "medium pizza", , "large pizza". lambda function orderpizzasize intent calls fulfillment "orderpizza". code below: exports.handler = (event, context, callback) => { var pizzasizechoice = event.currentintent.slots.pizzasize; var price = "free"; if (pizzasizechoice == "small pizza"){ price = "6 dollars"; } else if (pizzasizechoice == "medium pizza"){ price = "8 dollars"; } else if (pizzasizechoice == "large pizza"){ price = "10 dollars"; } else { price = "11 dollars"; ...

javascript - Find coordinate on image client sided -

i've got png 800x800 . after clicking on position(pixel) on image, let's 200x300 want save these coordinates. what approach these coordinates relative image when clicking it? i don't expect give me code, reference good. actually <input type="image"> html element need. <form action="/action_page.php" method="post"> <input type="image" src="https://68.media.tumblr.com/avatar_c5ab8cc59f62_128.png" alt="submit" width="128" height="128"> </form> when clicked, submits form , returns coordinates of click within image in x & y variables (post or get, depending on form's method attribute). demo : https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_input_height_width

Transfer multidimensional lua array from lua_State to lua_State C++ -

i have 2 scripts, each in different lua_state. i trying able variable 1 state , use in other. my code below works single variables , unidirectional arrays. guidance on making work multidimensional arrays? void getvalues(lua_state* l1, lua_state* l2, int& returns) { if (lua_isuserdata(l1, -1)) { luaelement* e = luna<luaelement>::to_object(l1, -1); if (e != null) { luna<luaelement>::push_object(l2, e); } } else if (lua_isstring(l1, -1)) { lua_pushstring(l2, lua_tostring(l1, -1)); } else if (lua_isnumber(l1, -1)) lua_pushnumber(l2, lua_tonumber(l1, -1)); else if (lua_isboolean(l1, -1)) lua_pushboolean(l2, lua_toboolean(l1, -1)); else if (lua_istable(l1, -1)) { lua_pushnil(l1); lua_newtable(l2); while (lua_next(l1, -2)) { getvalues(l1, l2, returns); lua_rawseti(l2,-2,returns-1); lua_pop(l1,...

android - Cant arrange LinearLayout to show button at the bottom with ListView above -

Image
consider next piece of xml - <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.android.fiby.fragments.menufragment" android:orientation="vertical" android:layout_weight="0.7"> <com.android.fiby.titlefont android:layout_margintop="5dp" android:layout_marginbottom="5dp" android:textcolor="#5e240a" android:layout_width="wrap_content" ...

wpf controls - How to add WPF Behavior in the code behind -

i trying find way add behavior in code, able add in xaml. this how adding behavior in xaml grid, selecteditems dp in behavior , data bind view model selected items property. listening grid collection changed event , updating dp in turns notify view mode of selected items /// <summary> /// dependency property selecteditems /// </summary> public static readonly dependencyproperty selecteditemsproperty = dependencyproperty.register("selecteditems", typeof(inotifycollectionchanged), typeof(multiselectbehavior), new propertymetadata(null)); associatedobject.selecteditems.collectionchanged += gridselecteditems_collectionchanged; <i:interaction.behaviors> <behaviors:multiselectbehavior selecteditems="{binding selecteditems}"/> </i:interaction.behaviors> what need create behavior in code behind. doing in constructor of window contains grid, not working, viewmodel selected items property...

google cast - Chromecast - Chrome sender - How do you update media session on sender? -

after cast initialization, sender makes request load media on running receiver var session = window.cast.framework.castcontext.getinstance().getcurrentsession(); ... session.loadmedia(loadrequest); then, receiver loads next media using mediamanager var mediamanager = new cast.receiver.mediamanager(mediaelement); ... mediamanager.load(loadrequestdata); // "loads media session on receiver without involvement of sender" i need update media session on sender side. how achieve this? you can use session.stop , addupdatelistener end current media when 1 starts. to stop, can use code snippet provided in docs: function stopapp() { session.stop(onsuccess, onerror); } you can check related so post reference. hope helps.

javascript - Leaflet double tap does not zoom in -

leaflet not recognize double tap (but double click zoom ok - open dev tools , choose mobile device see bug) on touch devices in app: https://express-tourism.herokuapp.com/ thought may because have map div inside global wrapper div not case. when typed 'map' in console shows doubleclickzoom enabled have manually add double tap feature or missing something? update: @baptiste right - had add custom double tap function: var tapped=false $("#map").on("touchstart",function(e){ if(!tapped){ //if tap not set, set single tap tapped=settimeout(function(){ tapped=null //insert things want when single tapped },300); //wait 300ms run single click code } else { //tapped within 300ms of last tap. double tap cleartimeout(tapped); //stop single tap callback tapped=null //insert things want when double tapped map.zoomin(1) } }); leaflet doesn't zoom double tap on mobile, need 2 f...

Ansible hot add multiple ports -

ansible playbook how add multiple ports (interactive prompt) using firewall-cmd command in ansible-playbook vars_prompt: - name: port prompt: "enter port#" private: no i can 1 port not multiple ports vars_prompt "loops" not possible (as of ansible 2.3) without writing custom plugins. you can workaround expecting comma-separated string , split later list: - hosts: localhost gather_facts: no vars_prompt: - name: ports prompt: "enter port(s) number" private: no tasks: - name: add port shell: /bin/firewall-cmd --permanent --add-port={{ item }}/tcp with_items: "{{ ports.split(',') }}"

update old and new location to firebase with swift -

i building app multiple users show on map avatar , trying animate movement on map need old , new location that, can't old location , don't know how . used code update new location still need old 1 : func locationmanager(manager: cllocationmanager, didupdatelocations locations: [cllocation]) { if let location = locations.first { self.database.database().reference().child("location").child(auth.auth()!.currentuser!.uid).setvalue(["newlatitude": locationmanager.location!.coordinate.latitude, "newlongitude": locationmanager.location!.coordinate.longitude]) } } thanks in advance

winapi - Run program when window user switches active window -

i prevent user switching window (similarly kiosk applications). turn behaviour od (and off) anytime keyboard shortcut application. the best thing achieved autohotkey script waits activating keyboard shortcut , detects changes of active window , when active window changed runs program (clearlock in case) locking computer fine me. i use when on computer , when want leave temporarily , not lock computer completely. friends, girlfriend or coworkers understand me not trusting them. here autohotkey script have: gui +lastfound hwnd := winexist() dllcall( "registershellhookwindow", uint,hwnd ) msgnum := dllcall( "registerwindowmessage", str,"shellhook" ) onmessage( msgnum, "shellmessage" ) return shellmessage( wparam,lparam ) { wingettitle, title, ahk_id %lparam% if (wparam=4) { ;hshell_windowactivated global kiosk if (kiosk) { global kiosk kiosk := 0 run "%portable_apps%\ut...

vba - Code to rename existing worksheets from cell value in worksheet 1 if value in another cell -

i quite know nothing macros , vba codes. have tried several different things nothing working. trying create template sheet1 list of part numbers either make or buy make product sell. column b part number , column e either m or b make or buy. rename existing worksheet (starting sheet3) part number listed in column b if there m in column e. please help, confused on this. need existing following sheets named parts make , not ones buy. thank you. paste in standard module (alt+f11, right-click vbaproject on left > insert > module). this may need tweaked little bit exact needs, asking in question should job. option explicit sub createsheets() dim rngb range, rnge range, mysheet worksheet, cell range dim row long, newsheet worksheet set mysheet = thisworkbook.sheets(1) set rngb = mysheet.range("b:b") set rnge = mysheet.range("e:e") each cell in rnge row = cell.row if cell = empty exit e...

r - concatenate quosures and string -

i'm looking way concatenate quosure , string result quosure. actually, if use paste0() , quo_name() , can it. wonder if there more elegant alternative write function in package. generic example: library(dplyr) df <- data_frame( z_1 = 1, z_2 = 2, y_1 = 10, y_2 = 20 ) get_var <- function(.data, var) { xx = enquo(var) select(.data, paste0(quo_name(xx), "_1"), paste0(quo_name(xx), "_2")) } get_var(df, z) # tibble: 1 x 2 z_1 z_2 <dbl> <dbl> 1 1 2 without function, how using dplyr : library(dplyr) df %>% select(starts_with("z_")) you can create function , pass in string variable name this: get_var= function(df, var){ df %>% select(starts_with(paste0(var, "_"))) } get_var(df, "z") now, tricky part comes when trying pass in variable name without quoting function (the r code, not value contains). 1 way of doing deparse + substitute in base r. converts ...

bash - npm does not run when called through nginx/php-fpm exec -

i have strange issue in autodeploy script. basically that's php script, that, when triggered through http, runs other shell script several commands npm install , npm run build . works except case when php script called http nginx/php-fpm - case npm command not run. i created simple example repo demonstrate issue: https://github.com/kasheftin/npm-bug we have test.php runs test.sh shell command: <?php exec("/home/www/tests/npm-bug/test.sh > /home/www/tests/npm-bug/test.log"); we have test.sh runs npm run test command: #!/bin/bash cd /home/www/tests/npm-bug npm run test finally have package.json following command: "scripts": { "test": "echo \"hello world!\"" } the result of npm run test looks like: > npm-bug@1.0.0 test /home/www/tests/npm-bug > echo "hello world!" hello world! notice last row - that's result of echo command in package.json. same result appears in case of ./tes...

javascript - AJAX - unexpected token < in JSON doesn't call complete function -

i have ajax call saving record on 1 of pages. on button click, have processing image shown , on complete, image should hidden. but, if chance there error occurring on server side, error saying unexpected token < in json printed in browser's console , completed method not being called. ajax call : jquery('body').on('click', "#save, function(e) { jquery("processing").show(); jquery.ajax({ method : "post", url : "useredit/save.do", data: { "userid" : row.id } }) .success(function () { table.ajax.reload(); }) .complete(function () { jquery("processing").hide(); }) .error(function () { jquery("processing").hide(); }); }); this making user feel process taking ever complete. there way hide processing image if ajax call completed errors? in advance

css z-index bug in blogger -

i'm creating new blogger template , unfortunately i'm facing issue. simple example trying do. <div class='container'> <div class='slider'></div> <div class='posts'></div> </div> by default second div (posts) should have z-index higher first one. see demo , see this pic , see should done here , problem !. here blog to have apparent higher z-index , element must either after other element or have position:relative; or absolute when previous element has relative/absolute position. .d1{ width: 100%; height:50px; background: tomato; position: relative; } .d2{ width:80%; height:200px; background: blue; margin: -30px auto 0 auto; position: relative; /* try removing - 'below' d1 because d1 has position:relative; */ } <div class='container'> <div class='d1 slider'></div> <div class='d2 p...

jquery - Fade In/Out on Scroll Not Working In Safari -

i have below code fades images in scroll down , fades them out when scroll up: <script> jquery(window).on("load",function() { jquery(window).scroll(function() { var windowbottom = jquery(this).scrolltop() + jquery(this).innerheight(); jquery(".lookbook").each(function() { /* check location of each desired element */ var objecttop = jquery(this).offset().top + jquery(this).outerheight(); /* if element within bounds of window, fade in */ if (objecttop -500 < windowbottom) { //object comes view (scrolling down) if (jquery(this).css("opacity")==0.4) {jquery(this).fadeto(1500,1.0);} } else { //object goes out of view (scrolling up) if (jquery(this).css("opacity")==1.0) {jquery(this).fadeto(1500,0.4);} } }); }).scroll(); //invoke scroll-handler on page-load }); </script> <style> .lookbook {opacity:0.4;} </style> this works fine when test in chrome ...

grails - avoiding deadlock by disabling ALLOW_PAGE_LOCKS in sql server -

i have grails application exposes api bit dml heavy underneath. dmls happening via gorm , not using sql directly. when api hit concurrently, running deadlocks , keylock on primary key part of deadlock log. here snippet of log sql server: date,source,severity,message 09/13/2017 17:02:13,spid21s,unknown,waiter id=process4a1fb88 mode=ranges-u requesttype=wait 09/13/2017 17:02:13,spid21s,unknown,waiter-list 09/13/2017 17:02:13,spid21s,unknown,owner id=process59494c8 mode=ranges-u 09/13/2017 17:02:13,spid21s,unknown,owner-list 09/13/2017 17:02:13,spid21s,unknown,keylock hobtid=72057594142588928 dbid=17 objectname=epm-dev.dbo.participanttrace indexname=pk_participanttrace id=lock8d0c6c80 mode=ranges-u associatedobjectid=72057594142588928 09/13/2017 17:02:13,spid21s,unknown,waiter id=process59494c8 mode=ranges-u requesttype=wait 09/13/2017 17:02:13,spid21s,unknown,waiter-list 09/13/2017 17:02:13,spid21s,unknown,owner id=process4a1fb88 mode=rangex-x 09/13/2017 17:02:13,spid21s,unknown,o...

ios - Pass arrays data from a ViewController to a TableView -

Image
i couldn't find specific case have pass , append 2 or more arrays of string tableview located in 2nd viewcontroller. want push 2 different strings inside 2 different uilabels i have data gets inside through uialertviewcontroller in mainviewcontroller var name = alertcontroller.textfields?[0].text var number = alertcontroller.textfields?[1].text then take data , every time new set of name/number append arrays of string in mainvc var playernames = [string]() var playernumbers = [string]() self.playernames.append(name!) self.playernumbers.append(number!) now created table view , custom cell .xib , i'd call , set custom labels this tableview in second viewcontroller func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell { customcell.tableviewcellnumber.text = mainvc.playernumbers[indexpath.row] customcell.tableviewcellname.text = mainvc.playernames[indexpath.row] return customcell } so every new set makes new row name...

python - higher-order function for delegating property getter/setters? -

i have python object bunch of property methods following, forward on method: class wonderland(object): ... @property def tweedledee(self): return self.request('gettweedledee') @tweedledee.setter def tweedledee(self, value): result = self.request('settweedledee', value) if not result['success']: raise wonderlandissue(result['issue']) @property def tweedledum(self): return self.request('gettweedledum') @tweedledum.setter def tweedledum(self, value): result = self.request('settweedledum',value) if not result['success']: raise wonderlandissue(result['issue']) @property def mad_hatter(self): return self.request('gethatter') @mad_hatter.setter def mad_hatter(self, value): result = self.request('sethatter',value) if not result['success']: rai...

How do I prevent my text from displaying Optional() in the Swift interpolation? -

how prevent text displaying optional() in swift interpolation? my text displaying : ---you can switch properties once images optional("ppp") have finished uploading.--- here code let imageslefttoupload = syncer!.imagestoupload?.count if(imageslefttoupload != nil && imageslefttoupload! > 0) { let propertyconfig = syncer!.getpropertyconfig() var propertynamestr: string = "" if(propertyconfig != nil && propertyconfig!.propertyname != nil) { propertynamestr = "from \(propertyconfig!.propertyname)" } messagetext.text = "you can switch properties once images\(string(describing: propertynamestr)) have finished uploading." } use optional binding safely unwrap optionals, use string interpolation on non-optional value. guard let imageslefttoupload = syncer?.imagestoupload?.count, imageslefttoupload > 0 else {return} guard...

javascript - Facebook API: user_feed is empty -

so happy when facebook approved chrome extension app. basically, allows import data facebook local_storage in chrome, can search old posts. while works charm account, when switch account, login, approve facebook request permissions, user_feed data empty. @ loss. i able user info, image of user, his/her name, etc. , able retrieve access token. but, when make call feed, comes empty: https://graph.facebook.com/me/feed?access_token=eaacu...&expires_in&limit=50&offset=1&fields=message,likes,story,created_time,link (i have tried injecting id "me"). again, works great when it's fb account (also developer account). so, don't think code, thing changes user... perhaps takes amount of time facebook api work after facebook approves permissions request?? use access token debugger tool see if access token getting has user_posts permission listed under "scopes". if not present, cannot use access token fetch user's feed. note use...

iis 8 - URL redirection to different port on the same web server based on the url name using IIS server -

i in need little help. have web server alias name www.dmp.org. when try access url, web page hosted on port 80 getting loaded default. now, need setup alias dmp-qa.org same web server, expected redirect automatically web page hosted on port 10000. we have web server windows 2012 iis 8.5. can done using iis/windows combination? any appreciated.

javascript - YouTube data API pauseVideo() isn't working -

i'm using youtube data api control embedded player , i'm getting odd results when call pausevideo(). instead of remaining in state 2 (or yt.playerstate.paused) player switches state 1 (playing). i'm using loadvideobyid() seekto() , pausevideo(). if change loadvideo cuevideobyid() works, i'm still curious. i'm logging events onstatechange($event) , get: pausing... state changed to: 2 state changed to: 1 is there reason player play after pause?

postgresql - Django .get() returns a tuple and not the object -

i have simple function looks this: parent_key = seokeys.objects.get(view_id=view_id, key_nbr=key_nbr) if parent_key.status != 'active': parent_key.status = status parent_key.save() metrics, created = seometrics.objects.get_or_create( seo_url = url_sent, date = date, parent_key = parent_key, defaults = { 'parent_key':parent_key, 'seo_url': url_sent, 'url_found':url_found, 'position':position, ...

How can I read CSV with strange quoting in ruby? -

i have csv file line like: col1,col "two",col3 so illegal quoting error , fix setting :quote_char => "\x00" ["col1", "col\"two\"", "col3"] but there line like col1,col2,"col,3" later in file ["col1", "col2", "\"col", "3\""] then read file line line , call parse_csv wrapped in block. set :quote_char => "\"" , rescue csv::malformedcsverror exceptions , particular lines set :quote_char => "\x00" , retry all works until line col1,col "two","col,3" in case rescue s exception, set :quote_char => "\x00" , result is ["col1", "col\"two\"", "\"col", "3\""] apple numbers able openn file absolutely correctly. is there setting parse_csv handle without preprocess string in way? upd show csv lines in file , results (...

r - plotting multiple series on same plot using plotly and lapply in Shiny modules -

i having trouble plotting many data on same plot using lapply i have module calling , storing dataframes list each lists called dx<-list , each dataframe in list i.e dx[[i]] i'd create add line 1 plot. since dataframes in list have same x axis want add multiple series same plot i using plotly add_trace , succesfully able following way when dont have modules or list of dataframes pl<-plot_ly()%>% add_trace(data=dataset1,x=~x,y=~y,mode='lines',type='scatter' ) %>% add_trace(data=dataset2,x=~x,y=~y,mode='lines',type='scatter' ) %>% add_trace(data=dataset3,x=~x,y=~y,mode='lines',type='scatter' ) %>% add_trace(data=dataset4,x=~x,y=~y,mode='lines',type='scatter' ) %>% layout(xaxis = x, yaxis = y) how can achieve same using lapply here reproducible code module1ui <- function(id) { ns <- ns(id) wellpanel( selectinput( ns('cars')...

visual studio - Clear data inside all files in C++ -

hi guys programming on c++. wish clear data inside of files in current directory. can tell me command files? that trying doesn't work: ofs.open("*.*", ios::out | ios::trunc); the problem is: open("*.*", fstream can't open files of directory, instead, can iterate each file. example works on c++17 #include <string> #include <iostream> #include <filesystem> #include <fstream> //namespace fs = std::experimental::filesystem; //for visual studio namespace fs = std:::filesystem; int main() { std::string path = "path_to_directory"; (auto & p : fs::directory_iterator(path)) { if (fs::is_regular_file(p)){ std::fstream fstr; fstr.open(p.path().c_str(), std::ios::out | std::ios::trunc); //do fstr.close() } } } older compilers(windows): #include <windows.h>...

angular - angular2 No provider for Http -

this question has answer here: angular 2 no provider http 12 answers import {http, http_providers} '@angular/http'; when use http error "no provider http", then import http_providers http_providers has no exported member i have created plunker on inserting http. read more http module import {httpclientmodule} '@angular/common/http'; @ngmodule({ imports: [ browsermodule, httpclientmodule ], declarations: [ app ], bootstrap: [ app ] }) export class appmodule {}

node.js - how to disable mocha.opts disable slow option -

in mocha.opts have got: --slow 1000000 but rather disable slow option. possible? basically, don't want yellow or red showing when tests run slow. because want these tests take considerable amount of time.

javascript - Convert CSS to inline CSS? -

i found awesome css code , use on website. because have generate lot of buttons php need write css inline style="..." button. question is, how can convert inline css? i googled converter sadly didn't find anything. you can add these css codes top css file of website

methods - Is Java "pass-by-reference" or "pass-by-value"? -

i thought java pass-by-reference ; i've seen couple of blog posts (for example, this blog ) claim it's not. don't think understand distinction they're making. what explanation? java pass-by-value . unfortunately, decided call location of object "reference". when pass value of object, passing reference it. confusing beginners. it goes this: public static void main( string[] args ) { dog adog = new dog("max"); // pass object foo foo(adog); // adog variable still pointing "max" dog when foo(...) returns adog.getname().equals("max"); // true, java passes value adog.getname().equals("fifi"); // false } public static void foo(dog d) { d.getname().equals("max"); // true // change d inside of foo() point new dog instance "fifi" d = new dog("fifi"); d.getname().equals("fifi"); // true } in example adog.getname() still retur...

php - Save SQL column value to an array -

i want save value array. have column called numbers values 1,2,3 . if select value, save variable $value , try put array: $array = array($value); but not working properly. php not automatically convert strings integers. dump showed 1 string, this: // separate comma array $array = explode("," $str); // array( '1', '2', '3' ); // re-create array, converting strings integers foreach ($array $index => $value) { $array[$index] = (int)$value; }

python import error WindowsError: [Error 126] -

import nfc when import nfc in python editor ,it can't import ,why?? traceback (most recent call last): file "<stdin>", line 1, in module file "e:\python27\lib\site-packages\nfc\__init__.py", line 22, in <module> . import clf file "e:\python27\lib\site-packages\nfc\clf\__init__.py", line 25, in <module> . import device file "e:\python27\lib\site-packages\nfc\clf\device.py", line 32, in <module> . import transport file "e:\python27\lib\site-packages\nfc\clf\transport.py", line 31, in <module> import usb1 libusb file "e:\python27\lib\site-packages\usb1\__init__.py", line 61, in <module> . import libusb1 file "e:\python27\lib\site-packages\usb1\libusb1.py", line 173,in_loadlibrary return dll_loader('libusb-1.0' + suffix, **loader_kw) file "e:\python27\lib\ctypes\__init__.py", line 362, in __init__ self._handle = _dlopen(self._name, mode) windowserr...

Why are Python, Ruby, and Node.js so much slower than Bash, AWK, Perl? -

while making polyglot makefile (which launches many thousands of processes), noticed scripting languages vary enormously in start-up performance. bash $ timeformat='%3r'; time bash -c "echo 'hello world'" > /dev/null 0.002 awk $ timeformat='%3r'; time awk "begin { print \"hello world\" }" > /dev/null 0.002 perl $ timeformat='%3r'; time perl -e "print \"hello world\n\"" > /dev/null 0.003 all same. each of these scripting languages order of magnitude(!) slower. python $ timeformat='%3r'; time python -c "print 'hello world'" > /dev/null 0.023 ruby $ timeformat='%3r'; time ruby -e "puts 'hello world'" > /dev/null 0.024 node.js $ timeformat='%3r'; time node -e "console.log('hello world')" > /dev/null 0.082 what sorts of things python, ruby, , node.js doing make them slower equivale...

Issue with ColdFusion 2016 CFGrid update function -

this has worked fine many versions prior. after update coldfusion 2016, cfgrid produces error when trying update cell active status 2 3 item. user updates cell , hits enter, refreshes grid , sees change not stored. cfdebug error ajax logger cfgridchanged undefined . suggestions on how make work in coldfusion 2016? <cfgrid name="modify_pids" height=525 autowidth="yes" width=1040 vspace=10 selectmode="edit" insert="no" delete="no" format="html" selectonload = "no" striperows = "yes" selectcolor="cde6f3" preservepageonsort="yes" pagesize=100 sort=true onchange="cfc:functions_pids.updatepid({cfgridaction},{cfgridrow}, {cfgridchanged}, '#getcurruser.uid#')" bind="cfc:functions_pids.getpids({cfgridpage},{cfgridpagesize}, {cfgridsortcolumn},{cfgridsortdirection}...

how to get the dom's true height by reactjs? -

there reactjs component, need heigth of dom in component. failed, don't know wrong. code: class imgcropper extends react.component { constructor(props) { super(props); this.state = { containsize: { width: 0, height: 0 }, }; } componentdidmount() { console.log('=================组件的宽高:', this.image.offsetwidth, this.image.offsetheight); this.middle.style.width = `${this.contain.offsetwidth}px`; this.middle.style.height = `${this.contain.offsetwidth}px`; // 配置图片的宽高 this.image.style.transform = `translate(0px,${parseint((this.contain.offsetheight - this.image.height) / 2, 10)}px)`; } render() { return (<div ref={((div) => { this.contain = div; })} classname={styles.container}> <div id="cover-top" ref={(div) => { this.top = div; }} classname={styles.covertop}> <a href=""> <input id="imagefile" name="image...

windows - How to make thumbnail and preview work for shortcut file on Win 7/8 -

Image
i learning write windows shell thumbnail handler (ithumbnailprovider implementation), according sample project microsoft ( https://code.msdn.microsoft.com/windowsapps/cppshellextthumbnailhandler-32399b35 ). everything works fine until noticed there 1 problem thumbnail handler: shortcut file links file type registered sample dll, cannot show thumbnail , preview on windows 7/8/8.1, works on windows 10. screenshot might better demonstrate issue. on windows 7: from screenshot, can see shortcut links .recipe file cannot show thumbnail , preview. tried sumatra , adobe acrobat reader, neither of them work. however, powerpoint 2016 (.pptx) somehow works without problem. here's screenshot taken on windows 10: any idea how make thumbnail/preview work on windows 7/8?

How does .livequery() work when it only receives one parameter? -

i visiting https://github.com/brandonaaron/livequery trying find syntax of .livequery(). can see there in official documentation, .livequery() can receive 2 or 3 parameters: // selector: selector match against // matchedfn: function execute when new element added dom matches $(...).livequery( selector, matchedfn ); // selector: selector match against // matchedfn: function execute when new element added dom matches // unmatchedfn: function execute when matched element removed dom $(...).livequery( selector, matchedfn, unmatchfn ); however, in source code examining, see .livequery() receiving 1 parameter. example: $('.js-truncate').livequery(function() { .................................. }); from understand , based on see in official documentation, first parameter of .livequery() "selector". mean when .livequery() receives single parameter, parameter in case?: function(){.......}. thank you.

artifactory - How should I point Meteor to a private repository for Atmosphere packages? -

i being asked deploy meteor app build server not have internet access. build server can download meteor, npm packages, etc, private jfrog artifactory repo on local network server. meteor app has atmosphere package dependencies. how can configure meteor point artifactory (or private repo) atmosphere packages, or otherwise solve problem? you access atmosphere or github @ build/deploy time. if use mup deploy server, won't matter it's not online. if has built build server, build server need network access, unless want configure local repository files from. there places here further how it: https://www.npmjs.com/package/sinopia can host private repository organization use npm? https://addyosmani.com/blog/using-npm-offline/ local npm/atmosphere package repositories meteor applications without internet access

php - Woocommerce Remove Coupon Section from Checkout Page -

i trying remove "have coupon" section sits @ top of woocommerce checkout page (/checkout). i keep coupon section on cart page, can't disable coupons, removed on checkout page. any appreciated. remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); should it.

javascript - Knockout and Semantic UI Multi Select Dropdown with pre-selected values with a collection inside a model -

using knockout , semantic ui. i'm trying figure out how values selected multi select dropdown. first dropdown works single values, multi select 1 dosent. have observable array inside collection: <tbody id="tbodyelement" data-bind="foreach: groupusercollection"> <tr> <td> <div class="ui selection dropdown fluid"> <input type="hidden" name="groupdd" data-bind="value: group.name"> <i class="dropdown icon"></i> <div class="default text">select group</div> <div class="menu" data-bind="foreach: $parent.groupcollection"> <div class="item" data-bind="text: $data.name(), attr: {'data-value': $data.id()}"></div> ...