Posts

Showing posts from April, 2010

c - What is the time complexity of my codes: reversing words in a string? Should I account for asymmetrical spacing? -

problem statement : write function of declaration void str_words_in_rev(char *input, int length) reverses words in string of word/(s). i've implemented 2 different solutions it, 1 of extremely complicated. solution 1: reverse entire string using void reverse(char* string, int start, int end) function takes index of first , last letter of string or substring want reverse. after that, reverse each word in string using same reverse function. #include<stdio.h> void swapchar(char *a, char *b) { char temp = *a; *a = *b; *b = temp; } int length(char *string) { if(string == null) return -1; int i=0; for(;string[i++];); return i; } void reverse(char* string, int start, int end) { int mid = start + (end - start + 1)/2; for(int i=start,j=end;i<mid;) swapchar(&string[i++], &string[j--]); } int main() { char str[] = "abc def ghij klmn"; int i=0, j=0, len = length(str), flag = 0; if(str == null || !(*str)) return 0...

java - ActionBar back button finishing activity from inner Fragment -

i have appcompatactivity actionbar incorporating button. starting inner fragment class opens view on top of activity view. hardware button closes fragment , activity view visible. if press button on actionbar whilst in fragment view, app goes mainactivity, activities parent. want either hide actionbar, or ideally give same behaviour hardware button, annoying behaviour user. have tried creating instance of actionbar in activity, this actionbar actionbar = getactionbar(); actionbar.sethomeasupenabled(true); this gives me nullpointerexception in runtime. have searched , stumped. also tried this, mfragmentmanager has .addtobackstack() before begins transaction fragment class. @override public void onbackpressed() { int count = mfragmentmanager.getbackstackentrycount(); if (count == 0) { super.onbackpressed(); //additional code } else { mfragmentmanager.popbackstack(); } log.i(log_tag, "onbackpressed. count = " + count); }...

excel - Create Backup folder with max. 7 backups -

my code doesnt kill older backups after getting on 7 backups :( option explicit private sub workbook_beforesave(byval saveasui boolean, cancel boolean) dim savepath string dim filename string dim fileextension string dim filedate string dim filebackupname string dim fileusername string dim datei string dim datalt string dim dateilösch string dim x long dim zähler long if dir(activeworkbook.path & "\" & "backup", vbdirectory) = "" then mkdir (activeworkbook.path & "\" & "backup") end if savepath = thisworkbook.path & "\backup\" filename = left(thisworkbook.name, instrrev(thisworkbook.name, ".") - 1) fileextension = mid(thisworkbook.name, instrrev(thisworkbook.name, ".") + 1) fileusername = environ("username") filedate = format(now, "yyyymmdd_hhmmss") '--- letztes backup löschen x = le...

excel - VBA Hide all sheets that aren't being used in workbook -

i have many sheets in workbook. have main sheet/"form" called "je" , on sheet there buttons , macros lead other sheets in workbook. but, intention other users, not myself, use workbook. so, sheet being used visible @ given time. @ no time want more 1 sheet visible user. user can navigate workbook thru clicking buttons , cells in select sheets allow them navigate throughout entire workbook. have tried adding code 'thisworkbook' module doesn't seem working i'd like. when navigate 1 sheet , another, sheets remain visible when i'd them hidden i'm unsure of other modifications can make code below desired result. if can offer modifications or changes can make accomplish this, i'd appreciate it. update : have added code 'thisworkbook' object: option explicit private sub workbook_sheetactivate(byval sh object) dim mysh worksheet each mysh in thisworkbook.worksheets if mysh.name <> sh.name mysh.v...

401 when trying to create a post in Wordpress API using Oauth 1.0 -

i'm trying create wordpress post through wordpress api v2, oauth 1.0 throwing 401 @ me when axios.post. when axios.get, everything's perfect , result. i can create or delete posts through postman without problem, configures automatically. nice if copy request somehow postman , put axios code, couldn't find option. i tried specifying header content-type application/json so: headers: { 'content-type': 'application/json' } as in postman, still no change. i'm using generator oauth signature , it's working in request pointed out. https://www.npmjs.com/package/oauth-signature here's code , post requests: getrequest = () => { const requestparams = { ...this.state.parameters } requestparams.oauth_nonce = this.generatenonce() requestparams.oauth_timestamp = new date() .gettime() .tostring() .slice(0,10) const encodedsignature = oauthsignature.generate( 'get', 'http://localh...

git - Automatically track certain files -

long story short: we're using jupyter notebooks ( .ipynb files) , have set jupyter config save .py copies (à la this answer on so , purposes of nicer git diffs). so every time save .ipynb file, saves .py version, otherwise same filename. if no .py version existed, creates new one. is possible automatically add / track these newly created .py files, perhaps putting in git config? edit so may possible using git pre-commit hook, having read it. however, don't know enough write hook scratch. to reiterate want: save foo_bar.ipynb , automatically creating foo_bar.py . want pre-commit hook add foo_bar.py if do, e.g., git commit -a . to emphasise, don't want add old .py files, ones have same filename existing .ipynb file. write script adds new , updated files git , commits them. run manually or cron job. better, hook tool generates files, if possible, run every time tool saves files or when exits. the script simple as: # change directory cd /path...

acumatica - PxProjection - how to use filter parameters in the Select class? -

i use pxprojection attribute in way select specific fields of dacs. how should pass filter parameter in select command(the same way in graph using or<crinsurancepolicy.currentreportsto, equal<current<baccountparam.baccountid>>> ) in order have filtered data in graph?

javascript - How to include DatePipe in HTML to print lastModifiedDate -

i have file-upload.component.ts import datepipe import { datepipe } '@angular/common'; then i export class fileuploadcomponent implements oninit { datepipe = new datepipe(); } and in file-upload.component.html set <td>{{ file.lastmodifieddate | date }} </td> where mistake? the datepipe shouldn't need imported @ all. it's built in , can used out of box

linux - How to create a table in mysql 5.6.30 debian? -

i'm trying create table in mysql in linux i'm getting error error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near varchar(64); i'm trying create table command create table randomtable(password varchar(64));

php - Checkbox selection in table -

i've seen similar questions on here code different when try implement it. i'm using php , html connect db2 database, pull data table , display pulled data in html table. i'm trying add functionality 'delete' button , able mark check-box highlight selected row in table. i'm working on delete.php implement row selection. found line of code put @ start of table, how highlight row? here's have far: <html> <head><title>db testing</title></head> <style> table{ font-family: arial, sans-serif; border-collapse: collapse; width: 80%; } td, th { border: 1px solid #dddddd; text-align: left; padding: 8px; } </style> <body> <?php //db2 express c (v10.5) in local $database = "db"; $user = "user"; $password = "password"; //create connection $conn = db2_connect($database, $user, $password); //check connection if($conn) { //echo "db2 connection su...

c# - Convert.ToBase64String() with numbers larger than 255 -

i'm using code below convert list of numbers base64 encoded string. the problem try on 255 system.overflowexception since overflows byte capacity. what way of doing this? there example here wondering if there other ways of making work. private string decimaltobase64(list<int> lst) { byte[] arr = new byte[lst.count]; for(int = 0; < arr.length; i++) { arr[i] = convert.tobyte(lst[i]); } return convert.tobase64string(arr); } try code: public static string decimaltobase64(list<int> lst) { var bytes = new list<byte>(); foreach (var item in lst) bytes.addrange(bitconverter.getbytes(item)); return convert.tobase64string(bytes.toarray()); } read more bytes order wiki

asp.net core - Single sign on between web application and native desktop application using OAuth 2 -

we want code web-application (with asp.net core) starts legacy windows desktop application via custom url protocol. web-application must use authorization server obtaining access (bearer) token via oauth 2 has access user's resources via asp.net core web api. desktop application must able access user's resources via web api too. how can desktop application obtain access token? i can think of following options: the desktop application shows login screen, sends entered username , password authorization server (using “resource owner password credentials” grant type of oauth 2) , gets access token back. the desktop application shows embedded browser window. embedded browser requests oauth authorize endpoint of authorization server (using “authorization code” grant type of oauth 2) , user must log-in authorize. authorization server redirects redirect url. desktop application intercepts redirect, extracts authorization token , uses access token. the web-application starts ...

[Azure Mobile App Service]How to login without password on Facebook sign-in? -

i activated facebook sign-in azure's mobile app service, service asked enter id , password. instagram or other famous application can login without entering password "continue name" if logged in facebook. i authenticate facebook on azure without entering id or password, how can it? for server-managed authentication , app authenticate user through web view. checked server-flow in xamarin.forms app, , found need enter facebook account info logging. while browsing mobile app via browser, login page show "continue name" if have logged in facebook (www.facebook.com). note: when using sever-flow, page asking facebook account under facebook domain, azure not peek or save facebook account info. i authenticate facebook on azure without entering id or password, how can it? based on scenario, need leverage client-managed authentication in mobile app, , need install facebook app on device test. additionally, cannot install other apps on ios simu...

json - ElasticSearch filtered query with operator AND and OR -

i'm intervening on existing app interacts elasticsearch sever , i'm seeing weird responses, due fact i'm new elastic. i have indexed item below : "_id": "59773d268770541557000012", "_score": 0.03282923, "_source": { "_id": "59773d268770541557000012", "active": null, "address": "dummy address", "center_ids": [], "consultation_site_ids": [], "coordinates": null, "created_at": "2017-07-25t14:44:22.270+02:00", "death_declaration_form_step_id": "56ddb086f0e0103b44000000", "end_of_pregnancy_form_step_id": "56c34e63f0e0105e65000000", "fax": "06.95.40.58.84", "form_step_ids": [ "55361b215342491667030000", ...

ms access - Query table based on results of another table -

Image
i trying create query in access picks out rows in table based on existence of values in table. looking @ table contains state of different id numbers , checking whatever state id @ has progressed through lower states. for example, each id goes apprentice journeyman master. if id @ master, noted in state table, there should record in events table id being @ apprentice , master well. the query should return ids state table @ master state have not progressed through states based on entries in events table. with 2 tables below, query should return ids 2. id 2 listed @ master never @ journeyman state. state table: id status 1 master 2 master 3 apprentice 4 journeyman events table: date status id 7/25/17 master 1 7/25/17 master 2 7/24/17 journeyman 1 7/24/17 journeyman 3 7/20/17 apprentice 4 7/20/17 apprentice 3 7/20/17 apprentice 2 7/20/17 apprentice 1 i have created query ids marked master. i'm not sure go there @ events table ids marked mas...

python 3.x - Web Scraping Location Data with BeautifulSoup -

i trying scrape webpage address data (the highlighted street address shown in image: 1 ) using find() function of beautifulsoup library. online tutorials provide examples data can pinpointed class; however, particular site, street address element within larger class="datacol col02 inlineeditwrite" , i'm not sure how @ find() function. what arguments find() street address in example? appreciated. image: 1 this should started, find div element class "datacol col02 inlineeditwrite" search td elements within , print first td elements text: divtag = soup.find("div", {"class":"datacol col02 inlineeditwrite"}) tag in divtag: tdtags = tag.find_all("td") print (tdtags[0].text) the above example assumes want print first td element div elements class "datacol col02 inlineeditwrite" otherwise divtag = soup.find("div", {"class":"datacol col02 inlineeditwrite"}) tdtag...

javascript - Angular 4 doesnt display my components views -

im learning use angular 4 , im not being able render more 1 template, starting app template ok, , renders fine, created 2 more components "ng g component newcomponent" , im not being able make them display anything. can type new components url in browser , navigates fine without errors, displays app.component.html files this: app.component.html <!--the content below placeholder , can replaced.--> <p> asdasdasdas </p> app.component.ts import { component } '@angular/core'; @component({ selector: 'app-root', templateurl: './app.component.html', styleurls: ['./app.component.less'] }) export class appcomponent { } app.module.ts import { browsermodule } '@angular/platform-browser'; import { ngmodule } '@angular/core'; import { routermodule, routes } '@angular/router'; import { appcomponent } './app.component'; import { logincomponent } './login/login.component'; impor...

c# - Register multiple DbContext for IUnitOfWork using Unity IOC -

i using repository pattern unit of work using iunitofwork via https://github.com/ziyasal-archive/repositoryt.entityframework/tree/master/repositoryt.entityframework sample ioc registration given under https://github.com/ziyasal-archive/repositoryt.entityframework/blob/master/repositoryt.entityframework.autofacconsolesample/ioc.cs when have multiple dbcontext in project , need register iunitofwork how can correct registration ioc? seems pick last registration example container.registertype<iunitofwork, efunitofwork<sample1datacontext>>(new containercontrolledlifetimemanager()); container.registertype<iunitofwork, efunitofwork<sample2datacontext>>(new containercontrolledlifetimemanager()); when resolve return me sample2datacontext https://github.com/ziyasal-archive/repositoryt.entityframework/issues/11 unity let have 1 "default" mapping. if wish map 1 "from" type ( iunitofwork ) multiple "to" ...

oauth 2.0 - SOAP UI: Trying to automate Oauth2 Token -

version using ready api 1.9 hi everyone, i trying automate steps automating oauth token not working. below steps performed 1) created test step in ready api 2) created profile in auth tab 3) entered values client id, auth url,redirect url , scope. 4) click on automation 5) here need write javascript automate user login page but right not invoking javascript code. have tried writing simple hello world example alert("hello world"); ,but doesnot seem working.

amazon ec2 - How to iterate over all aws_instances in terraform? -

i'm relatively new terraform , i'm trying iterate on aws_instances apply null_resource. can use multiple splats access instances, regardless of names? the ec2 instances broken down 3 types: aws_instance.web.* (3 instances) aws_instance.app.* (3 instances) aws_instance.db.* (2 instances) here's attempt apply null_resource 8 aws_instances: resource "null_resource" "install_security_package" { #count = "${length(aws_instance)}" #terraform error: resource count can't reference variable: aws_instance #count = "${length(aws_instance.*)}" #terraform error: resource variables must 3 parts: type.name.attr count = "${length(aws_instance.*.*)}" #terraform error: unknown resource 'aws_instance.*' connection { type = "ssh" host = "${element(aws_instance.*.private_ip, count.index)}" user = "${lookup(var.user, var.platform)}" private_key ...

ssl - HTTPS proxy with caddy -

i working golang app , caddy http server. golang app rejects every http connection, can used on https. app kind of api/service consumed other apps. as, requires https installed caddy can take advantage of automatic ssl certificate , use proxy switch between ports. the application running in port 9000, so, consumers writte mysite.com , caddy should in charge of redirect petitions port 9000 maintaining https. configuration in caddy site is: mysite.com { proxy / :9000 { max_fails 1 } log logfile } nevertheless, seems when proxy made https lost. checked logs application (no logs of caddy) , this: http: tls handshake error xxx.xxx.xxx.xxx:xxxx: tls: oversized record received length 21536 so, based in error, me looks http proxy made caddy losing https. can do? from caddy docs to destination endpoint proxy to. @ least 1 required, multiple may specified. if scheme (http/https) not specified, http used. unix sockets may used prefixing ...

java - InteliJ -- Gradle 'test' project refresh failed Error:Error:Could not create parent directory for lock file -

i new gradle, using intelij, start new project using using gradle, when try refresh build.gradle, says gradle 'test' project refresh failed error:error:could not create parent directory lock file c:\program files\gradle-2.7\wrapper\dists\gradle-3.5-rc-2-bin\ktl4k9rdug30mawecgppf5ms\gradle-3.5-rc-2-bin.zip.lck any ideas how fix this? this build.gradle group 'com.maxinrui' version '1.0-snapshot' buildscript{ repositories{ mavencentral() } dependencies{ classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.6.release' } } apply plugin: 'java' sourcecompatibility = 1.8 repositories { mavencentral() } dependencies { compile 'org.springframework.boot:spring-boot-starter-web:1.2.6.release' } i think issue classpath, check build path. if not set need set. can set classpath 'com.android.tools.build:gradle:2.3.0' , add distributionurl=https\://services.gradle....

javascript - Closing a secondary navigation menu with jQuery -

i took contracting work , part of involves using jquery, i've never used before. seems pretty trivial, haven't been able our secondary navigation menu close when clicks outside of menu. here code: $(".products-list li").on("click",function(){// selected product item $('.products-list li').removeclass('active'); $(this).addclass('active'); }); $("#navigation-menus").on("click",function(){ // menus close outside click $('#navigation-menus').removeclass('open'); console.log('the function being called'); $('.navigation-panel').removeclass('open'); $('.menus-main-list').removeclass('open'); }); $("#menu-product").hover(function (){ $('#navigation-menus').addclass('open'); $('#product-menu-list-2').removeclass('open'); $('#product-menu-list-1').addclass...

web services - Can a php file securely accept requests from ANY other domain / website? -

i hope question isn't general. unsure post advice on otherwise: i have html5 application living on webpage (to specific, it's webgl game published unity3d). want check url game runs , if doesn't match pre-approved list of urls, should "phone home" , ping php file on server, record referring url, , possibly email daily summary of these referrers. example use-case: if copied game , installed on own website without permission, ping server , record game is. i know how check url, know how call url, know cron job necessary emailing, etc... what don't know , question here is: possible webgl game silently call own server else's or cross-domain security in way , block it? or cause prompt pop up? etc? don't know part , trying figure out need hire , scope of job. if it's not possible, i'd rather abandon idea completely. just make sure enable cors in "php file" here how: https://enable-cors.org/server_php.html ...you menti...

.net - Find visual studio release on which an exe/dll was build (C#) -

if build exe/dll "enterprise" visual studio different 1 build "community" vs? are there ways determine if exe/dll built "enterprise" version or "community" version? versions of vs such enterprise , community differences in features available in visual studio ide. when build solution/project, that's got .net version you're using, , different build types such debug build , release build. think of 2 body of car , engine; ide body , host of modifications can it, , .net engine. so if use same .net version , build (release/debug) there no difference in executables whether build them on community or enterprise.

javascript - Change AngularJS ngTrim Behavior -

i using angularjs version 1.5.6. have large application lots of text areas , text inputs. discovered bug today caused default angularjs behavior of trimming input text type inputs. change behavior trimming default not trimming default. is there easy way rather go through hundreds of textareas , text inputs in application. (perhaps globally or writing own directive?) here documentation page describing default behavior of ng-trim (ngtrim). https://docs.angularjs.org/api/ng/input/input%5btext%5d the below directive should work input type=text fields. set value of ngtrim false default every input field. , similar 1 can created textarea if required. .directive('input', function($compile){ return { link(scope, element, attrs) { if (element.attr('type') === 'text') { attrs.$set('ngtrim', 'false'); } } }; });

flash - Chronometer - Action Script 2.0 Local Storage -

1º. sorry english :) 2º. im newbie on this, nice please! local storage - action script 2.0 on adobe flash. have fla file, chronometer of records, days, hours, minutes , seconds. thing is, wanna save time on local storage, tried did not work. can u me please? here´s code: stop(); // stop scene animation timerclip.stop(); // stop movieclip animation // initialise variables var day:number = 121; var hour:number = 23; var minute:number = 59; var second:number = 47; var record:number = 000; timerclip.onenterframe = function() { if (this._currentframe == 30) { second += 1; // seconds if (second > 59) { second = 0; seconds.text = "0" + second; minute += 1; // minutes if (minute >= 10) { minutes.text = minute; } else { minutes.text = "0" + minute; } // hours if (minute > 59) { minute = 0; minu...

Sorting 2 sets of scores with array in java -

i wrote following code rank 2 sets of scores: public class scoreranking { public static void main(string[] args) { int[] score1 = { 9, 3, 6, 19 }; int[] score2 = { 3, 3, 3, 3, 3, 5, 1 }; int[] rank1 = sortscores(score1); int[] rank2 = sortscores(score2); (int = 0; < rank1.length; i++) { system.out.println((i + 1) + ": " + rank1[i]); } system.out.println("_________\n"); (int j = 0; j < rank2.length; j++) { system.out.println((j + 1) + ": " + rank2[j]); } } static int[] sortscores(int[] sort) { (int = 0; < sort.length - 1; i++) { if (sort[i] < sort[i + 1]) { continue; } else { int temp = sort[i]; sort[i] = sort[i + 1]; sort[i + 1] = temp; } } return sort; } } the first set ordered second isn't. p...

stylecop - How to reference an old assembly in ASP.NET Core (.NET Framework targeting) project? -

i'm building asp.net core project (with target framework .net framework 4.5.2), in solution of bunch of .net framework projects. i'm referencing 1 of projects uses stylecop.msbuild . however, when dotnet build , i'm getting: c:\mysolution\nupkgs\stylecop.msbuild.4.7.54.0\build\stylecop.msbuild.targets(101,5): error msb4062: "stylecoptask" task not loaded assembly c:\mysolution\nupkgs\stylecop.msbuild.4.7.54.0\build\..\tools\stylecop.dll. not load file or assembly 'system.windows.forms, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089'. system cannot find file specified. confirm <usingtask> declaration correct, assembly , dependencies available, , task contains public class implements microsoft.build.framework.itask. [ c:\mysolution\src\myproject\myproject.csproj] where myproject project i'm trying reference. i've tried including system.windows.forms dependency, it's version 4.0.0.0 rather 2.0.0.0, didn'...

c# - Checkbox is only getting value from one checkbox. I need to get value for multiple checkboxes when selected -

i'm having issues trying checkbox receive multiple values when checked. i'm using dynamic gridview. when checkbox checked , start button clicked services suppose start. 1 service starting , value other services checked reading false. know i'm doing wrong. in advance! <asp:panel id="panel1" runat="server"> <asp:gridview id="gridview1" runat="server" style="font-size: 15pt" autogeneratecolumns="false"> <columns> <asp:boundfield datafield="servicename" headertext="service name" /> <asp:boundfield datafield="description" headertext="description" /> <asp:boundfield datafield="status" headertext="status" /> <asp:templatefield> <itemtemplate> <asp:checkbox id="chkstatus" enabled="true" runat="server" /> </itemtempla...

node.js - Angular 4 Scoket io webpack error -

i have installed socket.io , typings in angular 4. new angular 4. every time try ng server bellow errors npm --save @types/socket.io npm install --save express body-parser http-status mongoose socket.io imported in component import * io 'socket.io-client'; on ng server following errors. can me out fix this. error in ./~/socket.io-client/lib/index.js module not found: error: can't resolve 'socket.io-parser' in 'h:\users\home\desktop\routing-final\node_modules\socket.io-client\lib' @ ./~/socket.io-client/lib/index.js 7:13-40 @ ./src/app/servers/servers.component.ts @ ./src/app/app.module.ts @ ./src/main.ts @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts error in ./~/socket.io-client/lib/manager.js module not found: error: can't resolve 'socket.io-parser' in 'h:\users\home\desktop\routing-final\node_modules\socket.io-client\lib' @ ./~/socket.io-client/lib/manager.js 9:13-40 @ ./~/socket.io-cl...

Collapse columns in a dataframe (R) -

basically, have dataframe, df beginning1 protein2 protein3 protein4 biomarker1 pathway3 g na na f pathway8 z g na na e pathway9 g z h f pathway6 y g z h e pathway2 g d na f pathway5 q g d na e pathway1 d k na f pathway7 b c d f pathway4 v b c d e and want combine dataframe rows when identical "protein2" "protein4" condense, giving following: beginning1 protein2 protein3 protein4 biomarker1 pathway3 a,z g na na f,e pathway9 a,y g ...

javascript - Multi-select Drop-down filter AngularJS Logic -

thanks taking time read question. working on angularjs ui-grid, i've implemented multi-select drop-down menu "first name" column. however, having issues understanding how implement logic did "male" & "female" column since multi-select. if please me on logic example have created first column "first name". @ least guidance appreciated. thank in advance! also, may notice grid broken, header row stuck , not scrolling horizontally. has been fixed! here plunker! https://plnkr.co/edit/caizoibpyzgdpfwspabk?p=preview here of angular & html code! know code not dry, refactoring code shortly. <head> <meta charset="utf-8" /> <title>angularjs plunker</title> <script>document.write('<base href="' + document.location + '" />');</script> <script data-require="angular.js@1.5.x" src="https://cdnjs.cloudflare.com/ajax/libs/angu...