Posts

Showing posts from January, 2013

Reading in an array of 12 numbers with spaces in between each number - C programming -

i new c programming student , having trouble code working on. need ask user 12 number barcode spaces in between each value. also, need refer each individual value in array later on in code. example, if array x[12] , need use x[1] , x[2] , , other values calculate odd sum, sum, etc. below first function read in bar code using loop. assistance script of function help. #include <stdio.h> #define array_size 12 int fill_array() { int x[array_size], i; printf("enter bar code check. separate digits space >\n"); for(i=0; i<array_size; i++){ scanf("% d", &x); } return x; } you should pass array read argument , store read there. also note % d invalid format specifier scanf() . #include <stdio.h> #define array_size 12 /* return 1 if suceeded, 0 if failed */ int fill_array(int* x) { int i; printf("enter bar code check. separate digits space >\n"); for(i=0; i<array_size; i++){ ...

c - Left shifting operation on int -

on indiabix.com came across following question.as per experience level(beginner in c) output of above should 0 (10000000 << 1 00000000) came out 256,after going deeper found printing using %d supports 4 bytes output 256 instead of 0. #include<stdio.h> int main() { unsigned char = 128; printf("%d \n", << 1); return 0; } now consider following example #include<stdio.h> int main() { unsigned int = 2147483648;(bit 31 = 1 , b0 b30 0) printf("%d \n", i<<1); return 0; } when left shift above 0 output, %d supports value of int output should 0 when changed %d %ld output still 0. %ld supports values upto long int output should not 0.why getting 0 output. in first case, i promoted int , can store @ least 32767, shift calculated. result, result became 256. in second case, if unsigned int 32-bit long, calculated in unsigned int , result wraps. result, result became 0. ...

regex - How to compose regexes in code -

i writing regex irc protocol abnf message format . following short example of of regex writing. // digit = %x30-39 ; 0-9 // "[0-9]" static const std::string digit("[\x30-\x39]"); i use previous definitions form more complex ones, , gets complex, fast. having problems with, more complicated regexes, composing them: // hexdigit = digit / "a" / "b" / "c" / "d" / "e" / "f" // "[[0-9]abcdef]" static const std::string hexdigit("[" + digit + "abcdef]"); a "hexdigit" "digit" or "hex-letter". note: don't care rfc defines "hexdigit" letter (abcdef) being uppercase. going rfc says , don't plan on changing requirements. const std::regex digit(dapps::regex::digit); assert(std::regex_match("0", digit)); assert(std::regex_match("1", digit)); assert(std::regex_match("2", digit));...

java - Calling activity method in custom adapter class -

so trying refresh recyclerview in activity problem doesn't casting or way calling it. any ideas? from crashlog, appear passing applicationcontext recyclerview. instead, need pass activity context, , ensure activity implements userrview interface. a cleaner way pass context , pass userrview adapter, not have cast context userrview, , can continue pass application context if prefer. edit: replace code adapter = new customradapter(list, getbasecontext()); with adapter = new customradapter(list, this);

oracle - How to get max value out of two max values -

how can find maximum value similar fields in different tables? select max(select max(col) table1,select max(col) table2...) dual doesn't work! suggestions? you can union: select max(cols) from( select max(col) cols table1 union select max(col) cols table2)

locationmanager - how to set radius within current location android apps -

