Posts

Showing posts from July, 2010

reactjs - How do the `require`s in React's repo work? -

i'm looking extending react addon , looking through require statements looks lot of them requiring modules don't exist. how work? if i'm looking make extend reacttransitiongroup, has require('reacttransitionchildmapping');, reacttransitionchildmapping isn't module, should do? https://github.com/facebook/react/blob/master/src/addons/transitions/reacttransitiongroup.js you can see requiring bunch of things aren't npm modules. the react repo (and presumably other systems @ facebook) use custom require resolution solution based around @providesmodule annotation in various files. these compiled down standard commonjs modules via build step. check out reacttransitionchildmapping.js , you'll see following comment, part of block comment: @providesmodule reacttransitionchildmapping

java - Server returned HTTP response code: 400 for URL while fetching Tweets from twitter -

import java.io.bufferedreader; import java.io.dataoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.net.httpurlconnection; import java.net.malformedurlexception; import java.net.url; import java.util.arraylist; import javax.net.ssl.httpsurlconnection; import javax.xml.bind.datatypeconverter; import org.slf4j.logger; import org.slf4j.loggerfactory; public class twitter{ public static string gettwitterbearertokenurl() { return "https://api.twitter.com/oauth2/token"; } public static void main(string[] args) throws ioexception { final logger logger = loggerfactory.getlogger("twitter"); string base64key = null; string authorization = "authorization"; string bearer = "bearer"; string utf_charset = "utf-8"; logger.info("twitter::getbearertoken --> in"); string accesstoken = null; stringbuffe

regex - Sed exact match search and replace on HP-UX -

as per sed whole word search , replace have tried following. os: hp-ux b.11.31 u ia64 $ echo "bar bar2 embarassment" | sed "s/\<bar\>/test/g" bar bar2 embarassment $ echo "bar bar2 embarassment" | sed "s/\b[bar]\b/test/g" bar bar2 embarassment $ echo "bar bar2 embarassment" | sed "s/\[[:<:]]bar[[:<:]]\/test/g" sed: function s/\[[:<:]]bar[[:<:]]\/test/g cannot parsed. $ echo "bar bar2 embarassment" | sed "s/bar/test/g" test test2 embraassment none of above helping me match exact values. note: can't install gnu sed since don't have permission so. most portable method :) sed 's/^bar$/test/;s/ bar / test /g;s/^bar /test /;s/ bar$/ test/' you can allow non-alphanum characters: sed 's/([^a-za-z0-9])bar([^a-za-z0-9])/\1test\2/g;s/^bar([^a-za-z0-9])/test\1/'

javascript - Meteor template helper not working after using iron router -

i'm new meteor , installed iron router project. have inside application.js file: if (meteor.isclient) { template.nav.helpers({ ismobile: function(){ if(ismobile.tablet) { return false; } else if(ismobile.phone) { return true; } else { return false; } } }); } the ismobile helper used inside nav template this: <template name="nav"> ... {{#if ismobile}} {{> mobile_nav}} {{else}} {{> desktop_nav}} {{/if}} ... </template> what i'm doing here is, i'm loading 2 different sets of navigation. if user using desktop or tablet, i'm going show desktop_nav template , when user using phone, i'm going show mobile_nav . this jquery plugin use inside ismobile template helper. inside application.html file, have this: <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, in

Google Cloud Pub/Sub Node.js Sample: TypeError: Cannot read property 'on' of null -

i'm using gcp , want use cloud pub/sub. got error below when tried node.js sample. knows how fix it? /private/tmp/pubsub/pubsubsample.js:26 subscription.on('error', onerror); ^ typeerror: cannot read property 'on' of null @ /private/tmp/pubsub/pubsubsample.js:26:15 @ /private/tmp/pubsub/node_modules/gcloud/lib/pubsub/index.js:474:7 @ object.handleresp (/private/tmp/pubsub/node_modules/gcloud/lib/common/util.js:113:3) @ /private/tmp/pubsub/node_modules/gcloud/lib/common/util.js:422:12 @ request.onresponse [as _callback] (/private/tmp/pubsub/node_modules/gcloud/node_modules/retry-request/index.js:106:7) @ request.self.callback (/private/tmp/pubsub/node_modules/gcloud/node_modules/request/request.js:198:22) @ emittwo (events.js:87:13) @ request.emit (events.js:172:7) @ request.<anonymous> (/private/tmp/pubsub/node_modules/gcloud/node_modules/request/request.js:1035:10) @ emitone (events.js:82:20) ht

How to zip the files include sub folders in android -

i want zip more 1 directory. mean have 1 inner directory , 1 parent directory. want zip parent directory. i using following codes: my file path : /data/data/com/app/1430159400000/32640/images/capture_image_20150427_115541.png" /data/data/com/app/1430159400000/32640/images/capture_image_20150427_115542.png" /data/data/com/app/1430159400000/32640/images/childimages/capture_image_20150427_115543.png" /data/data/com/app/1430159400000/32640/images/childimages/capture_image_20150427_115544.png" /data/data/com/app/1430159400000/32640/images/capture_image_20150427_115545.png" /data/data/com/app/1430159400000/32640/images/capture_image_20150427_115546.png" to files directory:- public void getlistfilesforcreatingzip(file parentdir) { string[] filespath = null; file[] files = parentdir.listfiles(); filespath = new string[(int) parentdir.length()]; int index = 0; int index1=0; (file file : files) {

javascript - Protractor writing a cleaner test cases without using browser.sleep -

im new protractor , jasmine , use lot of browser.sleep make test cases work it('procedure tab-', function() { element(by.linktext('medical history')).click(); browser.sleep(500) element(by.linktext('personal history')).click(); browser.sleep(200) element(by.linktext('procedure')).click(); browser.sleep(500) element(by.css('[data-ng-show="ptab.index === 1"] > [profile="profile"] > #medicalhistory > .card > [header="header"] > .card-header-bg > .title-header > .row > [ui-sref=".procedure.new"] > [data-ng-hide="important"]')).click(); browser.sleep(500) $('label[for="dis4appendicitis"]').click(); browser.sleep(2000) }) what more efficient way write test case without using browser.sleep........i have been using sleeps because of slower internet connectivity etc...

xaml - Item added to ObservableCollection is successfull but still throws exception -

``i utterly confused on why getting error: system.nullreferenceexception occurred hresult=-2147467261 message=object reference not set instance of object. source=xamarin.forms.platform.uap stacktrace: @ xamarin.forms.platform.uwp.windowsbaseplatformservices.get_isinvokerequired() @ xamarin.forms.listproxy.oncollectionchanged(object sender, notifycollectionchangedeventargs e) @ xamarin.forms.listproxy.weaknotifyproxy.oncollectionchanged(object sender, notifycollectionchangedeventargs e) @ system.collections.objectmodel.observablecollection 1.oncollectionchanged(notifycollectionchangedeventargs e) @ system.collections.objectmodel.observablecollection 1.insertitem(int32 index, t item) @ system.collections.objectmodel.collection`1.add(t item) @ viewmodels.scanbadgesviewmodel.add(badgescan result) innerexception: the error results following line: employeeids.add(badge.employeeid) note: error

android - How to change AppCompatButton corner radius? -

<android.support.v7.widget.appcompatbutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/logout" /> above button xml have small corner radius default need change radius little bit how can change corner radius? use custom style: create following file drawable folder. button_style.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" > <shape> <solid android:color="#9cd0e3" /> <stroke android:width="7dp" android:color="#55bde4" /> <corners android:radius="3dp" /> <padding android:left=

android - Error :java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity -

<activity android:name="com.luckyxmobile.timers4meplus.activity.widgetconfigactivity" android:theme="@style/theme.pageindicator.dark"> <intent-filter> <action android:name="android.appwidget.action.appwidget_configure" /> <category android:name="com.jakewharton.android.viewpagerindicator.sample.sample" /> </intent-filter> </activity> <style name="theme.pageindicator.dark" parent="android:theme"> <item name="tpi_tabpadding">12dp</item> <item name="tpi_tabripple">@style/darktabripplestyle</item> <item name="tpi_indicatorheight">3dp</item> <item name="tpi_indicatorcolor">@color/colorprimary</item> <item name="android:textappearance">@style/darktabtextappearance</item> <item name="android:background">@co

html - How do I get tidy to do what I want? -

i'm trying tidy convert html document xml document on windows there should no additional linebreaks (markup shall stay) believe following command line should trick, somehow it's not working. tidy --markup no -o output.xml -file o.txt -asxml input.html can help? by way, tidy -o output.xml -file o.txt -asxml input.html works fine.. what version of tidy? can provide input sample , expected output? (sorry, i'm not enough comment.) a possible place also ask question tidy bug tracker: https://github.com/htacg/tidy-html5/issues , please provide samples requested.

python - How can I load a saved JSON tree with treelib? -

i have made python script wherein process big html beautifulsoup while build tree using treelib: http://xiaming.me/treelib/ . have found library comes methods save tree file on system , parsing json. after this, how can load it? not efficient build same entire tree each run. think can make function parse json tree written file want sure if there exists easy way or not. thanks in advance the simple answer with this treelib, can't . as in documentation ( http://xiaming.me/treelib/pyapi.html#node-objects ): tree.save2file(filename[, nid[, level[, idhidden[, filter[, key[, reverse]]]]]]]) save tree file offline analysis. it not contain json-parser, can not read files. what can do? you have no other option building tree each time every run. implement json-reader parses file , creates tree you. https://docs.python.org/2/library/json.html

self.locationManager.requestAlwaysAuthorization() is only available on iOS 8.0 or newer - Swift -

i developing simple ios app in swift gets location of user , shows location. need set app target ios 7.0 , higher iphone 4 users can use app. however, when set deployment target 7.0 build error saying: /users/toing_toing/dev/xyz/homepageviewcontroller.swift:35:30: 'requestalwaysauthorization()' available on ios 8.0 or newer it comes line: self.locationmanager.requestalwaysauthorization() i need app access gps time moment, cant find replacement code fix deployment target error. can do? just use self.locationmanager.startupdatinglocation() var authorizationstatus = cllocationmanager.authorizationstatus() if (authorizationstatus == .authorizedwheninuse || authorizationstatus == .authorizedalways { locationmanager.startupdatinglocation() }else if self.locationmanager.respondstoselector(selector("requestalwaysauthorization")) { self.locationmanager.requestalwaysauthorization() }else { locationmanager.startupdatinglocation() }

openssl - rbenv : BUILD FAILED when Install Ruby 2.2.3 on UBUNTU 14.04 (x86_64) -

i trying install ruby 2.2.3, have installed ruby 2.2.2, rbenv versions system * 2.2.2 (set /home/emen/.ruby-version) jruby-1.7.20 jruby-9.0.0.0.pre2build i got problem when tried install ruby 2.2.3, got build failed below : rbenv install 2.2.3 downloading ruby-2.2.3.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.bz2 installing ruby-2.2.3... build failed (ubuntu 14.04 using ruby-build 20160111-27-g06f1254) inspect or clean working tree @ /tmp/ruby-build.20160127112741.26444 results logged /tmp/ruby-build.20160127112741.26444.log i have inspected log, copy part of suspect since checking , compiling process fine : linking shared-object objspace.so make[2]: leaving directory `/tmp/ruby-build.20160127112741.26444/ruby-2.2.3/ext/objspace' compiling ossl_ssl.c make[2]: entering directory `/tmp/ruby-build.20160127112741.26444/ruby-2.2.3/ext/pathname' compiling pathname.c ossl_ssl.c:141:27: error: ‘sslv3_method’ undeclared here (not in func

Get Data from parse.com Promises -

i trying use parse.com promises retrieve job data user relation data associated job. have function returns promises not job data. how job & employee information returned promises? logically want to: 1) query parse array of jobs 2) each job, query parse again employee relation information 3) create local object contains job & employee details 4) add each job object local array 5) load table array of objects once information has been retrieved parse i can steps 1-4 can't figure out how wait until information has been retrieved parse refresh local table. function getjobpromises (){ var promises = []; var job = parse.object.extend("job"); var query = new parse.query(job); query.equalto("company", company); query.notequalto("isdeleted", true); query.limit(1000); // raise limit max amount query.find().then(function(results) { // create trivial resolved promise base case. var p

