Posts

Showing posts from May, 2015

php - Mikrtotik - Internal login page causing Infinte loops -

i trying use mikrotik hotspot following scenario. when user connected hotspot, login.html page redirect external page index.php check exist user csv. if user exist redirect redirect.html . if user not exist redirect register.html & register.php store user info in csv file. whole upper scenario working fine. the main problem when redirect.html called, browser loops between external server address , internal server address repeatedly , rapidly. here login.html code <html> <head> <title>bmc hotspot</title> <meta http-equiv="pragma" content="no-cache"> <script type="text/javascript" src="/hotspot/jquery.min.js"></script> <script type="text/javascript"> var js_var = '$(mac)'; $(document).ready(function () { window.location = "http://192.168.88.247/index.php?mac=" + js_var; })...

javascript - Select2 Always show placeholder -

i using select2 component selection. i fiddled example here: https://fiddle.jshell.net/mmo2dqno/15/ what trying is: select item via select2 widget show item in div below dont show label in search box. this works fine. problem is, when 1 item selected, searchbox isn't showing placeholder attribute anymore. how can tell browser assume input empty , show placeholder again? you kill select2 plugin js, , load again. or use js choose disabled placeholder option.

c# - Creating objects inside async thread causes STA exception -

i have class, should show messages user, when status of operation changed, this: public static class autoupdater { public static async void autoupdatecheck() { updaterstatus.currentupdatestatus = await updaterlogic.checkforupdateasync(); } public static void onstatuschanged() { switch (updaterstatus.currentstatus) { case updatestatus.updatefound: { message toadd = new message("some params"); //exception here messagesmanager.addnewmessage(toadd); break; } //some other cases } } when app starts, subscribe autoupdater event this: updaterstatus.eventstatuschanged += (sender, args) => { autoupdater.onstatuschanged(); }; the exception is: " the calling thread must sta, because many...

java - Calling a outside class method from Jar class -

i have created class " class b " package com.b public class b { public void printmsg() { system.out.println("called"); } } i have created jar file below class " class a " package com.a import com.b public class extends b { } when tried load jar dynamically using below code, getting error " class b " " classnotfoundexception " classloader cl = new urlclassloader(new url[] { new url(jarfullpath) }); class<?> cla = cl.loadclass(classname); object obj = cla.newinstance(); i believe because did not provide parent classloader urlclassloader such can find a not b , try instead: classloader cl = new urlclassloader( new url[] {new url(jarfullpath)}, thread.currentthread().getcontextclassloader() ); this use thread.currentthread().getcontextclassloader() parent classloader corresponding context classloader .

sql - Access 2010 How to differentiate between users with same name -

i have access 2010 database student names. each student has unique id. want design form record student visited library on date. problem 2 or more students can have same name. question 1: how design form enter date visited library. cannot expect person remember student name , id. id nothing indexed column in access. question 2: how should design form? should user first search student , how add record student? or there field allow me choose student , populate id? any ideas? joe make relationship between students , visits table. then, on visits form, make combo box choose student (the source of combo query students table have additional details identify, such middle name , birth year , city , hair color or whatever want) and put textboxes on form visit date , library , on.

How to see that a scheduled task is started manually, but not by the timer in nopcommerce -

in nopcommerce scheduled task started timer, have possibility start manually. is possible in make distinction in code, whether task started timer or started manually? in case want task run on saterdays because large batchjob: if (datetime.now.dayofweek != dayofweek.saturday) { return; // don't task } but start , run manually if situation demands it. bool startedmanually = _some_magic_here_please; // <- here? if (datetime.now.dayofweek != dayofweek.saturday && !startedmanually) { return; // don't task } it not supported without source code modification, furthermore taskmanager , taskthread classes not implement interface , not registered via ioc container cannot make required changes without changes in nop.services project, there no posibility add-on or extension. you can workaround duplicating task, can keep task weekdays constraints enabled in scheluder , other task no weekdays constraints disabled (just manual execution). disabled tas...

html - How can I set name to excel sheet in PHP? -

am generating .xls file <table> tags. export working fine. have set name sheet. code follows: <h2>==>> export table excel file <<==</h2> <?php echo $excel_data = '<table border="1"> <thead> <th width="1"></th> <th align="left">s.no.</th> <th align="left">name</th> <th align="left">doj</th> </thead> <tbody> <tr> <td width="1"></td> <td align="left">1</td> <td align="left">sreekanth kuriyala</td> <td align="left">04-06-2015</td> </tr> <tr> <td width="1"></td> <td align="left">...

node.js - Nested Operations in Handlebars -

i want use nested operation in handlerbars if(value == "a" || value == "b") how can create equations using handlebar. thanks in advance create helper (i use underscore.js simplicify): eq.js handlebars.registerhelper('eq', function() { var i, options, val1, vals; val1 = arguments[0], vals = 3 <= arguments.length ? slice.call(arguments, 1, = arguments.length - 1) : (i = 1, []), options = arguments[i++]; return _.any(vals, function(val) { return val1 === val; }); }); or eq.coffee handlebars.registerhelper 'eq', (val1, vals..., options) -> _.any vals, (val) -> val1 val and use: {{eq value 'a' 'b'}}

How to query multiply 2 cell for each row using Realm? -

i have 1 table has 2 fields quantity , price , want multiply both fields value: here want possible using mysql quantity| price | total 6 | 2 | null // should 12 2 | 10 | null // should 20 above can done using select quantity, price, quantity* price 'total' mytable i want same result using realm query .. how can achieve ..any appriciated .. thank you. using realm android, you'd need add new field, , custom setters. this solution supported 0.88.0+ public class extends realmobject { private long quantity; private long price; private long total; public long getquantity() { return quantity; } public long getprice() { return price; } public long gettotal() { return total; } public void setquantity(long quantity) { this.quantity = quantity; this.total = this.quantity * price; } public void setprice(long price) { this.price =...

c# - Catching an exception -

i'm getting exception thrown , message gives value not fall within expected range. i'm trying right piece of code grab exception , suppress - know issue - trying pull record list using id doesn't exist. any ideas how go catching this? to suppress exception need this try { // code may throw exception. } catch (exception ex) // better use more specific exception class { // nothing - suppresses exception. // if want additional checking may continue exception // stack use "throw" on own - compiled cil/msil's // "rethrow" , doesn't drop of information // go if did "throw ex" } that's there suppressing exception. for sanity of have maintain code (or in 6 months time when you've forgotten specifics of why did this), comment why suppressing exception. if see code suppresses exception want know why.

java - How to open the particular fragment on the click of the push notification message in the notification tab? -

this gcmintentservice class sending message. problem when click on push notification message opens main activity.but want open particular fragment.i knew changes in sendnotification() method. can tell me how can open particular fragment on click of push notification ? public class gcmintentservice extends intentservice { public static final int notification_id = 1; private notificationmanager mnotificationmanager; private final static string tag = "gcmintentservice"; public gcmintentservice() { super("gcmintentservice"); } @override protected void onhandleintent(intent intent) { bundle extras = intent.getextras(); googlecloudmessaging gcm = googlecloudmessaging.getinstance(this); string messagetype = gcm.getmessagetype(intent); if (!extras.isempty()) { if (googlecloudmessaging.message_type_send_error .equals(messagetype)) { sendnotificatio...

java - How to persist entity in hibernate postPersist listener -

let's got entity account : @entity(name = "account") @entitylisteners(listener.class) public class accountentity { @id @generatedvalue(strategy = generationtype.table) @column(name = "account_id") long id; @column(name = "username") string username; @column(name = "password") string password; <getters , setters... /> entity history store information changes in database: @entity(name="operation_history") public class operationhistoryentity { @id @generatedvalue(strategy = generationtype.sequence) @column(name="operation_history_id") long id; @column(name = "entity_name") string entityname; @column(name = "record_id") long recordid; @column(name = "operation") string operation; @column(name = "creation_date") timestamp creationdate; @column(name = "update_date") timestamp updated...

python - What is the goal of the minSearchTime argument in the PyAutoGUI locateOnScreen method? -

i can't see difference between import pyautogui pyautogui.locateonscreen("animage") and import pyautogui pyautogui.locateonscreen("animage", minsearchtime=10) and there no explanation nor reference in documentation minsearchtime .

php - Laravel one-to-one relationship giving errors -

im trying implement one-to-one relationship, im calling 'command' , keep getting undefined property error when viewing record in relationship. in model have following public function preferences() { return $this->hasone('app\websitepreferences', 'id', 'website_id'); } then im calling such $websites = website::where('active', 1)->get(); foreach ($websites $website) { var_dump($website->preferences()->status); } the exact error follows undefined property: illuminate\database\eloquent\relations\hasone::$status if var_dump($website) returns values in table, not ones in websitepreferences table associated 'website' i have few other one-to-one relationships , work fine. any appreciated. when call relationship method, returns querybuilder instance. allow keep chaining where, , on. instead should call attribute: $website->preferences->status

typo3 plugin: how to pass a parameter? -

i've got plugin in typo3 database query limit of 5 example. looking solution choose limit in backend of typo3 (select box,radio buttons,...) , pass parameter - have idea? thanks volker i guess using extension based on extbase! configuration called flexforms , can implemented easily as example, take @ 1 of extensions : configuration/tca/overrides/tt_content.php place such code $globals['tca']['tt_content']['types']['list']['subtypes_excludelist']['mailchimp_registration'] = 'recursive,select_key,pages'; $globals['tca']['tt_content']['types']['list']['subtypes_addlist']['mailchimp_registration'] = 'pi_flexform'; \typo3\cms\core\utility\extensionmanagementutility::addpiflexformvalue('mailchimp_registration', 'file:ext:mailchimp/configuration/flexforms/flexform_mailchimp.xml'); of course need adopt needs flexform_mailchimp.xml ...

PHP extending Exception breaks getMessage -

when declaring custom exception, e.g: final class testmeexception extends exception {} it, somehow, breaks getmessage() functionality, causing return null. meaning: $e1 = new exception('working'); $e2 = new testmeexception('not working'); print($e1->getmessage()); // prints: working print($e2->getmessage()); // prints: null does know going on here? you guys right. problem appeared when mocking exception via autobahn testsuite, without whitelisting new exception class (by default stubs out class under test , list of whitelisted classes/functions).

Copy rows automatically to new sheet with Google Apps Script -

i have spreadsheet information on, , want copy across second sheet automatically. want copy across automatically when insert new rows within rows copied across. found code below don't understand have do want, or if need add anything. have basic coding knowledge not much, if explain appreciated. function myfunction() { var source = spreadsheetapp.openbyid('xxxxxx'); var sourcesheet = source.getsheetbyname('sheet1'); var target = spreadsheetapp.openbyid('xxxxx') var targetsheet = target.getsheetbyname('sheet1'); var rangevalues = sourcesheet.getrange(2, 1, sourcesheet.getlastrow(), sourcesheet.getlastcolumn()).getvalues(); targetsheet.appendrow(rangevalues); } you can more using =importrange() function, e.g. =importrange("https://docs.google.com/spreadsheets/d/10x7kggfd4u8iwqo4qgunmlmphtwwef9bgwfu3vrm3am/","sheet1!a:z") put formula in second spreadsheet, replace url url of first spreadsheet (i put example one) , tw...

Execute JS code (using jQuery) with and without Turbolinks -

i'd execute code (using jquery) when page loading. want work , without turbolinks. for turbolinks, code following : document.addeventlistener("turbolinks:load", function() { // ... }) what have modify make work without turbolinks too? thank you

delphi - How to edit a file using a specified editor? -

currently, i'm using following function in order open file using default editor , sure application waits until user closes editor window. function editandwait(const afilename : string) : boolean; var info: tshellexecuteinfo; begin fillchar(info, sizeof(info), 0); info.cbsize := sizeof(info); info.lpverb := 'edit'; info.lpfile := pansichar(afilename); info.nshow := sw_show; info.fmask := see_mask_nocloseprocess; result := shellexecuteex(@info); if(result) , (info.hprocess <> 0) begin waitforsingleobject(info.hprocess, infinite); closehandle(info.hprocess); end; end; i write similar function allow specify editor executable use editing. function editandwait(const afilename : string; const aeditor : string) : boolean; begin //... end; as david said, have run editor program , pass file parameter. there several ways it. similar current function: function editandwait(const afilename : string; const aeditor : string) : b...

r - dplyr top_n() - Suppress status message? -

i have r code looks follows: rawlist <- df %>% select(colindex) %>% top_n(rows) this executes expect, when runs, output looks this: selecting readtime i added top_n() code , never saw message before adding function. i'm starting see it. assume it's comming top_n() function, , cannot find way suppress message. that message appears when don't explicitly pass wt parameter top_n tell column use select top values for. compare dd <- data.frame(x = c(10, 4, 1, 6, 3, 1, 1)) dd %>% top_n(2) # selecting x dd %>% top_n(2, x) # use column name

Dynamically Allocating Arrays Depending on User Input in C++ -

im watching tutorial on youtube https://www.youtube.com/watch?v=8xaqzcjvohk dynamically allocating arrays depending on user input in c++ this code 1 int main() 2 { 3 int *pointer = nullptr; 4 5 cout << "how many items u gonna enter" << endl; 6 int input; 7 cin >> input; 8 9 pointer = new int[input]; 10 11 int temp; 12 13 (int counter = 0; counter < input; counter++) { 14 cout << "enter item " << counter + 1 << endl; 15 cin >> temp; 16 *(pointer + counter) = temp; 17 } 18 19 cout << "the items have entered are" << endl; 20 (int counter = 0; counter < input; counter++) { 21 cout << counter + 1 << " item " << *(pointer + counter) << endl; 22 } 23 24 delete[]pointer; 25 26 return 0; 27} im stuck in line 16, dont understand why that, inside (), pointer variable , counter added each other pointer arithmetic ...

javascript - AngularJS watch element height change in directive -

i realize there several similar questions, checked them don't seem cover case. have fluid flexbox-based layout. of window used container block, shrinks when siblings appear. like <body> <div class="menu"></div> <div class="contact"></div> <div class="container"></div> </body> the container height not changed directly, it's recalculated browser when toggle other elements, such menu . i want watch container height , recalculate elements in directive. watch height this scope.$watch(()=>parentelement.prop('offsetheight'), resize); resize=()=>{console.log('resize called');}; problem resize triggered on next digest. when toggle menu first time nothing happens, on second resize called previous (first call) dimensions , on. i realize it's because browser resize not trigger digest, functions show menu use $rootscope, digest call should occur. is there...

typescript - Getting error-highlighting on things like `Object.assign` and `Promise<any>` -

hi i'm having problems supporting "lib" property in tsconfig when using webstorm 2016.2.2. i've tried editing typescript version in ide preferences ( preferences -> languages & frameworks -> typescript ) , pointing globally-installed typescript 2.0 version, i'm still getting error-highlighting on things object.assign , promise<any> . i've restarted ide multiple times, , nothing seems change, ideas on how fix or debug this? //tsconfig.json { "compileroptions": { "target": "es5", "module": "commonjs", "emitdecoratormetadata": true, "experimentaldecorators": true, "sourcemap": true, "noemithelpers": true, "strictnullchecks": false, "baseurl": "./src", "paths": { "core": ["app/core"], "reactive": ["app/reactive"], ...

Cut file Java (2 by 2) -

i started in java , galley little (a lot). explain problem, have flat file , read through java. goal create multiple output files (one file per order). in file, example have order number ( 136670 , 136609 ): 136670 00000000000000000 abc 136670 00000000000000000 abd 136670 00000000000000000 abe 136609 00000000000000000 abc 136609 00000000000000000 abd 136609 00000000000000000 abf 136609 00000000000000000 abe so created hashmap , or put order number 136670 , 136609 . current hashmap : key : 136670 values : 136670 00000000000000000 abc 136670 00000000000000000 abd 136670 00000000000000000 abe key : 136609 values : 136609 00000000000000000 abc 136609 00000000000000000 abd 136609 00000000000000000 abe 136609 00000000000000000 abf 136609 00000000000000000 abe code: linkedhashmap<string, stringbuilder> order = new linkedhashmap<string, stringbuilder>(); while((line = br.readline()) != null){ string lineid = line.substring(order_star...

php - Dynamic subqueries -

Image
i have following problem. have table atr_product contains columns atr_id , product_id . think registers are: i send atr_id array ws in php. example have atr_ids = (1,2,3); . so, when receive these atr_ids, query should return product_id 200. if send atr_ids = (1) , query should return product_id = (200,201) easy, atr_ids dynamic, don't know how many ids ws receive.

javascript - node-ipc cluster only using 1 worker -

i using node-ipc alongside cluster in nodejs on windows 8.1, , have clustered ipc server , created many processes have cpu's (4 in case), of them sharing same port , id. i connecting multiple clients clustered server , expecting master process delegate task worker free. not work , master chooses same worker. i have checked , worker processes running. how can master chooses least busy worker every time? below server code var os = require('os'); var numcpus = os.cpus().length; var cluster = require('cluster'); var ipc = require('node-ipc'); if (cluster.ismaster) { console.log("i master, launching workers"); (var = 0; < numcpus; i++) { cluster.fork(); console.log("worker " + + " launched"); } } else { ipc.config.id = 'worldserver'; ipc.config.retry= 1500; ipc.config.silent = true; console.log(`i worker #${cluster.worker.id}`, process.pid); ipc.serve( ...

java - Convert DWORD byte array to a unsigned long number -

i want unsigned value of little-endian dword byte array. this wrote: private long getunsignedint(byte[] data) { long result = 0; (int = 0; < data.length; i++) { result += (data[i] & 0xff) << 8 * (data.length - 1 - i); } return result; } is right? no afreaid big endian. public long readuint(byte[] data) { // if want tackle different lengths little endian: //data = arrays.copyof(data, 4); return bytebuffer.wrap(data) .order(byteorder.little_endian) .getint() & 0xff_ff_ff_ffl; } the above 4 byte (signed) int conversion , make unsigned.

tsql - SQL Server : Pivot with grouping -

i trying have query pivot data , working fine except noticed data issue further downstream our application development. noticed since having max because of pivot requiring aggregate function, literally maxing value without taking consideration columns not distinctly same. new pivoting may doing wrong result want. or direction appreciated. query: select @cols = stuff((select ',' + quotename(proto_name) #temp_rackplan group proto_name order proto_name xml path(''),type).value('.', 'nvarchar(max)'), 1, 1, '') set @query = 'select dept_catg_grp_desc [category group] ,dept_category_desc [category] ,fineline_desc [fineline] ,supplier ,ty_cust_choice_qty [cc] ,season_code [sc] ,set_strategy_desc [set strategy] ,ty_landed...

windows - How to install BuDDy lib in Cygwin? -

i'm trying install buddy on windows using cygwin. found these instructions i'm having problems installing libbdd0-2.4-1bl4 requirement. also, when running cygport ./buddy-2.4-x.cygport all manual above, i'm getting error: >>> buddy requires: >>> libbdd0 requires: cygwin libgcc1 libstdc++6 >>> libbdd-devel requires: libbdd0 anyone knows how fix this? it not error. build buddy package , libbdd0 sub package of buddy. looks on buddy-*/dist directory to install package easy way build own local repository , install buddy it. genini create local setup.ini https://cygwin.com/git/gitweb.cgi?p=cygwin-apps/genini.git;a=summary genini --help usage: genini [--okmissing=key ...] [--recursive] [--output=file] [--help] [setup.ini] [dir ...] create cygwin setup.ini setup.ini, setup.hint , tar ball information. --okmissing=key don't warn if key missing setup.ini or setup.hint or if expected `source...

Fixed FLAT File to XML -

need on xslt 2.0. here request of fixed flat file using unparsed text , schema file having offset , length information using document reference file. details when start grouping not able go further...any appreciated move stuck mind. source flat file p01020 230039.... a30438 009090..... a30439 009039..... p02390 039438.... d03049 304830... a30493 304030... p30439 230300.... schema file: <schema> <purchase recordidentifer="p"> <field1 length="5" offset="1" type="xs:string"/> <field2 length="6" offset="8" type="xs:string"/> </purchase> <account recordidentifer="a"> <field1 length="5" offset="1" type="xs:string"/> <field2 length="6" offset="8" type="xs:string"/> </account> <deposit recordidentifer="d"> <field1 length="5" offset=...

Manually hashing password the same as ASP.NET Identity v2.2.1 -

i have asp.net web api makes use of asp.net identity v2.2.1 manage users. able add/edit users without issue. however, have second project cannot make use of api needs able change users password directly via database. i trying figure out how hash password entered user without going through api. need make sure using same hashing algorithm asp.net identity using. came across code in this article not sure if same hashing algorithm used v2.2.1. using using system.security.cryptography; public static string hashpassword(string password) { private const int pbkdf2itercount = 1000; // default rfc2898derivebytes private const int pbkdf2subkeylength = 256 / 8; // 256 bits private const int saltsize = 128 / 8; // 128 bits if (password == null) { throw new argumentnullexception("password"); } // produce version 0 (see comment above) text hash. byte[] salt; byte[] subkey; using (var derivebytes = new rfc2898derivebytes(password,...

EXCEL - Fuse text cells and split into different lines -

i have file looks this, containing huge amount of data >ensmusg00000020333|ensmust00000000145|acsl6 agctccaggagggcccgtctcagtccgatgaactttgcagcaatattatagttattcgtg gttcacagaattccattaaacataaagaaaaaacataa >ensmusg00000000001|ensmust00000000001|gnai3 gaggatggcatagtaaaagctattacagggaggagtgttgagaccagatgtcatctactg ctctgtaatctaatgtttagggcatattgaagttgaggtgctgccttccagaacttaaac the columns should transformed lines contain: ensmusg*** ensmust*** genename sequence (four separate columns) the sequence column should lines starting either a,c,g,or t fused 1 text cell, number of cells fuse varies gene gene. does have advice how solve this? thank help! best wishes kk use text columns button on data tab. choose delimited , click next , select other , in box type pipe symbol |. click next , finish .

Using firebase database rules to prevent negative values -

Image
i trying use firebase database rules prevent negative values. { "rules": { "products": { ".read": true, ".write": "auth != null", ".indexon": ["subgroup", "group", "visibility"], ".validate": "newdata.child('quantity').val() >= 0" } } however, using the simulator test rule, seeing write denied on validate rule: ".validate": "newdata.child('quantity').val() >= 0" i using: location: /products/-kq1qlkei3gefugsfil_ and { "quantity": 0 } i using authenticated user. any idea whats going on here ? thanks. ==== update: changing rules following didn't help: "products": { "$product": { ".read": true, ".write": "auth != null", ".validate": "newdata.child('qua...

c# - Regarding GridViews and DateTime columns -

the goal of question me have better understanding of going on. seems there different ways solve issue depending on how data coming in. the situation when pull in data stored procedure lot of times there datetime columns , @ point have display them on web page. now, depending on how data coming in, seems have use different solution. depends on if i'm displaying inside label or if i'm displaying in gridview. understand going on , best way handle is. so here situations i've run , did solve issue (after researching on site of course). situation 1: datetime column stored procedure being saved datatable , used datasource gridview autogeneratecolumns set false. my solution situation format date on ascx page <asp:templatefield> <itemtemplate> <asp:label id="lbltest1" runat="server" text='<%# eval("somedatefield", "{0:mm/dd/yyyy}") %>'></asp:label> </itemtemplate> ...

gpu slower than cpu for neural networks in matlab -

i have following code: tic; h = rand(100, 1000); f = rand(1, 1000); net = newff(h, f, [30, 10], { 'tansig' 'tansig'}, 'traingdx', 'learngdm', 'mse'); net.trainparam.epochs = 400; net.performparam.regularization = 0.05; net.divideparam.trainratio = 1; net.divideparam.valratio = 0; net.divideparam.testratio = 0; net.trainparam.showwindow = 0; net.trainparam.showcommandline = 0; % net = train(net, h, f, 'usegpu', 'yes', 'showresources', 'yes'); % line 1 net = train(net, h, f, 'showresources', 'yes'); % line 2 toc; with line 2 uncommented computing resources: gpu device #1, geforce 800m elapsed time 5.084222 seconds. and line 1 uncommented computing resources: mex2 elapsed time 1.870803 seconds. why gpu slower cpu? gpu properties: cudadevice properties: name: 'geforce 800m' index: 1 comp...

regex - jQuery remove all characters after ? in img src -

would modify img src from: <div class="solo"> <img src="/uploads/2016/08/simone-b.jpg?fit=97%2c146&amp;ssl=1"> </div> to: <div class="solo"> <img src="/uploads/2016/08/simone-b.jpg"> </div> tried using following not working: jquery('.solo img').each(function(){ jquery(this).attr('src',jquery(this).attr('src').replace('?*','')); }); any suggestions? in advance in code .replace('?*','') replace string ?* . removing particular part need use regex instead .replace(/\?.*/,'') . but better way use attr() method callback iterate , update based on old value. can use string#split method removing string part after ? in attribute value. jquery('.solo img').attr('src',function(i,v){ return v.split('?')[0]; // string part before `?` // or // return v.replace(/\?.*/,''); });...