Posts

Showing posts from August, 2010

vb.net - String.Substring(start, end) sometimes throwing an exception -

my program uses backgroundworker call performaction() method when different method, method1 returns true. using strategy pattern set correct performaction() should performed every time event raised. for strategy pattern created abstract class, , class inside abstract class inherits it. public mustinherit class abstract public mustoverride sub performaction(byval str string) public class extends inherits abstract public overrides sub performaction(byval str string) str = str.substring(str.indexof(":"), str.indexof(">")) msgbox(str) end sub end class i create class contains field of abstract, , used call performaction. the performaction method gets called backgroundworker.reportprogress event, called when backgroundworker.dowork detects method1 returning true. , code above, causes system.reflection.targetinvocationexception addition information exception has been thrown t...

javascript - jquery css how to retain position if you remove margin -

i poked around , couldn't find question in particular, if missed please kindly point me in right direction. purpose: i'm in process of creating statistics reporting system our website. when first access it, has dashboard type of layout overall statistics, , graphs go along it. wanted make each individual set of stats/graphs can moved around page see fit, though starts out in center unless move it. i'm using jquery , jquery ui purpose. problem: initial view, i'm using margin: 0 auto center divs on page. first problem had when go drag it, couldn't drag left because of margin that's set on it. used draggable event property start: remove margin property div. fixed problem not being able move around expect, when first begin drag it, removal of margin forces div jump left side of screen , have click again. is there way prevent "jump" , force div retain current position while margin property being removed? going of in wrong way? appreciated, i...

php - Fieldset validation data -

Image
i have problem fieldsets in zf2, show problem. here form (made angularjs, not zf2), can put name, , select if permit page or action (pages composed of actions). the picture below partially show send zf2 : here data model of customrole class : class customrole { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") */ protected $id; /** * @orm\column(type="string") */ protected $name; /** * @orm\onetomany(targetentity="app\entity\users\customrolepagepermission", mappedby="customrole") */ protected $pagepermissions; /** * @orm\onetomany(targetentity="app\entity\users\customroleactionpermission", mappedby="customrole") */ protected $actionpermissions; /** * @orm\manytoone(targetentity="app\entity\users\globalrole") */ protected $globalrole; /** * @orm\ma...

unix - Bash- Converting a variable to human readable format (KB, MB, GB) -

in bash script, run through list of directories , read in size of each directory variable using du command. keep running total of total size of directories. problem after total size, it's in unreadable format (ex. 64827120). how can convert variable containing number gbs, mbs, etc? you want use du -h gives 'human readable' output ie kb, mb, gb, etc.

groovy - How to use gradle file tree in groovyTestcase -

i migrating project ant gradle. want write simple test case using groovetest framework. trying use gradle project.filetree interface in groovytestcase, how ever not able resolve it. same piece of code works in "test" task in build.gradle. here simple test case like. import org.gradle.api.project import org.gradle.api.file.filetree class installscripttest extends groovytestcase { void testcounnt(){ def tree = project.filetree("${project.projectdir}"){ include '**/install*.sh' } } } i following error when run gradle build. groovy.lang.missingpropertyexception: no such property: project class: installscripttest i have added gradleapi dependency in build.gradle file below. dependencies { testcompile 'org.codehaus.groovy:groovy-test:2.4.3' testcompile 'junit:junit:4.12' testcompile gradleapi() }

c - Pointers addresses behaviour -

this question has answer here: c pointers: *ptr vs &ptr vs ptr 7 answers for example: int *ptr what's difference beetween &ptr , ptr because when printf("ptr= %d &ptr=%d",ptr,&ptr); the result not same. ptr pointer value (it's address). &ptr address of pointer object. to print pointer value have use: printf("ptr= %p &ptr=%p", (void *) ptr, (void *) &ptr);

html - How to display previous and next images with a Bootstrap carousel -

