Posts

Os Exec Sudo Command in Go -

in process of familiarizing myself go , goroutines have hit road block executing commands. format of these commands are: sudo find /folder -type f | while read i; sudo -s chmod 644 "$i"; done with code taken how execute system command in golang unknown arguments i'm trying execute command believe it's not executing due first argument being sudo, wrong. have 2 questions. when these commands fail run returned "exit status 1", there way more detailed error doing? question two, why getting "exit status 1" script? going on isn't supposed to? package main import ( "bufio" "fmt" "os" "os/exec" "strings" "sync" ) func execmd(cmd string, wg *sync.waitgroup) { parts := strings.fields(cmd) head := parts[0] // head @ point "sudo" parts = parts[1:len(parts)] out, err := exec.command(head,parts...).output() if err != nil { ...

c# - DataGridView, Get the value of the first column of the selected row -

i'm wondering efficient way value of first column in datagridview row. currently, i'm using code: list<string> selectedrows = new list<string>(); foreach (datagridviewrow r in dgv.selectedrows) { selectedrows.add(r.cells[0].value.tostring()); } int index = convert.toint32(selectedrows[0]); this works fine; however, there more efficient option this? "most efficient" subjective. don't know following code faster or shorter you've got, it's method prefer use. if you're trying list of values particular column, try this: var results = datagridview1.selectedrows .cast<datagridviewrow>() .select(x => convert.tostring(x.cells[0].value)); if allow 1 selected row @ time, , want convert particular cell, try this: var index = convert.toint32(datagridview1.currentrow.cells[0].value);

Oracle SQL, avoiding errror "table is mutating" (trigger) -

i need trigger check if updated worker can moved other team create table workers ( id_worker number(4,0), --fk id_team number(2,0) --fk ); my trigger looks like: create or replace trigger team_limit before insert or update of id_team on workers each row declare v_num number; begin select count(*) v_num worker id_team=:new.id_team; if v_num >= 5 raise_application_error(-20025,' error nr ... bleble'); end if; end; this generate error : "table %s.%s mutating, trigger/function may not see it" when row updated. how write statements not generate kind of error? you can use compound trigger, looks (not tested): create or replace trigger team_limit insert or update of id_team on workers compound trigger v_num number; type row_tabletype table of workers.id_team%type; affectedteams row_tabletype; before statement begin affectedteams := row_tabletype(); -- init table variable end before statement; -----------------...

javascript - Communicate between content script and options page -

i have seen many questions , background page content script. summary my extension has options page, , content script. content script handles storage functionality ( chrome.storage manipulation). whenever, user changes setting in options page, want send message content script store new data. my code: options.js var data = "abcd"; // let data chrome.tabs.query({ active: true, currentwindow: true }, function (tabs) { chrome.tabs.sendmessage(tabs[0].id, "storedata:" + data, function(response){ console.log(response); // gives undefined :( }); }); content script js chrome.runtime.onmessage.addlistener(function(request, sender, sendresponse) { // not working }); my question: why isn't approach not working? is there other (better) approach procedure. 1) why isn't approach not working? you trying message yourself: options page on you're doing returned chrome.tabs.query({ active: true, currentwindow: ...

html - how to center the button inside a table cell -

i'm trying center button inside table : text-align: center however, seems doesn't work me. note: used display: table-cell combine vertical-align: middle center text of button. can see text of first button "aaaaaaa" in middle. can me center button without affecting text of button. thank in advance. here's example code: http://codepen.io/anon/pen/pacbx i do margin:auto; display:block; i guess @rhino answer works well. remember remove display:table-cell;

javascript - Mongoose .find with a req.params array? and res.json an array of each value and count? -

ideally user able enter multiple tags in search field, delinienated client-side (before .get call), sent on ajax each keypress. working on server-side (testing api postman), if .get serves variable tags array of [ 'tag1', 'tag2'], can req.params.tags array? if so, server - right now, getting response postman localhost:4200/api/v1/tag/tagname .. not /tag/tagname1+tagname2 or /tag/tagname1&tagname2 here's current api: router.route('/tag/:tags') // list of tags usergenerated tags (accessed @ http://localhost:4200/api/v1/tag/:tags) .get(function(req, res) { story.count( { tags: { $in: [ req.params.tags ] } }, function (err, count) { if (err) res.send(err); console.log('there is/are %d story/ies this/these tag(s)', count); if (count >= 1) { story.find( { tags: { $in: [ req.params.tags ] } }, 'tags', function(err, stories) { ...

jquery - Fill progress bar with php value -

i make progress bar link : http://www.metallicabyrequest.com/results.php?s=70 and have table 3 columns , progress bar should fill value third column : http://jsfiddle.net/metcastle/ensr2/ <table> <thead> <tr> <th>song name</th> <th>% ballots w/ song</th> <th># votes</th> </tr> </thead> <?php foreach($array $element) { ?> <tr> <td class="name"><?php echo $element['name']; ?></td> <td>progress bar 3 td value percent</td> <td><?php echo $element['votes']; ?></td> </tr> <?php } ?> </table> hope can understand try say, ! if have number of total votes ($totalvotes) work with, ,...