i want set radius of office. have current location code. want set radius when in radius, can use application. right current location longitude , latitude public gpstracker(context context) { this.context = context; getlocation(); } public location getlocation() { try { locationmanager = (locationmanager) context.getsystemservice(location_service); isgpsenabled = locationmanager.isproviderenabled(locationmanager.gps_provider); isnetworkenabled = locationmanager.isproviderenabled(locationmanager.network_provider); if(!isgpsenabled && !isnetworkenabled) { } else { this.cangetlocation = true; if (isnetworkenabled) { locationmanager.requestlocationupdates( locationmanager.network_provider, min_time_bw_updates, min_distance_change_for_updates, this); if (locationmanager != null) { ...

ios - how to show number of cell in table view using label -

i have 1 table view contains more many results dipslay in each cell. totally have 50 data in table view. did array , display in table view.like : var tabledata = ["thomas", "alva", "edition", "sathish", "mallko", "techno park" ..... till 50 data] what need is, have 1 label called countlabel . need display how data in tableview there? in lbel countlabel . need dipslay in label 50 datas .... because having 50 data in table view. please me how ? thanks countlabel.text = "\(tabledata.count) data"

How do I compile an XNA project from C# with MSBuild 14? -

i have xna project have compiles fine in visual studio 2015, makes use of c# 6 features. previously, had tools coded in c# auto-compile project when using c# 5 under vs 2013, change c# 6 has broken things somehow. to reproduce created new console application, referenced microsoft.build , microsoft.build.framework , , microsoft.build.utilities.core assemblies c:\program files (x86)\msbuild\14.0\bin . i created c# compiler project following code: namespace compilexna { class program { static void main(string[] args) { const string solutionpath = @"d:\code\my projects\frbtest\frbtest.sln"; var properties = new dictionary<string, string>() { {"configuration", "debug"}, {"platform", "x86" } }; var parameters = new buildparameters { loggers = new ilogger[] {new buildlogger()} ...

user controls - DNN : communicate with another module -

i new dnn. please guide me query. my requirement display 1 user list page , contain 1 link called 'edit'. on click of link it's detail should displayed. for this, have created 1 module contains 1 user control called 'userlist' displaying list of users. detail page should create new module? if yes how communicate module 'edit' link? if there way have both view in same module? please guide me in requirement? thanks in advance.

sql - Whats the right syntax for the string comparison query involving variable name in PostgreSQL? -

suppose have table name first name last name -------------------------- kris kristos i want right syntax query appears select * name first_name '%'last_name'%' you use strpos : select * name strpos(lastname, firstname) > 0; sqlfiddledemo

shell - Removing lines having special characters using awk command -

i have text file sentences, words on each line. e.g. hello hi how you? % $ 9 i need remove lines above file contains non text characters. output should follows: hello hi i trying out using awk command follows: awk '!/[%$0-9?]/' filename i able above file because know special characters in above sentence. but, file has list of special characters difficult write in awk. i tried out below commands keeps lines have both alphabets , special characters. awk '/[a-za-z]/' filename hence, please suggest me how write awk command keep lines don't have special characters or how keep lines have alphabets only. thanks awk '/^[a-za-z[:space:]]+$/' yourfile note $ usage.

string - How to format the content of any .txt file in one line by removing \n with Python? -

just quick question guys... recover content of formatted .txt file in 1 line. instance consider following content of .txt file: me encanta todos los electrodomésticos lg, ya que últimamente se han actualizado en un 200% en tecnología de punta respecto de las demás marcas que lo aventajaban antiguamente, sus repuestos son fáciles de encontrar en caso de defectos y mas económicos de otros, es una excelente secadora, gran capacidad de ropa y lo mas importante es que reúne las dos grandes funciones, lavar y secar en un sólo producto y cualquier persona la puede hacer funcionar, ya que su panel es muy sencillo y además no es ruidosa, se las recomiendo todos. además, posee una gran característica que es, que si es que no quisieras utilizar todas las funciones, puedes seleccionar sólo las que desees, por ejemplo si es quires sólo lavar, se programa para esa función en específico y si es deseas todo el proceso menos secar, por ejemplo, de igual forma se selecciona las funciones requerida...

swift - Looping through music -

i have app want cycle through music. play 15 secs of song move on next one. i have struct (musiclibrary) holds array of song information (a struct called songitem) including persistentid of songs on iphone. struct working , if print out names of songs works. (structs @ bottom of post) i have function (playthesong) uses persistentid have stored in songs object mpmusicplayercontroller - part of mediaplayer library. what happens when button pressed first song starts play. song persistentids printed debugger output , not sure why. after 15 seconds first song stops - added timer in attempt move onto next song, here doesn't work. think because loop through song structs executing , problem. i know doing silly here, can't put finger on it. note: work on phone simulator doesn't have music library. this viewcontroller. import uikit import mediaplayer class runningmusicviewcontroller: uiviewcontroller { var mymusic = musiclibrary() let mymusicplayer = mpmus...

Javascript: Applying class to multiple Id's For Interactive Map -

i'm new javascript , have had help, still trying wrap head around solution. i'm trying apply .mapplic-active class states listed on map when active. example can seen here: http://test.guidehunts.com/concealed-weapons-permit-reciprocity-map/?location=nv . i'm trying string location.description, split states, apply class through results of array, running issues. i'm trying edit. function tooltip() { this.el = null; this.shift = 6; this.drop = 0; this.location = null; this.init = function() { var s = this; // construct this.el = $('<div></div>').addclass('mapplic-tooltip'); this.close = $('<a></a>').addclass('mapplic-tooltip-close').attr('href', '#').appendto(this.el); this.close.on('click touchend', function(e) { e.preventdefault(); $('.mapplic-active...

google app engine - Objectify transaction fails in unit test -

this unit test of simple objectify transaction fail on: "transactions on multiple entity groups allowed in high replication applications". whenever there 1 entity used in case. such transaction executed on both dev server , google instance. need localservicetesthelper tweaking. can please? here unit test: @test public void transactiontest() { // setup final localservicetesthelper helper = new localservicetesthelper( new localdatastoreservicetestconfig(), new localmemcacheservicetestconfig()); helper.setup(); closeable session = objectifyservice.begin(); // test ofy().transactnew(new voidwork() { @override public void vrun() { user user = new user(); ofy().save().entity(user).now(); } }); // teardown helper.teardown(); session.close(); session = null; } and here exception get: mar 17, 2016 8:52:12 com.google.appengine.api.datastore.dev.localda...

swift - Can't access classes from framework imported in XCode playground -

Image
i can import framework playground, classes inside aren't accessible. if add keyword public event (and/or initialiser), error becomes: 'event' unavailable: cannot find swift declaration class what's going on? thanks

python - How can I find the credit card balance regarding my code? -

def balance (p, apr, mo): mpr = 0.01*apr/12 month in range(int(mo)): p= p+p*mpr return p i'm beginner trying create function return balance on credit card starting balance p , interest rate apr after mo months. when run code, seems loop not work. def balance (p, apr, mo): mpr = 0.01*apr/12.0 month in range(int(mo)): p= p+p*mpr return p in range(1,13): print balance(1000,10,i) strictly mpr not correct (monthly compounding simplification justified in times before slide rules); monthly rate should 12th root of annual rate; see continous compounding https://en.wikipedia.org/wiki/compound_interest def balance2 (p, apr, mo): mpr = ((1+apr/100.0)**(1/12.0)-1) month in range(int(mo)): p= p+p*mpr return p print in range(1,13): print balance2(1000,10,i) output: 1008.33333333 1016.73611111 1025.20891204 1033.75231964 1042.3669223 1051.05331332 1059.81209093 1068.64385836 1077.54922384 1086.52880071 1095.583...

Tags index with filebeat and logstash -

i use logstash-forwarder , logstash , create dinamic index tag configuration: /etc/logstash/conf.d/10-output.conf output { elasticsearch { hosts => "localhost:9200" manage_template => false index => "logstash-%{tags}-%{+yyyy.mm.dd}" } } /etc/logstash-forwarder.conf "files": [ { "paths": [ "/var/log/httpd/ssl_access_log", "/var/log/httpd/ssl_error_log" ], "fields": { "type": "apache", "tags": "mytag" } }, i convert configuration files filebeat in way: /etc/filebeat/filebeat.yml filebeat: prospectors: - paths: - /var/log/httpd/access_log input_type: log document_type: apache fields: tags: mytag now in kibana index, instead of mytag see beats_input_codec_plain_applied i can see 2 problems mentioned in topic. let me summarize own benefit , other ...

c - Purpose of shm_open() and ftruncate()? -

when create shared-memory use shm_open() , ftruncate() function. according information shm_open() create shared-memory region. , use ftruncate() function configure size of shared-memory region. well how shm_open() creates memory region in first place when doesn't yet know size? , if not case , totally wrong, please tell me purpose of shm_open() , ftruncate(). in advance!!! the main point of shm_open can open existing memory area. in case didn't exist , you'd create it, shm_open behaves open when creating file; newly created memory area has size of 0. linux manuals : o_creat create shared memory object if not exist. user , group ownership of object taken corresponding effective ids of calling process, , object's permission bits set according low-order 9 bits of mode, except bits set in process file mode creation mask (see umask(2)) cleared new object. set of macro constants can used define mode listed in open(2). (symbolic definitio...

sql server - Having serious issues with functions, dates, CASE and IIF statements in SQL -

i have been working on these queries , some, cannot seem these 3 quite right. not trying people work me, help/tips extremely appreciated. this query supposed return 4 columns: vendorname, invoicetotal, invoicedate , invoiceage (use appropriate function return number of days between invoicedate , 12/1/2008). filter results return rows there balance due , invoiceage greater 132. sort results vendorname. no errors, not quite right. select vendorname, invoicetotal, invoicedate, datediff(day, invoicedate, '12/1/2008') invoiceage vendors join invoices on vendors.vendorid = invoices.vendorid invoicetotal - paymenttotal - credittotal > 0 , invoicedate > 132 order vendorname;-- not showing invoices on 132 this query 1 has been giving me trouble; should return 4 columns: vendorname, invoicenumber, invoicetotal, , potentialdiscount. potentialdiscount column contain result expression case statement contains 4 conditionals based on invoicetotal column: select v...

ignite - Delta operation on Cache -

getting error while trying perform delta operation on basic primitype type on objects @test public void testdeltaonfield() { string name = "sreehari"; roccacheconfiguration<string, string> rc1 = new roccacheconfiguration<>(); rc1.setname("seventhcache"); roccache<string, string> r1 = roccachemanager.createcache(rc1); r1.put("a", name); assertequals(r1.get("a"), "sreehari"); roccachemanager.withkeepbinary(r1.getname()).invoke("a", (entry, args) -> { string = (string) entry.getvalue(); entry.setvalue(a = "hari"); return null; }); assertequals(r1.get("a"), "hari"); r1.replace("a", "hari", "hari1"); assertequals(r1.get("a"), "hari1"); roccachemanager.destroycache("seventhcache"); } @test public void testdeltaonpojofields() ...

node.js - Kurento Media Server 6.4 segmentation fault in libnice -

i using latest kurento media server (6.4) , node.js app one-2-one calls. however, kurento process crashes time time inside libnice: (multiple crashes point same lib entries) segmentation fault (thread 139888166897408, pid 1093) stack trace: [nice_output_stream_new] /usr/lib/x86_64-linux-gnu/libnice.so.10:0x28c74 [nice_output_stream_new] /usr/lib/x86_64-linux-gnu/libnice.so.10:0x2b00a [nice_output_stream_new] /usr/lib/x86_64-linux-gnu/libnice.so.10:0x2bd09 [nice_agent_gather_candidates] /usr/lib/x86_64-linux-gnu/libnice.so.10:0x13e8b [nice_agent_gather_candidates] /usr/lib/x86_64-linux-gnu/libnice.so.10:0x1431e [g_simple_permission_new] /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0:0x75b21 [g_main_context_dispatch] /lib/x86_64-linux-gnu/libglib-2.0.so.0:0x49eaa [g_main_context_dispatch] /lib/x86_64-linux-gnu/libglib-2.0.so.0:0x4a250 [g_main_loop_run] /lib/x86_64-linux-gnu/libglib-2.0.so.0:0x4a572 [gst_nice_src_get_type] /usr/lib/x86_64-linux-gnu/gstreamer-1.5/libgstnice15.so:0x2f99 [g...

python - How can I change a Bool variable in one function from another? -

i'm having issues regarding bools. i'm creating a game after getting ex35 in learn python hard way. in game there 2 functions i'm having trouble (roomone, , getfood), 1 function brings , given option pick brick of food - later use throw @ switch disable electric field around you. i want user able throw food if has food on person... - way program set - not matter if user has food - can throw either way. i've tried return foodbrick = true or (==) in food function. has not worked out. how can fix game can turn off switch when foodbrick on person? your immediate problem because setting foodbrick = true, no matter user types in getfood() subroutine. you've done bunch of work, i'll suggest @ code , see if can identify doing repeatedly, , see if can make common things subroutine. past that, think should consider making player object (member of class) or dictionary, can add attributes player in different subroutines, , have them visible througho...

android - How to get the direct download link of a file by google drive api v3 in java -

how direct download link of file google drive api v3 in java ? hi all, i've worked google drive api in android week, used both android drive sdk , drive rest api java can't find way how how direct download link of file (anyone can read) on drive. i've try how url of file of google drive download in android it's not work. please me. thanks. if want have direct download link of file, drivefile doesn't seem you're looking for. can use drive api web service instead. note you're still required authenticated use api. check out download files section of documentation, there 3 ways download file. download file — files.get alt=media file resource download , export google doc — files.export link user file — webcontentlink file resource another alternative use webcontentlink download file. however, available files binary content in drive.

wireshark decode as ddp -

i using wireshark @ ddp/rdma packets, works fine. wireshark can't recognize next protocol after tcp ddp/rdma (although know is), tried using "decode as" there no option ddp/rdma in there. is there way force wireshark parse packet ddp/rdma? thanks! is there way force wireshark parse packet ddp/rdma? the dissector iwarp ddp/rdma, if that's you're referring to, "heuristic" dissector, means 1) looks @ otherwise-undissected tcp packets , tries guess whether they're packets , 2) doesn't have "force this" option. you should submit bug the wireshark bugzilla saying wireshark isn't recognizing traffic ddp/rdma, , attach sample capture.

python - urllib.error.URLError: <urlopen error [Errno 11002] getaddrinfo failed>? -

so, code 4 lines. trying connect website, trying after irrelevant because error arised without other codes. import urllib.request bs4 import beautifulsoup html=urllib.request.urlopen('http://python-data.dr-chuck.net/known_by_fikret.html').read() soup=beautifulsoup(html,'html.parser') and error(succinctly summarized one): for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [errno 11002] getaddrinfo failed during handling of above exception, exception occurred: urllib.error.urlerror: <urlopen error [errno 11002] getaddrinfo failed> here have tried. i searched error returned "urlopen error [errno 11002]” on google , on stackoverflow, nothing helpful returned(in fact there not question on error 11002 asked). so try replace website argument(i.e. " http://python-data.dr-chuck.net/known_by_fikret.html " ) inside urlopen function website " http://www.pythonlearn.com/code/urllinks.py ". , wor...

Java Integer Wrapper Class Related -

public class testme{ public static void main(string[] args) { integer = 128; integer j = 128; integer k = 12; integer l = 12; system.out.println(i == j); system.out.println(k == l); } } i'm getting output: false true why 1st 1 false , 2nd 1 true? see: http://javapapers.com/java/java-integer-cache/ short answer: in java 5, new feature introduced save memory , improve performance integer type objects handlings. integer objects cached internally , reused via same referenced objects. this applicable integer values in range between –127 +127. this integer caching works on autoboxing. integer objects not cached when built using constructor.

javascript - Can not delete the new created row using angular.js -

i have issue.i have 1 add( + ) button in each row of table when clicked on add button 1 new row adding.here need when new row create 1 - (remove) button stay previous row , when user click on remove button corresponding row delete.i have done not working.please check https://plnkr.co/edit/?p=preview link code , please me. try using table deleterow() method document.getelementbyid("mytable").deleterow(index); or use array splice() method

actionscript 3 - What is the mnemonic index in the context of an application menu? -

Image
i have menu bar across top of application , each of menu items has property on called mnemonic index . it's value -1. documentation provide help. mnemonic index in relation menu item , for? the environment i'm working in flex , adobe air. it's property on nativemenu , nativemenuitem. a mnemonic single key, not used in combination ctrl, alt, or shift keys, activates menu command in open menu. character in menu item on windows contain underscore, i.e. r, g, b: menu item mnemonics relevant on windows, os-x not support mnemonics in menu items. note: know on windows 7 (and under) supported, not sure if supported (show) under windows 8.1/10: var root:nativemenu = new nativemenu(); var stackroot:nativemenuitem = root.addsubmenu(new nativemenu(), "stack"); var stack:nativemenu = new nativemenu(); stackroot.submenu = stack; var overflow1:nativemenuitem = new nativemenuitem("overflow1"); overflow1.mnemonicindex ...

mmu - Page table in Linux kernel space during boot -

i feel confuse in page table management in linux kernel ? in linux kernel space, before page table turned on. kernel run in virtual memory 1-1 mapping mechanism. after page table turned on, kernel has consult page tables translate virtual address physical memory address. questions are: at time, after turning on page table, kernel space still 1gb (from 0xc0000000 - 0xffffffff ) ? and in page tables of kernel process, page table entries (pte) in range 0xc0000000 - 0xffffffff mapped ?. ptes out of range not mapped because kernel code never jump there ? mapping address before , after turning on page table same ? eg. before turning on page table, virtual address 0xc00000ff mapped physical address 0x000000ff, after turning on page table, above mapping not change. virtual address 0xc00000ff still mapped physical address 0x000000ff. different thing after turning on page table, cpu has consult page table translate virtual address physical address no need before. the page table in k...

excel - Incorporating refedit into Vlookup userform -

Image
i have vlookup userform autofills details in form based on seat n°. now want incoroporate ref edit paste these data text box cells user chooses refedit. hence need in going these. this code have used. potentially want insert 3 refedit boxes user select cell want paste each of data ( name , dept , ext no .) textbox . see code below: option explicit private sub frame1_click() end sub private sub textbox1_exit(byval cancel msforms.returnboolean) dim answer integer answer = textbox1.value textbox2.value = worksheetfunction.vlookup(answer, sheets("l12 - data sheet").range("b:e"), 2, false) textbox3.value = worksheetfunction.vlookup(answer, sheets("l12 - data sheet").range("b:e"), 3, false) textbox4.value = worksheetfunction.vlookup(answer, sheets("l12 - data sheet").range("b:e"), 4, false) end sub private sub textbox2_change() end sub private sub textbox3_change() end sub private sub text...

regex - Parsing mathematical expressions in C# -

as project, want write parser mathematical expressions in c#. know there libraries this, want create own learn topic. as example, have expression min(3,4) + 2 - abs(-4.6) i create token string specifying regular expressions , going through expression user trying match 1 of regex. done front back: private static list<string> tokenize(string expression) { list<string> result = new list<string>(); list<string> tokens = new list<string>(); tokens.add("^\\(");// matches opening bracket tokens.add("^([\\d.\\d]+)"); // matches floating point numbers tokens.add("^[&|<=>!]+"); // matches operators , other special characters tokens.add("^[\\w]+"); // matches words , integers tokens.add("^[,]"); // matches , tokens.add("^[\\)]"); // matches closing bracket while (0 != expression.length) { ...

c# - Selection of dropdown save -

i have 1 dropdownlist,it contains 3 items open invoices,close invoices , invoices.when select 1 should array or arraylist.like if select index 1 means should save,then select index 2 means should save,again select index 1 means shouls save in seperate index of arrat,not replace.is possible array,for foreach or arraylist.i try arraylist if (ddltransaction.selectedindex < 3) { list.add(ddltransaction.selecteditem); } but save current selection of dropdown item save. note sure if understand question seems issue not persisting list after postback, try use session in order persist : list<string> list = new list<string>(); if(session["list"] != null) { list = (list<string>)session["list"]; } if (ddltransaction.selectedindex < 3) { list.add(ddltransaction.selectedvalue); session["list"] = list; }

c# - How can you set security so that a user can only see/edit their items in Sitecore? -

is there way in sitecore can create role/user can view , edit own created items? if not, how can make possible? to fix have added item:created event under sitecore/events config. <event name="item:created" xdt:transform="replace" xdt:locator="match(name)"> <handler type="sirano.dev.itemeventhandlers.customitemeventhandler, sirano.dev" method="onitemcreated" /> </event> this event wil run following code: protected void onitemcreated(object sender, eventargs args) { if (args == null) { return; } var parameters = event.extractparameters(args); var item = ((itemcreatedeventargs)parameters[0]).item; if (item == null) { return; } var user = sitecore.context.user; var accessrules = item.security.getaccessrules(); accessrules.helper.addaccesspermission(user, ac...