Image
the effect i'm looking can seen in following image, carousel 3 images. how can make bootstrap carousel show left , right images opacity of 0.7? the following carousel template. <div class="col-md-10 center-block"> <img id="logo" src="./img/yoox_group.png" alt="yoog group" /> <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <!-- indicators --> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <!-- wrapper slides --> <div clas...

ios - How to draw a line in the simplest way in swift -

i new swift , xcode , trying make tic tac toe game. have figured out except how draw line through 3 x's or o's. have no idea on how draw lines. have looked on web answer , can't figure out. can help. thanks ahead try looking uibezierpath lot drawing lines. documentation here example: override func drawrect(rect: cgrect) { var apath = uibezierpath() apath.movetopoint(cgpoint(x:/*put starting location*/, y:/*put starting location*/)) apath.addlinetopoint(cgpoint(x:/*put next location*/, y:/*put next location*/)) //keep using method addlinetopoint until 1 close path apath.closepath() //if want stroke red color uicolor.redcolor().set() apath.stroke() //if want fill apath.fill() } make sure put code in drawrect. in example above. if need update drawing call setneedsdisplay() update.

javascript - TextAngular custom toolbar button onElementSelect not working for table/tr/td -

i have implemented custom button allows user add table editor, works fine. however, can't seem onelementselect fire when clicking in newly added table. goal when user clicks on table, popover displayed allow user edit number of columns/rows. now, i'm triggering alert. taregistertool('inserttable', { iconclass: 'fa fa-table', tooltiptext: 'insert table', onelementselect: { element: 'td', action: function(event, $element, editorscope){ alert('table clicked!'); // once here, add necessary code implement table editor }, action: function($deferred){... ... }); taoptions.toolbar[1].push('inserttable'); i have tried setting element td , tr , tbody , , table , none of work. if set a or img , clicking on 1 of elements in editor fires alert. i've added custom toolbar buttons inserting links , images , work fine using method. textangular not...

ios - MapKit - Change the Color/Stroke of a MKPolyline -

i have added overlay map follwing code: func mapview(mapview: mkmapview!, rendererforoverlay overlay: mkoverlay!) -> mkoverlayrenderer! { if overlay.iskindofclass(mkpolyline) { // draw track let polyline = overlay as! mkpolyline let polylinerenderer = mkpolylinerenderer(overlay: polyline) polylinerenderer.strokecolor = uicolor.bluecolor() polylinerenderer.linewidth = 2.0 return polylinerenderer } return nil } now want change color or line width of polyline. way found is: func randommethod() { ...// find apolyline self.myoverlay = apolyline self.map.removeoverlay(self.myoverlay) self.map.addoverlay(self.myoverlay) } on mapview renderforoverlay method added this: if (polyline == self.myoverlay) { polylinerenderer.strokecolor = uicolor.redcolor() polylinerenderer.linewidth = 5.0 }else{ polylinerenderer.strokecolor = uicolor.bluecolor() polylinerenderer.linewidth = 2.0 } there h...

PHP+MySQL Login wont work -

i have been trying script go db , fetch data, login etc... my php version 5.6. have included code in both index page [where form is] , problematic script in question. login form code: <form class="form" action="php-process/main_login-check.php" method="post"> <input type="text" placeholder="username" name='username' id='username' maxlength="50" > <input type="password" placeholder="password" name="password" id="password"> <button type="submit" id="login" name="login">go</button> <button type="reset" id="reg-button" onclick="mm_openbrwindow('app/register.php','register @ mysite.com','scrollbars=no,width=500,height=500');javascript:regprocess();"> register</button> </form>...

django - How to run get_or_create() method with dictionary {'field_name': field_value, ...}? -

i need kind of universal solution, (btw. eval(), exec() , ideas not permitted). so.. i have dictionary of fields: dict = {'field_name_1': field_value_1, 'field_name_2': field_name_2, ...} , run: class.objects.get_or_create(dict) . is possible? how correctly? assuming field_name_1 , field_name_2 , etc. model's attribute names: model.objects.get_or_create(**dict)

sql - What graph to use when there are multiple parameters SSRS -

Image
i want display number of males , females based on working hours per week stuck in choosing kind of graph use. below seems sloppy graph display data: can please suggest , recommend graphs use or how better display figures. how different colors male female , shades year? you'd need create legend in paint , add under .

android - Asynctask for cycle and substring -

i'm developing livescore app: i'm using asynctask in in doinbackground function download data web , elaborate them. in doinbackground there cycle, , inside there substring istruction. problem that, substring istruction cycle doesn't run cycles (makes 50 instead 100+ cycles). if remove substring istruction runs cycles perfectly. can me? (sorry bad english) protected string doinbackground(string... params) { int i=0; string casa=null; string trasferta=null; string ris=null; string hinizio=null; try { document doc = jsoup.connect(urlind) .useragent("mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.22 (khtml, gecko) chrome/25.0.1364.172 safari/537.22") .timeout(60000).get(); elements partite = doc.select(....); elements competizioni = doc.select(....); string comp=competizioni.tostring(); string com...

python - PyGame not working in Eclipse using Python3.4 -

i using linux mint 17 (ubuntu 14.04) , got pygame 1.9.2 working in eclipse on windows pc. installed on machine, doesn't work. there no apt-get python3-pygame downloaded source https://bitbucket.org/pygame/pygame , built , installed without getting errors. when running following on command line receive no error: import pygame pygame.init() if try same in eclipse pydev project error: "undefined variable import: init". first thought interpreter not set correctly, path pygame installed added libraries (/usr/local/lib/python3.4/dist-packages). realized python2.7 pygame installed in /usr/lib/pytho2.7/dist-packages instead, directory doesn't exist python3.4 on machine. since seems work on command-line must have eclipse or pydev settings, right? update: ok, things getting confusing. found out pygame indeed working within eclipse if run project, giving me these error messages eg. pygame.init(), pygame.quit, pygame.k_escape, pygame.keydown. find strange, becaus...

If 2 Items in Basket Apply Discount - Shopping Basket Price Rules Magento -

trying work out if possible magento, assume can't seem figure out. essentially trying suceed in doing is: if 2 products added cart category x or y, apply 5% discount. at moment, can work out how apply 5% discount if 2 of same item added cart. many thanks managed figure out, that's looking in future: if of these conditions true : if total quantity equals or greater 2 subselection of items in cart matching of these conditions: category (your cateogry here)

php - Call parent function inside included/required file -

i know if possible call function of parent file inside included file , how work. example got that: parent_file.php : <?php if ( ! class_exists( 'parent_class' ) ) { class parent_class { public $id = 10; public static function getinstance() { if ( ! ( self::$_instance instanceof self ) ) { self::$_instance = new self(); } return self::$_instance; } public function init() { include 'child-file.php'; $child = new child_class($id); $child->action(); } public function edit($values_of_id) { return $values_of_id; } ?> child_file.php : <?php if ( ! class_exists( 'child_class' ) ) { class child_class { private $id; function __construct(){ ...

javascript - Highstock, multiple series chart, independent xAxis -

following chart have, want add xaxis both charts depending on data inputs, where should make change or add xaxis can define min max limits xaxis. here fiddle: http://jsfiddle.net/pratik24/n24s2fyk/3/ code: $(function () { $('#container').highcharts('stockchart', { navigator:{ enabled: false }, scrollbar:{ enabled: false }, rangeselector : { selected : 1, enabled:false }, yaxis: [{ min: -1e6, max: 1e6, labels: { align: 'left', format : '' }, title: { text: 'ohlc' }, height: '30%' }, { min: -1e6, max: 1e6, labels: { align: 'lef...

linux - Access output in Ubuntu 14.04 terminal that has 'disappeared' off the terminal window -

i ran script on server generates lot of output on command window. however, now, after running 4 hours want check output, beginning of output has disappeared terminal window. when scroll up, not there anymore. is there way access this? needs via commands in terminal because i'm running on server. thanks. best way redirect output file & open file check output. you can redirect script running in background & saving output file. let me know type of command running can give exact command. :)

angularjs - When does Angulars link function run? -

from understand runs once before page rendered. there ever case runs after page has been rendered? i tried testing few things plnkr : angular .module('app', []) .directive('test', function($http) { return { restrict: 'e', template: '<input />', link: function(scope, el, attrs) { var input = angular.element(el[0].children[0]); input.on('change', function() { console.log('change event'); scope.$apply(function() { console.log('digest cycle'); }); }); input.on('keyup', function() { console.log('keyup event'); var root = 'http://jsonplaceholder.typicode.com'; $http.get(root+'/users') .success(function() { console.log('http request successful'); }) .error(function() { console.log('http req...

php - Retrieve and use entire MYSQL Table in Swift -

i've looked around internet have yet come across solution seems should common practice. i trying write method in swift which, using php backend, retrieves data specific mysql table in database. in other sections of app (user login etc) have got similar system working, needs return few variables 1 specific user, can return these in json data individual variables , store them in nsuserdictionary use throughout app, easy! however have table information different 'shops' each row storing various details (location, name etc). want able plot these names onto mkmapview , therefore need retrieve entire table , iterate through each row (shop) within swift. (well that's way can think of accomplishing this). my issue can figure out how return '1d' json data in php (e.g. location / name etc specific shop), not entire array of shops? this code i'm using in swift retrieve 1d data user: var post:nsstring = "email=\(email)&password=\(passwor...

android - Set TextView to display integers that change for a certain length of time -

i add textview layout holds integer value , continues change it's value length of time. example, textview change value 10 seconds , stops. how can this? you may want countdowntimer . code this: countdowntimer mycountdown = new countdowntimer(10000, 1000){ public void ontick(long millisuntilfinished) { mytextview.settext(string.valueof(millisuntilfinished / 10)); } public void onfinish() { mytextview.settext("done!"); } }.start(); this create timer runs 10 seconds , updates textview every second. important thing note parameters in milliseconds, not seconds. first parameter (10,000 in example) represents duration of timer. second parameter (1,000) determines how many milliseconds occur between each call ontick() .

python - Where can I find the pdb source code? -

this question has answer here: where find python standard library code? 4 answers i modify source code of python 3.4's built in debugger, pdb (i'm assuming it's written in python). add code when put: pdb.set_trace(locals()) in code, invokes standard pdb interface in console, , automatically displays formatted information local environment variables similar table below. can point me source code pdb ? -------------------- objects: -----------------------------------[2000] [name: dog] [data type: "dog"] [2100] +------+-------+-------+-------+------------+------------+ | id | breed | color | name | size | uuid | +------+-------+-------+-------+------------+------------+ | 2110 | lynx | black | dog-3 | large!!!!! | e30475ad-9 | +------+-------+-------+-------+------------+------------+ [name: cat] [data type...

ios - Display seconds in a UILabel from a NSTimer which was selected from UIPickerView -

how can display number of seconds in label nstimer? imagevc.h @property (weak, nonatomic) iboutlet uilabel *timelabel; imagevc.m -(void)viewdidappear:(bool)animated { [super viewdidappear:animated]; imageviewcontroller *pickerview = [[imageviewcontroller alloc] init]; [nstimer scheduledtimerwithtimeinterval:10 target:self selector:@selector(timeout) userinfo:nil repeats:no]; }]; } } any appreciated. thanks add timer 1 second interval updates label -(void)viewdidappear:(bool)animated { [super viewdidappear:animated]; imageviewcontroller *pickerview = [[imageviewcontroller alloc] init]; [nstimer scheduledtimerwithtimeinterval:10 target:self selector:@selector(timeout...

node.js - Retrieve both string and json of body using koa js -

i use koa js bodyparser , suppose client send body this: { "first": "1" , "second": "2"} what want original body string no changes (json.stringify changes order of fields , remove spaces can't use it). try use raw-body gives me string of body, have parse json. is there middleware give me body both json , original string? if want both raw string , json, string, keep copy, parse json. var getrawbody = require('raw-body') app.use(function* (next) { var string = yield getrawbody(this.req, { length: this.length, limit: '1mb', encoding: this.charset }) var json = json.parse(string) // "string" // "json" }) note: have run getrawbody() against this.req , since that's node's raw http request object. this.request koa-specific , won't work.

gradle - Force locale for Android flavor with resConfig -

i trying use resconfig , resconfigs android build system. android studio version 1.2.2 gradle build version 1.2.3 osx 10.10.3 i having problem these 2 options project started new blank project android studio. attached build.gradle added resconfigs "en", "fr" under android { defaultconfig { ... resconfigs "en", "fr" ... } } and defined 2 basic flavors productflavors { fr { resconfig "fr" } en { resconfig "en" } } i created 2 strings.xml files , translated hello_world default label /src/main/res/values/strings.xml (default) /src/main/res/values-en/strings.xml /src/main/res/values-fr/strings.xml with this, expect see 3 values folders in myapplication/app/builds/intermediates/res/en/debug since defined in resconfigs use "en" , "fr" , filter else /values/ /values-en/ /values-fr/ ...

android - Handling Null Pointers from JsonReader -

i using jsonreader fetch lots of data website , saving db. incidentally, whenever reader doesnt find value object item, fails , stops executing. this error have; system.err﹕ java.lang.illegalstateexception: expected string null @ line 1 column 359337 path $[19].date even if specified value not available, seems objects loaded before error encountered lost , not saved db. there way handle these errors , keep objects had been loaded far? have set jsonreader lenient. this part of method parses data: private post read(jsonreader reader) throws exception { reader.beginobject(); while (reader.hasnext()) { string name = reader.nextname(); switch (name) { case title: mtitle = new stringbuilder(); mtitle.append(reader.nextstring()); break; case author: if (reader.hasnext()) { ...

entity framework - SQL Server sp_executesql timeout -

the following query (without details) ends timeout. columns have nvarchar type. not this . query works without sp_executesql. exec sp_executesql n'declare @exp nvarchar(max) = ''%'' + @name + ''%'' select u.id [local_db]..users u join [linked_server].[remote_db].dbo.players p on p.playerid = u.playerid join [linked_server].[remote_db].dbo.playerstats ps on ps.playerid = u.playerid @exp null or u.nickname @exp or u.name @exp or p.nickname @exp order ps.wins desc offset @skip rows fetch next @take rows only',n'@skip int,@take int,@name nvarchar(8)',@skip=0,@take=24,@name=n'foo' i've found interesting details. if remove or p.nickname @exp , works. same happens, when remove or u.nickname @exp or u.name @exp . it's thought. update next query works fine! exec sp_executesql n' declare @skip int = 0, @take int = 24, @name nvarchar(8) = n''foo'' declare @exp nvarchar(max) = ''%...

mysql - Python - Regular Expression to find dates in list -

while looping through csv i'm attempting normalize dates mysql load (yyyy-mm-dd). i've attempted search items contain 2 forward slashes, i've found that's not unique enough identify date. can accomplished regular expression , looking items match pattern? input appreciated. example input: ['1','2','01/02/2015','3','4','1-05-2015','5','anot/her ex/ample','6'] example output: ['1','2','2015-01-02','3','4','2015-01-05','5','anot/her ex/ample','6'] if know order of fields. can use datetime.strptime: from datetime import datetime l = ['1','2','01/02/2015','3','4','1-05-2015','5','another ex/ample','6'] out = [] ele in l: try: out.append(datetime.strptime(ele,"%d/%m/%y").strftime("%y-%m-%d")) exce...

c - android native ndk jnienv* env -

i new in android native app development. reseons need run .so file @ sdcard elf file(executable file). need define jnienv* env variable in elf file , pass .so file dlopen command, or define jnienv* env in .so file, want send sms in native android application. native method below: void java_com_example_calljavaservice_mainactivity_getjnistring() { //i should define env variable here jclass smsmanagerclz = (*env)->findclass(env, "android/telephony/smsmanager"); jmethodid getdefaultmethodid = (*env)->getstaticmethodid(env, smsmanagerclz,"getdefault", "()landroid/telephony/smsmanager;"); jobject smsmanagerobj = (*env)->callstaticobjectmethod(env, smsmanagerclz, getdefaultmethodid); jmethodid sendsmsmethodid = (*env)->getmethodid(env, smsmanagerclz, "sendtextmessage","(ljava/lang/string;ljava/lang/string;ljava/lang/string;""landroid/app/pendingintent;landroid/app/pendingintent;)...

php - IIS 7.5 loses $_POST data? -

i have following form: <form method="post" action="./action.php?a=create" enctype="multipart/form-data"> <input name="formtype" type="hidden" value="file" required /> <input name="formparent" type="hidden" value="<?php echo $parentid; ?>" required /> <table class="fixed"> <tr> <td> <p>display name</p> </td> <td> <input name="formname" type="text" placeholder="enter file name" autofocus autocomplete="off" required /> </td> </tr> <tr> <td> <p>select file</p> </td> <td> <input name="formfile" type="file" placeholder="se...

design - Inside Out TDD and unit tests evolution -

i developing application using inside out tdd , here sequence of steps identified in process: write test basic functionality of class a create class , implement needed functionality write test additional functionality implement needed functionality in class a notice class violates srp extract classes b , c services class uses now, of questions have on "extracting crossroad" are: this assumes injecting dependencies b , c in class a. should use mocks b , c or real instances? if should use real instances of b , c, our unit tests test more 1 unit , become more unit tests (integration or perhaps acceptance tests)? also, if should switch of original unit tests (targeting a) test b , c functionality, i've noticed becomes quite hard write: arrange part tests testing b , c, and setting expectations b , c mocks in unit tests class a since data communicated between , b/c become more granulated , difficult setup. that's clear statement ...

Alternatives to variable-width lookbehind in Python regex -

i've decided jump deep end of python pool , start converting of r code on python , i'm stuck on important me. in line of work, spend lot of time parsing text data, which, know, unstructured. result, i've come rely on lookaround feature of regex , r's lookaround functionality quite robust. example, if i'm parsing pdf might introduce spaces in between letters when ocr file, i'd value want this: oacctnum <- str_extract(textblock[indexval], "(?<=orig\\s?:\\s?/\\s?)[a-z0-9]+") in python, isn't possible because use of ? makes lookbehind variable-width expression opposed fixed-width. functionality important enough me deters me wanting use python, instead of giving on language i'd know pythonista way of addressing issue. have preprocess string before extracting text? this: oacctnum = re.sub(r"(?<=\b\w)\s(?=\w\b)", "") oacctnum = re.search(r"(?<=orig:/)([a-z0-9])", textblock[indexval]).group(1) is t...

android - Defining a String array in XML vs building it dynamically -

i tryin build string array of 60 strings not sure 1 better performance: in code dynamically: minutevalues = new string[60]; string minutesbefore = getresources().getstring(r.string.minutes_before); (int = 0; < 60; ++i) { minutevalues[i] = + 1 + minutesbefore; } or in xml statically: <array name="minutes_before_array"> <item>1 minute before</item> <item>2 minutes before</item> <item>3 minutes before</item> <item>4 minutes before</item> <item>5 minutes before</item> . . . <item>60 minutes before</item> </array> there should no significant performance difference whatsoever. here cleaner way of doing it, though: <string name="minutes_before">%d minutes before</string> and use in code: int minutes = getnumberofminutessomehow(); string timestring = getresources().getstring(r.string.minutes_before, minutes...

serialization - Apache Storm: Remembering old number of output fields for spout -

after changing spouts declaration single field output 2 cluster seems remember old declaration of output. example declarer.declare(new fields("usertask")); to declarer.declare(new fields("tupletrackingid","usertask")); this spout has serialized. remembered also. the error in log states tuple created wrong number of fields. expected 1 fields got 2 fields but has new declaration. questions there way clear history of storm cluster? or clear historically generated serialized object? or if issue? for sanity here spout output. outputcollector.emit(new values(msgid, task), msgid); thanks nimbus buffers submitted topologies in storm.local.dir . should able delete buffered topology there (ie, jar file). but careful: deleting "wrong" files interrupt running topologies!

animation - Unity 5.1 Animator Controller not transitioning -

Image
i have created animator controller (called player ) , assigned animator field of humanoid avatar, simple animation states suitable transitions. please see 2 attached images. i have attached script, containing following code, avatar game object, wonder missing or doing wrong transition idle walk not take place, though can see speed variable increases when press w . could please me understand problem? using unityengine; using system.collections; public class charanim : monobehaviour { private animator animator; float speed; void start() { animator = getcomponent<animator>(); } void update() { animator.setfloat( "speed", input.getaxis("vertical") ); if ( input.getkeydown( keycode.w ) && ( speed > 0.5f ) ) { animator.settrigger("walk"); } else { animator.settrigger("idle"); } } } x the problem ...

php - Limit one to many relationship to a custom maximum number in laravel 5 -

a hasmany(b) b belongsto(a) i want limit number of b maximum of 5. 1 row in can have maximum of 5 rows in b is there way? or should use 1-1 relationship max 5 columns here need do. count number of rows of b against given @ creation request. show error if more 5. there no direct way limit b using laravel, far know.

How to implement icons instead of links in Ruby? -

Image
i have primitive delete link in front of objects in database. looks pretty plain , simple. want find way implement deleting via trash bin icon in example. what need? in advance. try this: link_to (image_tag('delete.png')), 'javascript:void(0)' this show delete icon instead of link text. if not handling delete js javascript:void(0) can replaced rails_path

Lost recieved data when calling recv twice in C socket -

i'm trying read first 4 bytes received network whole message length message this: #include <sys/socket.h> int len,length; char *buffer, lengthx[4]; recv(com_handle, lengthx, 4, 0); sscanf(lengthx, "%" s(4) "x", &len); length=recv(com_handle, buffer , len, 0); for reasons loose 13 bytes of rest of message. ideas? the recv() function not guarantee read full number of bytes specified. linux manual page describes way: the receive calls return data available, requested amount, rather waiting receipt of full amount requested. in way read(2) , prefer purposes. type of socket (stream vs. datagram) impacts this, either function, may need prepared loop, reading repeatedly in order collect pieces of message. and always check return value of syscalls. in case, not need detect errors, need ensure read correctly @ all.

assembly - MIPS: lw (load word) instruction -

is lw $s0,8($0) same lw $s0,0($v0) ? i not see difference. think 8 represents offset, means need addres of $0 , add 2 (8/4) address. edit: my question lw instruction , mips register set. pretty difficult me understand how offset works... they not same, although in circumstances behave alike. format of lw instruction follows: lw regdest, offset(regsource) where regdest , regsource mips registers, , offset immediate. it means, load register regdest word contained in address resulting adding contents of register regsource , offset specified. resulting source address must word-aligned (i.e. multiple of 4) therefore, lw $s0,8($0) means load in $s0 contents of word located @ address specified $0 plus 8. $0 register $zero contain constant zero, load word located in absolute address 8 $s0 . lw $s0,0($v0) means load in $s0 contents of word located @ address specified $v0 . if $v0 contains value 8 both instructions have same effect. if $v0 not multiple o...

mysql - Alternative method of SQL WHERE in PHP -

dear coders , stackoverflow users; yesterday i've fixed sql queries joins of stackoverflow users - post found here while sql query works wonders, haven't been able find replacement queries below; select pid, pname, pstartdate, penddate, photel, pcity projects pstatus = 'active' select pid, pname, pstartdate, penddate, photel, pcity projects pstatus = 'inactive' perhaps php alternative work better sql query, although not entirely sure. trying while() , if() statements gives endless loop far issue has not been solved. tried followings; while( $pstatus == "active" ) { // this. } and if( $pstatus == "active" ) { //do this. }elseif( $pstatus == "inactive" ) { //do that. }; i have 2 tables in first 1 shows 'active' projects while on other 1 shows 'inactive' projects. did sql queries above although since implemented new sql select projects, wondering if there method of replacing said 2 queries php equ...

c# - Is there any way to pass custom state or context from the client through identityserver3 to a custom IdP? -

i working on spike following architecture: [asp.net mvc client] --> [identity server 3 custom middleware] --> [custom idp] the spike prove out more open, standards-based approach better yet bespoke solution serves 1 purpose. the functionality flow require such that: the client perform user search , retrieve customer id the user requested restricted resource providing customer id the openid connect pipeline redirects them through custom idp the custom idp presents page of secret questions user must answered in order them authenticated authentication occurs , passes user through idsvr3 client upon can access restricted resource. my question - achievable? state encrypted on client , should considered unencryptable. have access source code client, idsvr3 instance, custom middleware , custom idp, magic tricks can think of should achievable. i'm using latest nuget package openidconnect in mvc client. i managed by: intercepting response within globa...

angularjs - Angular Currency Formatter with Comma -

i using following syntax format euro amount in angular {{ 20,00 | currency : "€" : 2}} what produces "20.00€" is there simple way format (using syntax) euro price comma instead of dot. like "20,00€" ? https://docs.angularjs.org/api/ng/filter/currency for localisation angular leverages i18n localization , gloablization of applications. using euro symbol not give formatting of comma vs. period. https://docs.angularjs.org/guide/i18n you'll need include formatting including correct i18n script in project. here's example angular if application needs german formatting. <html ng-app> <head> …. <script src="angular.js"></script> <script src="i18n/angular-locale_de-de.js"></script> …. </head> </html> if need format currency based upon symbol currency though, you'll need implement custom filter.

javascript - Regex - replace end of line, not string? -

i building foxpro c# conversion , replacing common foxpro syntax work in c#. 'if' becomes 'if (' 'else' becomes '} else {' 'endif' becomes '}' now need able identify end of line on if statement can close ) { . how can accomplish via regex/jquery? jsfiddle here regular expression work /^if([^$\n\r]+)(?:$|\r\n)/gim check fiddle

Nuget in Visual Studio 2015 ignores allowedVersions? -

i have mvc5 project uses jquery, included through nuget package manager. want keep project on 1.x branch. done using allowedversions attribute in packages.config: <package id="jquery" version="1.11.1" targetframework="net45" allowedversions="[1.10.2, 2.0.0)" /> since switched vs 2015, ignored, nuget suggests 2.1.4 (at time of writing) newer version. tried variations [1.10.2, 2) , [1.1, 2). bug or newer mechanism used achieve this? it's been reported here on nuget project: https://github.com/nuget/home/issues/1094

c++ - set of pointers with custom comparator -

struct classcomp ; typedef struct basic{ int ; set<base*,classcomp> b ; int c ; } base ; classcomp{ bool operator() (const base& *lhs, const base& *rhs) const{ return (*lhs).a < (*rhs).a;} }; i want create set of pointers of datatype base comparator function classcomp .where code gone wrong.someone please help from see in code, you've several places you're trying use dependent declarations don't exist yet. fixing various problems, 1 way is: struct base; //forward decl announces exist (sooner or later) struct classcomp { // uses forward decl before in arguments. since we're // using pointers, no other type info required. don't // implement yet (we can't, don't know // "base" yet). bool operator ()(const base* lhs, const base* rhs) const; }; // define "base". when set declared provide // custom comparator type has yet fleshed out, // that's ok. know *will*...