Posts

Showing posts from May, 2010

jquery - Blur Effect when switching/closing Modals -

i want have durable blur effect on background when open/switch modal clicking button. what have far: i have button, on click open bootstrap modal. in modal can click again on button switch modal, means first modal hides , second 1 comes in. second modal can switch first or close it. when open first modal clicking button, background has blur effect. if close modal clicking close button blur effect disappear. effect disappears when click outside modal, modal close. code: <button data-toggle="modal" data-target="#loginmodal"> <span class="glyphicon glyphicon-log-in"></span> </button> <section role="region"> <div class="modal fade" id="registermodal" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> /* similar loginmodal */ </div> </div> <...

javascript - How do I access methods from one JS file from another in a Swift 3 WKWebview project? -

i have loaded external js file dom wkwebview. works fine. trying add functionality javascript library. have tried loading js file , importing method external library it. have tried loading both js files dom adduserscript, , doesn't seem work (specifically prevents code worked running) i know correct method have both files loaded dom can use methods library in js file. library optimal-select , using single file version optimal-select.js i have not added code because works without second js file. add code if necessary

wpf - Check if something is overlapping my window? -

how check if overlapping window? i found winforms code should trick: public static bool isoverlapped(iwin32window window) { if (window == null) throw new argumentnullexception("window"); if (window.handle == intptr.zero) throw new invalidoperationexception("window not yet exist"); if (!iswindowvisible(window.handle)) return false; intptr hwnd = window.handle; hashset<intptr> visited = new hashset<intptr> { hwnd }; // set used make calling getwindow in loop stable checking if have // visited window returned getwindow. avoids possibility of infinate loop. rect thisrect; getwindowrect(hwnd, out thisrect); while ((hwnd = getwindow(hwnd, gw_hwndprev)) != intptr.zero && !visited.contains(hwnd)) { visited.add(hwnd); rect testrect, intersection; if (iswindowvisible(hwnd) && getwindowrect(hwnd, out testrect) && intersectrect(out interse...

javascript - Vue App structuring -

Image
i trying build first webapp using vue.js now 2 days of tutorials deep still not 100% sure how structure basic application. using vue-cli , webpack makes nice structure, including /src folder components , /router folder routing. now plan create todo app. want dynamically switch between [show todos] , [add todo], form submit button. have achieved using without components , cli. my structure be: app.vue -> buttons 2 router-link components/showtodos.vue & components/addtodos.vue components/showtodos.vue -> table including todo list components/addtodos.vue -> form submit button now routing part works, able switch between 2 components. now 2 questions: how can push information form in addtodos component array in showtodos component in order loop through there ? is proper way structure vue app, , if not how can improve ? thank much. this first time me using component based js framework, pretty hard follow along. on structuring vuejs app...

php - If I host my web app in AWS Do I have to use S3 -

i have web application store images , videos.im using php.is make sense if use s3 instead of store in file server since both in aws ( web server , file storage) yes. recommend. s3 object storage service provided aws. place store static files images/videos/css/javascript can serve directly without putting more load on servers. there many benefits if use s3, 99.999999999% durability , 99.99% availability of files scalability on demand provide file caching support integration of cloudfront - load files faster granular access management of files private content distribution cloudfront signed urls stream media cloudfront viewers across globe ability protect data encryption (eg: sse-s3, sse-kms) lifecycle management of files eg: archiving @ low cost easy set of disaster recovery cross region replication of files you may use aws sdk php interact s3 server.

How to set the spf or 'sent via' in email header in php -

when receive email (in gmail @ least), see following format @ top: 'john doe johndoe@gmail.com via servername.com' wondering if there way change 'servername.com' after "via" while in doing keeping defined headers in php code below, great: <?php $to = 'johndoe@gmail.com'; $message = 'blah'; $subject = 'blahblah'; $headers = 'from: test@gmail.com'; mail($to,$subject,$message,$headers); ?> that's set mta. postfix can tell it's determined myorigin parameter in main.cf .

postgresql - Querying postgres from c# using npgsql -

i have installed postgres in windows machine , started working on poc. able connect database windows command line. but, unable connect c# application. it seems have issues in connection string. have gone through multiple tutorials every tutorial has own way of providing connection string parameters.is there standard way of giving hostname,port,username,password , database. i trying query using rest api. am, doing right way. // api/values [httpget] public iactionresult get() { test test = new test(); return ok(test.table2json()); } using npgsql; using system; namespace zeiss.mccneo.datamigration.utilities { public class test { private readonly npgsqlconnection conn; public test() { conn = new npgsqlconnection("server=127.0.0.1;user id=postgres;" + "password=postgres;database=postgres;"); //also tried using conn = new npgsqlconnection("server=127.0.0.1;port=5432;user ...

html - Specific responsive positioning on single page fullscreen jumbtron image + more -

essentially trying accomplish single-page website full screen background image using bootstrap. however, need logo , (2) buttons site positioned on page on desktop, reset have logo @ top , buttons placed vertically stacked below on mobile. i feel shouldn't complicated , accomplished bootstrap grid system struggling. this model of should ( desktop )( mobile ) the main issues having logo moving on center of image on laptops smaller screen size (with plenty of space on right) , mobile responsiveness being disaster. thanks. current html: <div class="jumbotron desktop"> <div class="container"> <div class="container-fluid"> <div class="container content"> <div class="container"> <div class="row"> <div class="col-md-12"> <img class="logo-img" src="http://via.placehold...

r - Remove unnecessary y-axis points with facet_wrap and geom_segment -

Image
i'm mapping y-axis points x-axis using geom_segment() , using facet_wrap separate data 2 plots; however, y-axis points showing on both plots. how can have necessary y-axis points pertaining each facet_wrap ? sample code dat <- structure(list(temp = c(1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5), rev = c(-5, -11, -20, -29, -40, -9, -20, -32, -45, -57, -12, -24, -37, -50, -62, -7, -20, -36, -52, -67, -5, -13, -23, -35, -47, -12, -24, -36, -48, -58), type = c("type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 1", "type 2", "type 2", "type 2", "type 2", "type 2", "type 2", "type 2", "type 2", "ty...

javascript - Reinitialize jssor slider -

i using angular js jssor slider follow. far concern, there no $destroy method jssor slider yet. need user click on refresh button , reinit jssor slider. as can see, won't work if reinit jssor slider clicking refresh function. i not want call .remove() function , bind html seems less angular way. there other method? i can't create own $destroy method jssor slider library source code uglify. angular.module('app', []) .controller('framecontroller', ['$scope', '$injector', function($scope, $injector) { initslider(); $scope.refresh = initslider; function initslider() { var image = []; var count = math.floor(math.random() * 6) + 1; (var = 0; < count; i++) { image.push('https://unsplash.it/600/' + * 100 + '?random'); } $scope.image = image; console.log($scope.image); function jssor_slider1_init(containerid) { var options = { $autoplay:...

Modern core method of uploading file in Perl -

i'm looking write script lets user upload image webpage, later use on website. per usual, can find examples involving cgi.pm. there core modules can use replacement? the perl core distribution contains no modules writing web applications. think want based on plack::request , plack::request::upload (for example dancer2::core::request::upload ).

python - How do I handle migrations as a Django package maintainer? -

i have been writing new django package pip-installable. i've been stuck awhile because i'm unsure how make migrations particular package allow normal workflow of install be: pip install package add package "installed_apps" run python manage.py migrate currently, package looks this: package_root/ dist/ actual_package/ __init__.py models.py setup.py the problem facing when package app , install using pip install dist/... , add example apps "installed_apps", running python manage.py migrate not create tables models in actual_package/models.py , hence (from users perspective) need run python manage.py makemigrations actual_package first, not ideal. any ideas on how have migrations sorted before user installs excellent. 1 - include initial migrations in package - e.g., actual_package/migrations/0001_initial.py 2 - include python manage.py migrate actual_package part of installation process - whether ne...

python - What is numpy.fft.rfft and numpy.fft.irfft and its equivalent code in MATLAB -

i converting python code matlab , 1 of code uses numpy rfft. in documentation of numpy, says real input. compute one-dimensional discrete fourier transform real input. so did in matlab using abs results different. python code ffta = np.fft.rfft(a) matlab code ffta = abs(fft(a)); what have misunderstood? the real fft in numpy uses fact fourier transform of real valued function "skew-symmetric", value @ frequency k complex conjugate of value @ frequency n-k k=1..n-1 (the correct term hermitian ). therefore rfft returns part of result corresponds nonpositive frequences. for input of size n rfft function returns part of fft output corresponding frequences @ or below n/2 . therefore output of rfft of size n/2+1 if n (all frequences 0 n/2 ), or (n+1)/2 if n odd (all frequences 0 (n-1)/2 ). observe function floor(n/2+1) returns correct output size both , odd input sizes. so reproduce rfft in matlab function rfft = rfft(a) ffta...

android - How to use text watcher to do match between 3 EditText? -

i code in below. doesn't work. need perform simple addition , simple subtraction based on 2 of field have input.... question ends... i needed make text because can't ask question if details isn't enough , code more details. i'm typing ask question. ignore , see code below. thank you java code : package com.test.easycount; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.text.editable; import android.text.textwatcher; import android.widget.edittext; import android.widget.toast; public class mainactivity extends appcompatactivity implements textwatcher { edittext num1, num2, sum; int fnumber, snumber, total; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); num1 = (edittext) findviewbyid(r.id.num1); num2 = (edittext) findviewbyid(r.id.num2); sum = (edittext) findviewbyid(r.i...

amazon web services - AWS Athena date_Part -

i'm trying truncate date day using athena. here's input , select statement like: create table ... usagestartdate timestamp, usageneddate timestamp, ... row format serde 'org.apache.hadoop.hive.serde2.lazy.lazysimpleserde' serdeproperties ( 'serialization.format' = ',', 'field.delim' = ',', "timestamp.formats" = "yyyy-mm-dd't'hh:mm:ss.sssss'z'") location 's3: day select... resource string day(usagestartdate) sum(usagehours) to retrieve date of timestamp column need use datetime functions underlying prestodb engine. so resulting select this: select date(usagestartdate) date, date_diff('hour',usagestartdate,usageenddate) hours usagetable

How to draw Isosceles Triangle in Java using only two for loops? -

i can able draw pattern triangle using 3 for-loops want draw using 2 for-loops. 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 1 2 3 4 5 6 7 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 program of mine 3 loops import java.util.scanner; class isotrg { public static void main(string[] args) { int n; system.out.println("enter no. line:"); scanner sc = new scanner(system.in); n = sc.nextint(); (int = 0; < (2 * n) - 1; i++) { int d = 1; if (i < n) { (int j = 0; j <= i; j++) { system.out.print(d + " "); d++; } system.out.println(); } else { for(int j = 1; j < (2 * n) - i; j++) { system.out.print(d + " "); d++; ...

How to deal with "java.lang.OutOfMemoryError: Java heap space" error (64MB heap size) -

i writing client-side swing application (graphical font designer) on java 5 . recently, running java.lang.outofmemoryerror: java heap space error because not being conservative on memory usage. user can open unlimited number of files, , program keeps opened objects in memory. after quick research found ergonomics in 5.0 java virtual machine , others saying on windows machine jvm defaults max heap size 64mb . given situation, how should deal constraint? i increase max heap size using command line option java, require figuring out available ram , writing launching program or script. besides, increasing finite max not rid of issue. i rewrite of code persist objects file system (using database same thing) free memory. work, it's lot work too. if point me details of above ideas or alternatives automatic virtual memory, extending heap size dynamically , great. ultimately have finite max of heap use no matter platform running on. in windows 32 bit around 2gb (not...

lambda - Java, why collections.sort() still works with non-comparator typed argument? -

i know in java collections class, there static method sort: sort(list<t> list, comparator<? super t> c**) the second argument in sort should object implements comparator interface , it's compare method. but when learn lambda's method reference , see example: public class test { public static void main(string[] args) { new test().sortword(); } public void sortword() { list<string> lst = new arraylist<>(); lst.add("hello"); lst.add("world"); lst.add("apple"); lst.add("zipcode"); collections.sort(lst, this::compareword); system.out.println(lst); } public int compareword(string a, string b) { return a.compareto(b); } } this example of method reference instance method. compareword method has nothing comparator interface, can not understand why works? can explain this? thank much. ...

java - Difference between JScrollPane.setviewportview vs JScrollPane.add -

Image
i faced new thing today, , didn't know why. when want show in panel example, add panel; why cannot add table scroll pane directly, , why have call setviewportview() method? add() method , setviewprotview() do? basically, should not use jscrollpane#add . jscrollpane has single component attached it, jviewport , jscrollpane uses display component added view port. setviewportview convenience method for jscrollpane#getviewport#setview the basic concept comes down fact scroll panes point of view, show single component, add doesn't make sense it. method consequence of extending jcomponent -> container

html - shuffling a nodelist and traversing dom properly in javascript -

this has been kind of hard question explain i'll best.. basically, have raffle app (of sorts). have grid of images assigned names(captions) , created dynamically using javascript. end goal of have each picture on different spot on grid different name every time button clicked. names captured textarea , stored array. part, have working. issue when button clicked, images , names not random independent of each other. in other words, images move on grid, names stay same each picture. i merely want shuffle p tags around. know it's because img , p tags part of same div, i'm lost on how these separately while still keeping grid form, otherwise things start going out of place. grid uses bootstrap. now line in particular did sort of work me: tdisplay.getelementsbytagname("p") [math.random() * tdisplay.children.length | 0].textcontent = names[math.random() * tdisplay.children.length | 0]; i know it's long , ugly, rough draft, problem not want names appeari...

linux - Send/Receive AT commands to GSM modem in python -

i want write simple code in python send ussd codes gsm modem (d-link dwm-157) , receive results , store them in variables. can connect modem minicom , miniterm.py. problem need terminal send/receive @ commands modem. don't want terminal. use following code send simple @ command when run code nothing happens: import serial, time def serial_def(): ser = serial.serial() ser.port = "/dev/ttyusb2" ser.baudrate = 115200 ser.bytesize = serial.eightbits #number of bits per bytes ser.parity = serial.parity_none #set parity check: no parity ser.stopbits = serial.stopbits_one #number of stop bits ser.timeout = 2 #timeout block read ser.xonxoff = false #disable software flow control ser.rtscts = false #disable hardware (rts/cts) flow control ser.dsrdtr = false #disable hardware (dsr/dtr) flow control ser.writetimeout = 2 ser.open() if ser.isopen(): print(ser.name + ' open...') ...

arrays - Swift - Cascading Pickers -

Image
assuming have 3 pickers following content: restaurant{ [menu] name } menu{ [ingredients] time } ingredients{ ... } how can implement picker updates automatically if objects changes? (e.g. when restaurant picked, menu , ingredients changes, when menu picked ingredients changes) you can this: class viewcontroller: uiviewcontroller, uipickerviewdatasource, uipickerviewdelegate { @iboutlet weak var restaurantspicker: uipickerview! @iboutlet weak var menupicker: uipickerview! @iboutlet weak var ingredientspicker: uipickerview! var restaurants = ["r1", "r2", "r3"] var menus = ["r1": ["m1", "m2"], "r2": ["m2"], "r3": ["m1", "m3"]] var ingredients = ["m1":["i1", "i2", "i3"], "m2":["i1", "i3"], ...

java - Illegal argument error while setting foreign key -

org.springframework.web.util.nestedservletexception: handler dispatch failed; nested exception java.lang.error: unresolved compilation problem: method settbldepartment(tbldepartment) in type tblproject not applicable arguments (long) code in service layer public void setfkdeptidforproject(long projectid, long departmentid) { tblproject existproj=projectdao.get(projectid); tbldepartment dept= new tbldepartment(); dept.setpkdepartmentid(departmentid); existproj.settbldepartment(dept); projectdao.update(existproj); } tblproject.class @manytoone(fetch = fetchtype.lazy) @joincolumn(name = "fk_department_id") public tbldepartment gettbldepartment() { return this.tbldepartment; } public void settbldepartment(tbldepartment tbldepartment) { this.tbldepartment = tbldepartment; }

ubuntu - Python uninstall woes -

i setting first python package described here , seemed necessary python 2.7.13 finish. not realizing how integral python 2.7.12 ubuntu's health, moved 2.7.12 dirs (/usr/local/lib/python2.7/) backup dirs , replaced them 2.7.13 dirs , removed python3. led series of problems killed desktop (no launcher, no alt-t terminal) after lengthy battle required me alt-f1 non-gui terminal, undo directory swaps, , detailed here after sudo apt-get install --reinstall python2.7 sudo apt-get install python3-all and sudo apt-get install ubuntu-desktop things normal except can't reinstall pip (to use ipython amongst others) due lacking ctypes. i'm willing reinstall ubuntu if have to. jeremy@jr:~$ python python 2.7.12 (default, nov 19 2016, 06:48:10) [gcc 5.4.0 20160609] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import ctypes traceback (most recent call last): file "<stdin>...

android - Meteor Cordova - Login service configuration not yet loaded -

i've setup oauth login (google, facebook, linkedin, twitter) meteor - cordova app , runs on browser (both localhost , staging page). i tried run app on android device via command: meteor run android-device --settings settings/localhost.json . when , clicked oauth login buttons, got error: login service configuration not yet loaded , failed login. tried using app on browser via localhost:3000 , runs well. i looked error on internet , seems serviceconfiguration data hasn't been published mobile devices, hence error. no matter how long "wait", serviceconfiguration data never comes ! can tell logging accounts.loginservicesconfigured() out. i'm literally stuck i'm looking help.

python - Django - invalid literal for int() with base 10: ''' -

invalid literal int() base 10: ''' is error occurring. recieving error whilst trying update database register pcap files. following line on error occurs pcaps.objects.update_or_create(filename=pcapname, filehash=malwarehash, uuid=uuid) here model inserting. class pcaps(models.model): filename = models.charfield(max_length=100, default='') datetime = models.datetimefield(default=datetime.now, blank=true) filehash = models.foreignkey(malwares) uuid = models.foreignkey(system)

php - Swiftmail parsing error -

i moved swiftmailer people have said things it. when used documentation on how set up, i'm getting strange error. if code wrong. the error showing : parse error: syntax error, unexpected '?' in mailer\classes\swift\transport\esmtptransport.php on line 211 i haven't modified file atoll , it's throwing error. i'm calling username , password config file giving them define php function. my code being used : define("authentication_donotredirect", 1); require("../main_config.php"); $site_config = new site_config(); $from = $site_config->grabsitesettings_manual($con, 'name'); require 'mailer/swift_required.php'; $transport = swift_smtptransport::newinstance('smtp.gmail.com',465,'ssl')->setusername(gmail_mail)->setpassword(gmail_pass); $swift = swift_message::newinstance($transport); $content = "this test message."; $message = swift_message::newin...

android - Debugging on Google Cloud Platform -

i developing new android app , development environment (android studio 2.3) installed on virtual machine hosted in google cloud platform. after quite lot of research still not able debug app, neither through android emulator, nor using device connected usb port of laptop. this, of course, slows down work i'm not able see errors caused programming. is there different do?

java - How does AWS Lambda serve multiple requests? -

how aws lambda serve multiple requests? want know multi-thread kind of model here well? if calling lambda api gateway. , there 1000 requests in 10 secs api. how many containers created , how many threads. how aws lambda serve multiple requests? independently. i want know multi-thread kind of model here well? no, not multi-threaded model in sense asking. your code can of course written use multiple threads and/or child processes accomplish whatever purpose intended accomplish for 1 invocation , lambda doesn't send more 1 invocation @ time same container. container not used second invocation until first 1 finishes. if second request arrives while first 1 running, second 1 run in different container. if calling lambda api gateway. , there 1000 requests in 10 secs api. how many containers created , how many threads? as many containers created needed process each of arriving requests in own container. the duration of each invocation largest d...

javascript - How to See Only the Image of Chart -

below code generates image of chart after chart has been generated. want see image. possible? i tried display: none; chart's div image doesn't seem. $(function() { var ctx = document.getelementbyid('mychart'); var mychart = new chart(ctx, { type: 'line', data: { labels: ["july","august","september","october","november","december","january","february","march","april"], datasets: [ { label: 'this year', data: [340,0,450,3240,360,200,0,0,1445,350], } , { label: 'last year', data: [330,340,100,160,560,3600,320,0,397.5,300], } ] }, options: { maintainaspectratio: false, ...

class - What is the purpose of a static method in interface from Java 8? -

why static methods supported java 8? difference between 2 lines in main method in below code? package sample; public class { public static void dosomething() { system.out.println("make something!"); } } public interface { public static void dosomething() { system.out.println("make something!"); } } public class b { public static void main(string[] args) { a.dosomething(); //difference between i.dosomething(); //and } } as can see above, not implemented in b. purpose serve have static method in interface when can write same static method in class , call it? introduced other purpose modularity. , modularity, mean following: public interface singable { public void sing(); public static string getdefaultscale() { return "a minor"; } } just put methods together. in past, if had interface foo , wanted group interface-related utils or factory methods, n...

javascript - Sliding the images in ionic 2 -

Image
i have set of images added ion-slides, however, when drag slide next slide, want current slide zoom out , next slide zoom in. html code : <ion-content> <ion-slides class="image-slider" loop="true" slidesperview="2" direction="horizontal" zoom="true" (ionslidedrag)="slidemoved()" (ionslidedidchange)="slidedidchange()"> <ion-slide *ngfor="let img of images" > <img src="http://lorempixel.com/200/200/cats/{{img}}" class="thumb-img" /> </ion-slide> </ion-slides> </ion-content> on dragging, slidemoved() function called .ts file : slidemoved() { this.scalecurrentval = 1; this.scalepreviousval = 0.5; let curr = this.slides.getactiveindex(); let htmlidactive = this.slides._slides[curr]; htmlidacti...

java - setcolspan on dynamic table notworking -

my code: while (i<jsonarraymatakuliah.length()) { jsonobject jomk = jsonarraymatakuliah.getjsonobject(i); no = jomk.getstring("no"); kls= jomk.getstring("kls"); nilaihuruf=jomk.getstring("nilaihuruf"); nilaiangka=jomk.getstring("nilaiangka"); nmk= jomk.getstring("nmk"); sks= jomk.getstring("sks"); tot = jomk.getstring("tot"); linearlayout.layoutparams llp = new tablerow.layoutparams(tablerow.layoutparams.match_parent,tablerow.layoutparams.wrap_content,1.0f); llp.setmargins(2, 2, 2, 2); // linearlayout.layoutparams llp1 = new tablerow.layoutparams(tablerow.layoutparams.match_parent, viewgroup.layoutparams.wrap_content,1.0f); // llp1.setmargins(2, 2, 2, 2...

excel - How to convert matrix to 4-column table without using VBA (Data - PivotTable and PivotChart Report) -

i need convert excel matrix "a" table "b", not using vba. preferably 'reverse pivot', 'unpivot', 'flatten', 'normalize'... picture of have , need receive there similar topics, couldn't find exact 1 interested in. here described looking for, done in vba: excel macro(vba) transpose multiple columns multiple rows , here without vba, 1 column kept , repeated: convert matrix 3-column table ('reverse pivot', 'unpivot', 'flatten', 'normalize') focussing on 2 sets of quantities, essence of want transform table "a" n columns , 3 rows table "b" 3*n rows , 1 column. a couple of helper columns left (or right) of table "b" can used identify row , column of "a" match each of rows in table "b". these helper columns like row col 1 1 2 1 3 1 ... n 1 1 2 2 2 3 2 ... n 2 1 3 2 3 3 3 ... n 3 starting i...

swift - Eliminate repeating letters from Strings -

eliminate repeating letters strings in swift var name1 : string = "sandeep" var name2 : string = "warrior" var name3 : string = name1+name2 var name4 : string = //output should sndpwio in name 4, want eliminate repeating letters name 3. how can achieve this? name1 , name2 coming text box user. use nscountedset count hold many times each character appears, filter appear once: swift 3 let countedset = nscountedset(array: name3.characters.map { $0 }) let name4 = string(name3.characters.filter { countedset.count(for: $0) == 1 }) swift 4 in swift 4, string collection of characters again can shorten code this: let countedset = nscountedset(array: name3.map { $0 }) let name4 = name3.filter { countedset.count(for: $0) == 1}

asp.net web api - webapi-use claims with windows authentication -

Image
the method has been secured roles=admin: [authorize(roles = "admin")] public class valuescontroller : apicontroller { // api/values public ienumerable<string> get() { return new string[] { "value1", "value2" }; }} i use claims webapi project individual user account selected claim admin injected in public class applicationuser : identityuser { public async task<claimsidentity> generateuseridentityasync(usermanager<applicationuser> manager, string authenticationtype) { // note authenticationtype must match 1 defined in cookieauthenticationoptions.authenticationtype var useridentity = await manager.createidentityasync(this, authenticationtype); // add custom user claims here useridentity.addclaim(new claim(claimtypes.role, "admin")); return useridentity; } } now want test windows authentication option iauthenticationfilter implemen...

swift - How to add countdowntimer which will run in whole iOS application? -

i need add global timer of 60 minutes in application show in viewcontrollers. not able implement feature. i have implemented timer in 1 viewcontroller till now. here code: var timercount = 3600 var timer = timer() timer = timer.scheduledtimer(timeinterval: 1.0, target: self, selector: #selector(update), userinfo: nil, repeats: true) func update() { if(timercount > 0){ let minutes = string(timercount / 60) let seconds = string(timercount % 60) timelbl.text = minutes + ":" + seconds timercount -= 1 } else { timer.invalidate() let vc = storyboard?.instantiateviewcontroller(withidentifier: "navigateviewcontroller") navigationcontroller?.pushviewcontroller(vc!, animated: true) } } i need show timer value in every viewcontroller of application. // create class timermanager class timermanager { var timercount = 3600 static let sharedinstance = timermanager() ...

android - Expected resource of type ID -

Image
i using anko build simple project. when try set id edittext getting following error. ensures resource id's passed apis of right type; example, calling resources.getcolor(r.string.name) wrong. import android.support.v7.app.appcompatactivity import android.os.bundle import org.jetbrains.anko.* class mainactivity : appcompatactivity() { override fun oncreate(savedinstancestate: bundle?) { super.oncreate(savedinstancestate) relativelayout { edittext{ id = 1 } } } } you can either use id references ( r.id.something ) or negative integers -16777215 -1 (and ignore warning). suitable negative integers can generated using view.generateviewid() method available since api 17. source code available here . you'll have remember generated values yourself. generating r.id covered in other answers. i trying same getting error the video published on year ago , lint didn't warn kotlin code then.