python - How to set "simple" password in Django 1.9 -

python manage.py createsuperuser --username admin after prompts password , when enter "admin" got following message: this password short. must contain @ least 8 characters. password common. i haven't seen on earlier versions of django. tune auth_password_validators setting removing django.contrib.auth.password_validation.commonpasswordvalidator out there. password validation new feature introduced in django 1.9.

python - Display database table columns according to the table -

hi have following code display tables in database (python json formated view) class dbtablesresourceview(jsonresponsemixin, view): def get(self, request, *args, **kwargs): status = 'error' msg = "success" django.db import connection tables = connection.introspection.table_names() seen_models = connection.introspection.installed_models(tables) return self.render_json_response(dict(objects=list(tables))) and have drop-down option display tables in html below. used angular js display drop-down list. <div class="input-group well"> <span class="input-group-addon addon">table </span> <select type="input" class="form-control" ng-model="final_data.table" ng-options="t t in table_list" required ng-cloak></select> </div> my goal here display columns of user selected table in drop-down option.

android - Recycle view getting change while scrolling -

i trying change image in recycleview dynamically. changed when scroll recycleview imageview change here adapter class code: public class recyclerviewadapter extends recyclerview.adapter<recyclerviewholders> { private list<itemobject> itemlist; private context context; ongridselected ongridobj; public recyclerviewadapter(context context, list<itemobject> itemlist,ongridselected ongridobj) { this.itemlist = itemlist; this.context = context; this.ongridobj = ongridobj; } @override public recyclerviewholders oncreateviewholder(viewgroup parent, int viewtype) { view layoutview = layoutinflater.from(parent.getcontext()).inflate(r.layout.card_view_list, null); recyclerviewholders rcv = new recyclerviewholders(layoutview,itemlist,ongridobj); return rcv; } @override public void onbindviewholder(recyclerviewholders holder, int position) { if(!itemlist.get(position).isselected

list - Overriding sorting attribute in class, python -

i use bisect (as shown here, in second answer: does python have sorted list? ), instead of using list of numbers, have list of objects. in specific, objects class: https://networkx.github.io/documentation/latest/_modules/networkx/classes/graph.html i list keep graphs sorted number of nodes. if push these graphs list, looks being inserted in arbitrary way, (if run many times, changes between runs). is there "sort" function each class can define, when applying sorting used (like operator overriding in other languages) ? import bisect import networkx nx l=[] g1 = nx.graph() g2 = nx.graph() g1.add_edges_from([(1,2),(1,3),(2,3),(3,4),(4,5),(4,6),(5,6),(4,7),(7,8),(7,9),(8,9)]) print 'g1', g1.number_of_nodes() g2.add_edges_from([(1,2),(1,3)]) print 'g2', g2.number_of_nodes() bisect.insort(l,g1) bisect.insort(l,g2) print 'l0 ', l[0].number_of_nodes() print 'l1' ,l[1].number_of_nodes() if there's way of doing that, great to. thank

java - HibernateException when trying to access embedded Derby db -

Image
i have deployed embedded derby database intellij in project i want access spring application, create hibernate config @configuration @enabletransactionmanagement public class hibernateconfig { @autowired @bean public sessionfactory getsessionfactory(final datasource datasource) { final localsessionfactorybuilder sessionbuilder = new localsessionfactorybuilder(datasource); sessionbuilder.scanpackages("com.em.daas.entity"); return sessionbuilder.buildsessionfactory(); } } wher com.em.daas location of entity classes, , datasource config: @configuration @propertysource(testapplication.properties_path) public class localdatasourceconfig { @bean public drivermanagerdatasource derbydatasource() { final drivermanagerdatasource datasource = new drivermanagerdatasource(); datasource.setdriverclassname("org.apache.derby.jdbc.embeddeddriver"); datasource.seturl("jdbc:derby:c:/users/timofb

c# - Progmatically binding the dropdownlist in edititem template in gridview -

i trying bind dropdownlist in gridview under edititemtemplate under rowbound event. gives me blank rows in drop down list:here design <asp:templatefield headertext="description"> <itemtemplate> <asp:label id="lbldescription" runat="server" text='<%# bind("description") %>' width="400px"></asp:label> </itemtemplate> <edititemtemplate> <asp:label id="lblcity" runat="server" text='<%# bind("description") %>'></asp:label> <asp:dropdownlist id="ddlcities" runat="server" width="400px"></asp:dropdownlist> </edititemtemplate> <footertemplate> <asp:dropdownlist id="ddlnewdescfooter" runat="server" width="400px" onselectedindexchanged="ddlcitiesfooter_selectedindexchanged"> </asp:dropdownlis

What is bluetooth le multi advertising? -

i couldn't find clear explanation bluetooth le multi advertising. for example, in specification of bluetooth system, see description of ble advertising not multi advertising. what difference between ble advertising , multi advertising? thanks bluetooth smart has 2 ways of communicating. first 1 using advertisements, ble peripheral device broadcasts packets every device around it. receiving device can act on information or connect receive more information. second way communicate receive packets using connection, both peripheral , central send packets. focus on advertisement several reasons: you can’t create connection between 2 devices without using advertisements. defining data , format of advertisement packets first thing work on when developing ble device. large number of ble products sleep of time, waking advertise , connect when needed. means advertisements have big impact on power consumption. users want responsive products, , advertising interval critic

Restcomm jDiameter: Error creating SCTP socket -

i trying create standalone sctp diameter client using jdiameter. jar libraries using jdiameter-api-1.5.9.0-build538-snapshot , jdiameter-impl-1.5.9.0-build538-snapshot but error unable create server socket localpeer 'client.test.com' @ 127.0.0.1:55555 (org.mobicents.protocols.api.associationlistener) it works fine tcp. tried debug couldn't figure out problem. kindly me this. sctp not work on windows systems. linux systems, might have install sctp stack. however, aware linux distributions might run strange issues it, e.g. port still being blocked after server sockets, client sockets etc closed , processes have been shut down or killed. in these cases, need wait 5-10 minutes until sctp stack recognizes there no 1 anymore interested in port , releases itself.

bash - gnu-parallel: exec: perl: not found -

i have 3 ec2 instances os centos7. i've installed parallel on 1 of instances (server1). it's possible acces no ssh issue ssh root@ip-10-0-xx-xx.xx-xx-1.compute.internal date gave me date. ssh $server echo works works here i've created all_servers -file contains hostnames of servers (root@ip-10-0-xx-xx.xx-xx-1.compute.internal). now i've written short bash-script name test: #!/bin/bash echo 'hello' i want run script (started on server1). on server2 , server3 @ same time. parallel ./test.sh --sshloginfile all_servers but it's showing academic tradition requires cite works base article on.... , after few enters it's showing hello (only on server1). can explaining i'm doing wrong. edit: tried without file: parallel --sshlogin root@ip-10-0-xx-xx.xx-xx-1.compute.internal echo hello output: bash: line 0: exec: perl: not found i tried too: parallel --tag --nonall --slf all_servers now get: root@ip-10-0-0-xx.xx-xx-1.

java - Intellij Idea 15 Gradle project import Junit compile errors -

i having issue simple project's junit in intellij idea. gradle (2.10) can run junits command line. import project intellij idea 15.0.3, try run junit in intellij throws compile errors if junit not on classpath. error:(1, 17) java: package org.junit not exist checked project structure junit lib there, tried other method adivised - create test in intellij 'goto test > create new test >' still not luck. build.gradle: allprojects { apply plugin: 'idea' apply plugin: 'java' sourcecompatibility = 1.7 group 'junit.fail' version '1.0' repositories { mavencentral() } } subprojects { dependencies { testcompile 'junit:junit:4.12' } } dependencies { compile project(':common') compile project(':moda') } settings.gradle rootproject.name = 'junit-fail' include 'common' include 'moda' simple code in module common junit-fail\common

php - IF Statement inside a ChoiceType Symfony2 -

how place if statement inside choicetype add option? this code: $form = $this->createformbuilder() ->add('name', choicetype::class, array( 'choices' => array( 'server' => 'server', 'apc' => 'apc', 'switch' => 'switch', 'apc small' => 'apc small' ), the choice apc need checked first see if exists. if not exists had included otherwise excluded. the check ready true , false how place if statement inside form add array. or there other way that? the if statement this: if($apcdisable == false){} not sure understand problem, can determine/calculate choices array content before adding form, example this // w/out apc $choices = [ 'server' => 'server', 'switch' => 'switch', 'apc small' => 'apc small'

Accessing data in Google storage for Apache Spark SQL -

i have 30gb worth of data in cloud storage query on using apache hive dataproc cluster. what's best strategy access data. best approach copy data master via gsutil , access there, or can access in cloud storage directly ? if latter, how specify location in spark cli ? can specify location 'gs://<bucketname>' when run create external table ? you should able create external table points directly @ data in cloud storage. should work both hive , spark sql. in many cases, best strategy. here example based on public dataset in cloud storage. create external table natality_csv ( source_year bigint, year bigint, month bigint, day bigint, wday bigint, state string, is_male boolean, child_race bigint, weight_pounds float, plurality bigint, apgar_1min bigint, apgar_5min bigint, mother_residence_state string, mother_race bigint, mother_age bigint, gestation_weeks bigint, lmp string, mother_married boolean, mother_birth_state string, ci

xml - XSLT transformation with keyed Param -

i have piece of xslt file looks this: <xsl:template match="request"> <instrument> <identifiertype> <xsl:value-of select="idcontext"/> </identifiertype> <identifier> <xsl:value-of select="identifier"/> </identifier> <userdefinedidentifier> <xsl:value-of select="userdefinedidentifier"/> </userdefinedidentifier> <xsl:if test="param[@key='exchange']"> <exchange> <xsl:value-of select="param[@key='exchange']"/> </exchange> </xsl:if> </instrument> </xsl:template> and 1 input xml piece this: <request> <identifier>xxx</identifier> <idcontext>isin</idcontext> </request> now want

c - Separating a string into smaller strings -

i have following string abcd1234 , want find way break string 2 different strings, abcd , 1234 . have tried following code: char buf[100],*str1,*str2; int x; fgets(buf,sizeof(buf),stdin); str1=strtok(buf,"0123456789 \t\n"); str2=strtok(null," \n\t\0"); puts(str1); puts(str2); x=atoi(str2); printf("x=%d", x); but output abcd 234 . , if try 1 letter , 1 number, e.g a2 take e on output , x 0. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> size_t extract(const char **sp, char *out, int (*test)(int ch)); int main(void){ char buf[100], str1[100], str2[100]; int x; const char *p = buf; //size_t len; fgets(buf, sizeof(buf), stdin); while(*p){ if(isalpha((unsigned char)*p)){ extract(&p, str1, isalpha); puts(str1); } else if(isdigit((unsigned char)*p)){ extract(&p, str2, isdigit); x = atoi(str2

html - how to keep element in screen when scrolling in css? -

i have website big header go out of screen when scrolling (i want this), have 2 columns. i'd left column (it's section @ moment) remain visible time while right 1 scrolls down. position: fixed; not i'm looking for, left column scroll until reaches top of screen, , stay there. i know can done javascript, possible using css?

ios - Tabbar buttons order changed after go to other view -

Image
i have 2 buttons in tabbar, programmatically added. order changed after navigating placeholder within view. when open app: when go movies tab: the code: self.searchbutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemsearch target:self action:@selector(togglesearchbar)]; uiimage* meetupbuttonicon = [uiimage imagenamed:@"meetup_logo_icon"]; uiimage* meetupbuttoniconhighlighted = [uiimage imagenamed:@"meetup_logo_icon_highlighted"]; cgrect frameimg = cgrectmake(0, 0, 25, 25); uibutton *meetupuibutton = [[uibutton alloc] initwithframe:frameimg]; [meetupuibutton setbackgroundimage:meetupbuttonicon forstate:uicontrolstatenormal]; [meetupuibutton setbackgroundimage:meetupbuttoniconhighlighted forstate:uicontrolstatehighlighted]; [meetupuibutton addtarget:self action:@selector(togglemeetup:) forcontrolevents:uicontroleventtouchupinside]; uibarbuttonitem *meetupicon =[[uibarbuttonitem alloc] initwithcustomview:meetupuibutton]; sel

Excel VBA equivalent to Word VBA System -

i have word vba function i'm trying build in excel vba (the reason behind choice comes this question ) , i'm stuck @ following problem: the word vba function uses system.privateprofilestring extensively, throws compile error: invalid qualifier error when applied excel vba. what's equivalent statement in excel? alternatively, how work way around this? example of use: strhomesharepath = system.privateprofilestring("", "hkey_current_user\volatile environment", "homeshare") hi if wand read regesty in excel can way. sub test() dim strpath string strpath = regkeyread("hkey_current_user\volatile environment\homeshare") end sub function regkeyread(i_regkey string) string dim myws object on error resume next 'access windows scripting set myws = createobject("wscript.shell") 'read key registry regkeyread = myws.regread(i_regkey) end function

assign a unique color to a array number in java -

hi guys im new programming code for (int = 0; < v; i++) system.out.print(value[i] +" "); system.out.println(); value of "i" numbers , instead of printing value of "i" want print unique color each value example if value: "1 2 1 1 3" want print: "red blue red red green" how can this? you can use switch choose color private string getcolor(int num) { switch (num) { case 1: return "red"; case 2: return "blue"; case 3: return "green"; default: return ""; } } (int = 0 ; < v ; ++i) { system.out.print(getcolor(value[i]) +" "); } system.out.println();

numpy - Applying a Fast Coordinate Transformation in Python -

i have simple 2x2 transformation matrix, s , encodes liner transformation of coordinates such x' = sx . i have generated set of uniformley distributed coordinates on grid using np.meshgrid() function , @ moment traverse each coordinate , apply transformation @ coordinate coordinate level. unfortunately, slow large arrays. there fast ways of doing this? thanks! import numpy np image_dimension = 1024 image_index = np.arange(0,image_dimension,1) xx, yy = np.meshgrid(image_index,image_index) # pre-calculated transformation matrix. s = np.array([[ -2.45963439e+04, -2.54997726e-01], [ 3.55680731e-02, -2.48005486e+04]]) xx_f = xx.flatten() yy_f = yy.flatten() x_t in range(0, image_dimension*image_dimension): # current (x,y) coordinate. x_y_in = np.matrix([[xx_f[x_t]],[yy_f[x_t]]]) # perform transformation x. optout = s * x_y_in # store new coordinate. xx_f[x_t] = np.array(optout)[0][0] yy_f[x_t] = np.array(optout)[1][0] # reshape output xx_

c# - Define multiple sinks with different outputTemplates based on logging level in xml config for Serilog -

is there way define multiple sinks in xml config serilog allow outputtemplate change based on level of log? i have: <add key="serilog:minimum-level" value="verbose" /> <add key="serilog:write-to:coloredconsole" /> <add key="serilog:write-to:rollingfile.pathformat" value="c:\logs\adapterservice-{date}.txt" /> <add key="serilog:write-to:rollingfile.retainedfilecountlimit" value="10" /> <add key="serilog:write-to:rollingfile.outputtemplate" value="[{timestamp:g}] [{level}] [{sourcecontext:l}] {message}{newline:l}{exception:l}" /> however debug level logs not include sourcecontext string in: <add key="serilog:write-to:rollingfile.outputtemplate" value="[{timestamp:g}] [{level}] {message}{newline:l}{exception:l}" /> i aware can set restrictedtominimumlevel: logeventlevel.verbose unsure how in xml.

css animations - How to set a keyframe from another keyframe in LESS -

i have legacy keyframes want re-namespace. e.g have legacy code: @keyframes bulge { 50% {} } and want like: @my-ui-bulge: @bulge; is possible?

c# - Linq To SQL Delete + Insert best practice -

as stated in title need perform delete + insert, : context.deleteallonsubmit ( deletequery ) ; foreach ( var entry in entries ) contex.insertonsubmit ( entry ) ; context.submitchanges(); as wrote in post : linq sql: execution order when calling submitchanges() i read delete operation last 1 applied, @ moment see logic work (i sure delete+insert happen dozen of times per day). need understand if post wrong or logic , reason (update check flag in linq sql datamodel?) lucky , avoid trouble. after know better pattern make "update" when record cardinality changes. mean in table there primary key identify entity (an entity has many records) , subkey identify each record in same entity (sub entity). need regenerate (because sub entity may inserted, edited or delete) use delete + insert (in messagge form write db contains entity , sub enetity exist, not deleted ones). eg: id subid data 1 1_0 father 2 2_0 father 2

Android ViewPager Fragment ImageView Glide Memory Leak -

i'm using viewpager fragmentstatepageradapter . each fragment has imageview 's. glide loading images: glide.with(fragment)//current fragment .load(imageurl)//url string .dontanimate() .skipmemorycache(true) .into(imageview_n); viewpager 's offscreenpagelimit default (1); ondestroy calling each fragment . after sliding next , next fragment memoryheap increasing, not releasing. , outofmemory . i know, possible duplicate question, other post did not me.

ruby - Module method access restriction -

i have class c inherits class a , includes module b . a has method baz . class def baz; 5 end end module b def foobaz; baz end end class c < include b def barbaz; baz end end i want disallow b instance (indirectly) calling baz , allow c instance call baz . b.new.foobaz # => error c.new.foobaz # => no error c.new.barbaz # => no error how this? maybe wanted ? class def baz; 5 end end module b module_function def foobaz self.respond_to(:baz) ? baz : "no baz defined :(" end end class c < include b def barbaz; baz end end b.foobaz # => "no baz defined :(" c.new.foobaz # => 5 c.new.barbaz # => 5

java - How to use Servlets and Ajax? -

i'm new web apps , servlets , have following question: whenever print inside servlet , call webbrowser, returns new page containing text. there way print text in current page using ajax? indeed, keyword "ajax": asynchronous javascript , xml . however, last years it's more asynchronous javascript , json . basically, let js execute asynchronous http request , update html dom tree based on response data. since it's pretty tedious work make work across browsers (especially internet explorer versus others), there plenty of javascript libraries out simplifies in single functions , covers many possible browser-specific bugs/quirks under hoods, such jquery , prototype , mootools . since jquery popular these days, i'll use in below examples. kickoff example returning string plain text create /some.jsp below (note: code doesn't expect jsp file being placed in subfolder, if so, alter servlet url accordingly): <!doctype html> <html l