Posts

Showing posts from April, 2010

php - need to add in_reply_to when using imap_append -

i`m trying append mail after send in sent mailbox... public function append_mail($mail_box, $replyto, $from, $to, $subject, $text, $attaches = []){ $mailbox = "{".$this->imap_host.":".$this->imap_port.$this->imap_path."}".$mail_box; $dmy = date("d-m-y h:i:s"); $boundary = "------=".md5(uniqid(rand())); $msgid = $this->generatemessageid(); $msg = "from: $from\r\n"; $msg .= "to: $to\r\n"; $msg .= "date: $dmy\r\n"; $msg .= "message_id: $msgid\r\n"; $msg .= "in_reply_to: $replyto\r\n"; $msg .= "subject: $subject\r\n"; $msg .= "mime-version: 1.0\r\n"; $msg .= "content-type: multipart/mixed; boundary=\"$boundary\"\r\n"; $msg .= "\r\n\r\n"; $msg .= "--$boundary\r\n"; $msg .= "content-type: text/

python - Regex matching the end of a line correctly -

Image
i'm looking way re.sub lines ending \n , \r\n while preserving line ending. import re data = "foo\r\nfoo\nfoo" regex = r"^foo$" re.sub(regex, "bar", data, flags=re.multiline) leaves me with foo\r\nbar\nbar when using regex ^foo(\r)?$ check optional \r , i'll end with bar\nbar\nbar any ideas? edit : expected result bar\r\nbar\nbar use positive lookahead assertion import re data = "foo\r\nfoo\nfoo" regex = r"^foo(?=\r?\n?$)" re.sub(regex, "bar", data, flags=re.multiline) output : 'bar\r\nbar\nbar' regex explanation here.

php - Show database data with CodeIgniter -

i want show data in database codeigniter. my code shows error 404 page requested not found . model <?php class daftar_model extends ci_model { public function __construct() { //connect ke database $this->load->database(); } public function get_pertanyaan() { $query = $this->db->get('pertanyaan_ts'); return $query->result_array(); } } ?> controller <?php if ( ! defined('basepath')) exit('no direct script access allowed'); class daftar_controller extends ci_controller { public function index() { //echo "hallo"; $this->load->model('administrator/pertanyaan/daftar_model'); $this->load->view('administrator/pertanyaan/daftar_view',$data); $data["pertanyaan_ts"] = $this->daftarpertanyaan_model->get_pertanyaan; } view

java - Constructor problems with inheritance and generics -

i having hard time understanding generics inheritance. error getting is: stage.java:66: error: constructor stage in class stage<t> cannot applied given types; { ^ required: arraylist<t>,double,arraylist<t> found: no arguments reason: actual , formal argument lists differ in length t type-variable: t extends object declared in class stage what have subclass called stage0 (an inline class of stage) inherits stage. stage0 have same functionality bar - stage0 @override method parent class. here line 63 of stage class (which beginning of stage0) class stage0 extends stage<t> { stage0(arraylist<t> inq, double inputtime, arraylist<t> outq) { inputqueue = inq; takestime = inputtime; outputqueue = outq; } @override public boolean isstarving(double time) { return false; } } what source of error? cheers. public class stage<t> // equivalent 'storage

iphone - Parsing Local XML File Works, Downloaded XML File Doesn't -

i have problem when fetch xml file internet , parse it, error: error while parsing document: error domain=smxmldocumenterrordomain code=1 "malformed xml document. error @ line 1:1." userinfo=0x886e880 {linenumber=1, columnnumber=1, nslocalizeddescription=malformed xml document. error @ line 1:1., nsunderlyingerror=0x886e7c0 "the operation couldn’t completed. (nsxmlparsererrordomain error 5.)"} here extract code (i believe showing relevant code, if need more, please ask.) // create url request , set url nsurl *url = [nsurl urlwithstring:@"http://***.xml"]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:url]; // display network activity indicator [[uiapplication sharedapplication] setnetworkactivityindicatorvisible:yes]; // perform request on new thread don't block ui dispatch_queue_t downloadqueue = dispatch_queue_create("download queue", null); dispatch_async(downloadqueue, ^{ nserror* err = nil;

c# - Unable to launch an exe file from webapi Controller MVC -

hi trying launch exe file webapicontroller on receiving request. the exe file on server. want launch on server. the exe triggered, can see process name in task manager not access console window.tried adding useshellexecute true. still shows under backround process var processinfo = new processstartinfo("cmd.exe", "/c " + command); processinfo.createnowindow = true; processinfo.useshellexecute = true; processinfo.windowstyle = processwindowstyle.maximized; processinfo.redirectstandarderror = true; processinfo.redirectstandardoutput = true; var process = process.start(processinfo);

c - Distinguish between numbers and alphabet in a string -

i trying build tcpip communication between server , client in visual studio , client accept string keyboard, , send string server if numbers not alphabet tried below code seems there wrong. while (rc == socket_error); //try long till there connection (no socket error) printf("conected %s..\n\n", address); { printf("please insert blood pressure values further diagnostic\n "); gets(data); char i; (i = data[0]; <= max; i++) { char n = data[i]; if ((strlen(data) > max) || (strlen(data) == 0)) { printf("argument not allowed!\n\n"); memset(data, '\0', strlen(data)); continue; } if ((n >= 'a' && n <= 'z') ||( n >= 'a' && n <= 'z')) { printf("you have enter number !\n\n"); memset(data, '\0', strlen(data));

Present Drupal 8 Custom widget choice only in certain context -

i have custom drupal 8 widget textfields, want present choice in "manage form display", if textfield attached entity type, in fact media entity type. widget makes no sense in other contexts. don't want create custom field type purpose of filtering out field formatters. any ideas. there hook can access here? thanks ...

c++ - Why can templates only be implemented in the header file? -

quote the c++ standard library: tutorial , handbook : the portable way of using templates @ moment implement them in header files using inline functions. why this? (clarification: header files not only portable solution. convenient portable solution.) it not necessary put implementation in header file, see alternative solution @ end of answer. anyway, reason code failing that, when instantiating template, compiler creates new class given template argument. example: template<typename t> struct foo { t bar; void dosomething(t param) {/* stuff using t */} }; // somewhere in .cpp foo<int> f; when reading line, compiler create new class (let's call fooint ), equivalent following: struct fooint { int bar; void dosomething(int param) {/* stuff using int */} } consequently, compiler needs have access implementation of methods, instantiate them template argument (in case int ). if these implementations not in header, wouldn

php - long TTFB on php7 apache -

i had installed php7 on apache 2.4, debian 8. chrome client, had used ctrl-f5 prevent loading cache. i running next 2 files, times avg: 1. hello.php (206ms ttfb) <?php echo "hello world"; 2. hello.html (5ms ttfb) hello world php: opcode caching , running as can see there huge difference between two. what can speed php slow process? it's seems apache problem.

html - I don't see why my :last-child selector isn't working as it should be -

in css i've used wrapped divs class call last-child remove right margin, reason can't find problem. .user-panel { border-bottom-color: #8f8f8f; background-color: #fcfcfc; border-style: solid; border-width: 1px; border-color: #d9d9d9; float: left; width: 257px; margin-top: 40px; border-bottom-color: #8f8f8f; margin-right: 5px; } .user-panel-wrap:last-child { margin-right: 0px; } .user-panel:hover { background-color: #b2d195; } .user-panel-image { margin: 5px auto; display: block; } .user-panel-header { font-size: 26px; text-align: center; margin: 0; color: black; } .user-panel-paragraph { color: #a0a09e; margin: 0; text-align: center; font-size: 19px; } <div class="user-panel-wrap"> <a class="user-panel-link" href="#"> <div class="user-panel"> <img class="user-panel-image" src="pictures/toc

sql server 2008 r2 - ssrs/ssrb end user picks a date to filter by -

i'm using sql server 2008 r2 , i'm new building reports ssrs. have reports built, i'm trying make when end user, goes report on site, able pick start , end date. data gets filtered those, @ each quarter. i've been looking through interwebs few hours , looks people able this, haven't seen on how yet. also see there date picker thats greyed out, i've read can used in web projects, i'm looking for? i don't have 2008 in 2012 define 2 parameters date/time , amend dataset include them. example select salesorderid, orderdate, status, totaldue sales.salesorderheader orderdate between @lodate , @hidate the datasource in case advicentureworks2012. ssrs automatically adds parameters report , includes date picker.

html - Multiple responsive background images -

Image
i've got .container { width: 960px; margin: 0 auto; } .bgcontainer { width: 960px; background-image:url(images/midbg.gif); margin: 0 auto; } i need attach 2 (background)images floating container. 2 wings can see in image. they should hide when there no place 1024 px. put background on body. http://codepen.io/anon/pen/fasha

android - Notifications every 24h at specified hour -

my code partially works. shows if app opened +/- 2h before time notification, later doesn't show notification. notification doesn't show @ time should. public class backgroundservice extends service { private static final int first_notification = 9; private static final int second_notification = 17; timer t1; timer t2; @nullable @override public ibinder onbind(intent intent) { return null; } @override public void oncreate() { super.oncreate(); } @override public int onstartcommand(intent intent, int flags, int startid) { super.onstartcommand(intent,flags,startid); t1 =new timer(); // t2 = new timer(); log.d("service","service started!"); date da = new date(); da.settime(system.currenttimemillis()); if(da.gethours()>=first_notification){ da.setdate(da.getday()+1); } da.sethours(first_notification); da.setminutes(0); da.setseconds(0); if(t1!=null) { t1.schedule(new timert

node.js - creating certificate for android volley and nodejs -

i developing android application can connect multiple node server. connection needs secure need certificates. cant pay certificates. researches, create certificates each server , sign them own root certificate(i need that). pin root certificate android application. can connect multiple server 1 android app. dont know create certificates , how pin android application. a ca can generate certificate bound ip, not usual. agree in case more appropriate use self-generated certificates. need 1) create ca certificate , ssl certificate extracted here need openssl create ca certificate openssl genrsa -out rootca.key 2048 openssl genrsa -des3 -out rootca.key 2048 openssl req -x509 -new -nodes -key rootca.key -sha256 -days 1024 -out rootca.pem this start interactive script ask various bits of information. rootca.pem create 1 certificate each device openssl genrsa -out device.key 2048 openssl req -new -key device.key -out device.csr openssl x509 -req -in device.

sql server - Will joining on integer be quicker than joining on nvarchar? -

does have significant impact on performance if use integer key columns instead of nvarchar(20) ? assume fields used in joins have been indexed. please take @ following post. join on varchar vs join on int basically int best option.

javascript - Bootstrap Popover: It disappears instead of staying active -

i'm dealing bootstrap popovers , i'm getting stuck. when click button, popover shows , disappears again. doesn't stay visible. besides, when click button , popover shows, image placed in web blinks, strange. have been trying different popover configurations it's weird , don't work. btw, i'm using ruby on rails , bootstrap/jquery gem. here code: <div class="span9"> <table class="table"> <thead> <tr> <th>#</th> <th>domain</th> <th>api key</th> <th>api secret</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>http://www.example.com</td> <td>29383947382</td> <td><a href="#" class="btn btn-small btn-warning" id="api_secret" rel="popover"

linux - Script to check for process & restart program if not found -

this question has answer here: how write bash script restart process if dies? 6 answers i using check script see if package called cccam running & restart if not.. #!/bin/sh process=`ps auxwww | grep cccam | grep -v grep | awk '{print $1}'` if [ -z "$process" ]; echo "couldn't find cccam running. restarting server-binary" >> /var/cccamlog/cccam.check echo && date >>/var/cccamlog/cccam.check /usr/local/bin/cccam -d >> /var/cccamlog/cccam.log & else echo "cccam still ok!" >> /var/cccamlog/cccam.check fi the script reporting "cccam still ok!" but not running, if search process using command: ps x |grep -v grep |grep -c cccam , 0 know process not running. is there other factors should take account might fooling check script thinking cccam running? example, there kind

php - mySQL database not updating from form -

not sure error is. in html have form, , when click submit gives me error. connection working, reason won't add database <?php if( isset( $_post['submit'] ) ){ $username = $_post['username']; $password = $_post['password']; $connection = mysqli_connect( 'localhost', 'root', '', 'loginapp' ); if($connection){ echo "we connected"; } else{ die( "connection failed" ); } $query = "insert users(username,password) "; $query.= "values('$username','$password')"; $result = mysqli_query( $connection, $query ); if( !$result ){ // if not true, put query failed die('query failed' .mysqli_error($connection)); } } ?> i wondering if there wrong here code isnt working planned $query = "insert users(username,passw

android - Static reference to images file in my Database -

let's want create database static references images included in android app. if use drawable folder, ids dynamic , can't use static reference them. since want use 1 column of database resource suggestion icons in app, using drawables files not simple... if want it, in folder should put .png files? , in database, url should save each entry? it's pretty simple use in normal drawable folders , write in db string/text. the resources object have few methods deal it: getidentifier(...) use integer id of drawable, example: context.getresources().getidentifier("icon", "drawable", context.getpackagename()); and getresourceentryname(...) use string name of drawable, example: context.getresourceentryname(r.drawable.icon);

file - C - Create/Write/Read named pipe -

i want create named pipe , write , after want read it. here code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <errno.h> #include <string.h> #include <fcntl.h> #define fifo "fifo0001" int main(intargc, char *argv[]){ char input[256]; file *fp; char str[50]; printf("please write text:\n"); scanf("%s", input); unlink(fifo); /* because exists, unlink before */ umask(0); if(mkfifo(fifo, 0666) == -1){ printf("something went wrong"); return exit_failure; } if((fp = fopen(fifo, "a")) == null){ printf("something went wrong"); return exit_failure; } fprintf(fp, "%s", input); if(fgets(str, 50, fp) != null){ puts(str); } fclose(fp); return exit_success; } after write text, nothing happen anymore. , there

android - how to add images from URL to ListBox -

i want load images url list in listbox items, code retrieve urls var ljsonarray : tjsonarray; lentity: tbackendentityvalue; : integer; begin try ljsonarray := tjsonarray.create; backendstorage1.storage.queryobjects('list', [], ljsonarray); := 0 ljsonarray.count-1 begin listbox4.items.add (ljsonarray.items[i].getvalue<string>('pictures')); end; ljsonarray.free; end; end; update 1 procedure tform1.button1click(sender: tobject); var lbitem : tlistboxitem; i: integer; http : tidhttp; stream : tmemorystream; begin http := tidhttp.create(nil); try := 0 listbox1.items.count-1 begin lbitem := tlistboxitem.create(nil); lbitem.parent := listbox2; lbitem.height := 100; stream := tmemorystream.create; http.get(listbox1.items.strings[i], stream); lbitem.itemdata.bitmap.loadfromstream(stream); end; stream.free; http.free; end; end; i tried loading pictures in listbox, however, there items added witho

mysql - MS-ACCESS How to create query to select all records with fields matching from another query? -

i know question may sound confusing, let me try simplify it. i have query, let's call query1, , larger table of products. here query1: item_code description order_qty option 1000 prod1 5 blue 1005 prod5 3 brown 1602 prod6 1 red 5620 prod8 6 yellow 9865 prod2 1 brown 1624 prod3 3 brown 9876 prod12 4 blue now in table, have bigger list of products same format. want make new query contains blue, brown, red, , yellow. works, there duplicate. i'm not sure how post attempt i'll explain tried. made new query , included table , query1. made relationship between two, include rows "option" equal. reason resulting query come out repeats. such as: item_code description order_qty option 1000 prod1 5 blue 1009 <-- prod2

javascript - Submiting one form to two different URLs -

hello, folks!! i not experience. appreciate follows: goal: run 2 actions associated 1 submit, have add urls , pull out necessary info need form. constraints: no access database, no ajax , no php. problem: nothing happens when use <input type="button" value="submit" onclick="onbtn1(); onbtn2();"> i tried these no luck: two onclick actions 1 button submit single form 2 actions html code: <script type="text/javascript"> function posttourl () { document.form1.action = "https://db2.com/cgi-bin/b.cgi?" document.form1.submit(); } </script> <form id=" form1" method="post" action="https://db1.com/cgi-bin/a.cgi?" onsubmit="posttourl();"> <input type="text" id="field1" name="field1"> <input type="text" id="field2" name="field2"> <

Send two lists by Json and Get it from Array on JavaScript -

i have 2 lists on controller , send lists array in json javascript. see controller code here: var aval = new list<avaliacaoviewmodel>(); aval = reldata.getavaliacao(data_1, data_2, cliente, operador); var resumo = new list<resumoviewmodel>(); resumo = reldata.getresumo(data_1, data_2, cliente, operador); var result = new { aval = aval, resumo = resumo }; return json(result, jsonrequestbehavior.allowget); my list1 - controller-1 my list2 - controller-2 its working fine , can see 2 arrays on javascript: $.ajax({ url: '/relatorios/avaloperador', datatype: "json", type: "get", data: { 'data1': data1, 'data2': data2, 'operador': operador }, success: function (data) { debugger; var aval1 = avalia.getvalue(1); var aval2 = avalia.getvalue(2); var aval3 = avalia.getvalue(3); var

ruby - "certificate verify failed" despite setting CACERT.PEM environment variable in Windows 10 -

i have set environment variable ssl_cert_file correctly -- here's cmd output set: ssl_cert_file=c:\railsinstaller\cacert.pem here's link have in cacert.pem: cacert.pem here's cmd windows output running irb: c:\users\anon\prog\workspace>irb irb(main):001:0> require 'open-uri' => true irb(main):002:0> open ('https://www.youtube.com') openssl::ssl::sslerror: ssl_connect returned=1 errno=0 state=sslv3 read server certificate b: certificate verify failed c:/railsinstaller/ruby2.1.0/lib/ruby/2.1.0/net/http.rb:923:in `connect' c:/railsinstaller/ruby2.1.0/lib/ruby/2.1.0/net/http.rb:923:in `block in connect' c:/railsinstaller/ruby2.1.0/lib/ruby/2.1.0/timeout.rb:75:in `timeout' c:/railsinstaller/ruby2.1.0/lib/ruby/2.1.0/net/http.rb:923:in `connect' c:/railsinstaller/ruby2.1.0/lib/ruby/2.1.0/net/http.rb:863:in `do_start' c:/railsinstaller/ruby2.1.0/lib/ruby/2.1.0/net/http.rb

java - Getting error when changing other activity's TextView -

i'm beginner @ android , java , have error when trying change other activity's textview. i've created mainactivity, , 1 (playernames). i've set playernames launcher activity, maybe error that, don't know. post error , code: fatal exception: main process: com.example.android.mapamundi, pid: 1423 java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.android.mapamundi/com.example.android.mapamundi.playernames}: java.lang.nullpointerexception: attempt invoke virtual method 'android.view.window$callback android.view.window.getcallback()' on null object reference @ android.app.activitythread.performlaunchactivity(activitythread.java:2236) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2387) @ android.app.activitythread.access$800(activitythread.java:151) @ android.app.activitythread$h.handlemessage(activitythread.java:1303) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(lo

Unknown C++ braces syntaxis -

this question has answer here: what purpose of anonymous { } blocks in c style languages? 16 answers look @ snippet: void sample_compositor::createeffects(void) { ogre::compositorptr comp3 = ogre::compositormanager::getsingleton().create("motion blur", ogre::resourcegroupmanager::default_resource_group_name); { { ogre::compositiontargetpass *tp = t->getoutputtargetpass(); tp->setinputmode(ogre::compositiontargetpass::im_none); { ogre::compositionpass *pass = tp->createpass(); pass->settype(ogre::compositionpass::pt_renderquad); pass->setmaterialname("ogre/compositor/motionblur"); pass->setinput(0, "sum"); } } } } if code legit, how these blocks work? they blocks introdu

ios - SKAction: scaleTo:1.0 duration .01, is there a way to make "duration" any faster/instant? Objective C, Sprite Kit -

i trying duration of skaction down pretty nothing. reason action subtracts users coins, , though .01 pretty fast, still not instant , user cannot make move while coins subtracting. there anyways "instantly" perform skaction? nslog(@"subtractusercoinsactivated"); int = user_coins; int result = - 49; [self setuserinteractionenabled:false]; __block int dummyscore = a; skaction* scaleup = [skaction scaleto:1.0 duration:0.01]; skaction* block = [skaction runblock:^{ dummyscore--; _usercoinstext.text = [nsstring stringwithformat:@"%i",dummyscore]; if(dummyscore == result) { [_defaults setinteger:result forkey:@"usercoins"]; [_defaults synchronize]; nslog(@"-49 coins"); [self setuserinteractionenabled:true]; if

itertools - using python's 'with' while reading two files simultaneously with izip -

i regularly use python read 2 or more files simultaneously in following way: for line1, line2 in izip(open(file1),open(file2)): line1 , line2 (using izip itertools package because files i'm reading huge , don't want load entire file memory). i have been converted using with while reading files, apparently better since close open files if program crashes (at least that's understand discussion on here , other places): with open(filename) fh: line in fh: line however, can't seem figure out how combine these 2 methods. when trying use izip in context, says 'itertools.izip' object has no attribute '__exit__' intuit part of reason why using with powerful. so, there anyway use izip with ? you'll kick when see how obvious : with open(fname1) f1, open(fname2) f2: line1, line2 in izip(f1, f2): ...

html - Can't set a margin with AngularJS (JavaScript) -

my name fernando , first topic in stack overflow. looking code error , didn't anything. i created application angularjs routing in added container show in example , have added span , button. in span , button added margin, element not obeying code. div.mainheader { width: 100%; height: 25%; background-image: no-repeat; background-size: 100%; } div.mainheader span { float: left; margin-left: 10px; margin-bottom: 10px; font-size: 18px; color: white; } div.mainheader .md-fab { float: right; margin-right: 10px; margin-bottom: 10px; } <div class="mainheader" ng-controller="linkcontroller" ng-style="{'background-image': 'url({{ linkheader + 'international.png' }})'}"> <span>international</span> <md-button class="md-fab md-mini md-primary" aria-label="favorite"> <md-icon class="material-icons">notifications_no

How to do basic authentication using Selenium Webdriver and PhantomJS? -

i'm having trouble authenticating using selenium server 2.33.0, selenium webdriver js binding 2.34.0 (npm package "selenium-webdriver") , phantomjs 1.9.1 on mac 10.6.8. i've tried other js bindings "webdriverjs" , "wd" similar results don't think it's problem binding. i setup webdriver using this: return new webdriver.builder(). usingserver('http://localhost:4444/wd/hub'). withcapabilities({ "browsername": "phantomjs", "phantomjs.page.settings.username":user, "phantomjs.page.settings.password":password }).build(); i see in selenium server log output: phantomjs launching ghostdriver... [info - 2013-08-13t21:52:40.240z] ghostdriver - main - running on port 28904 [info - 2013-08-13t21:52:40.394z] session [acd0ad70-0462-11e3-95df-4b230b17334d] - constructor - desired capabilities:{"phantomjs.page.settings.password":"xxx","

asp.net mvc - Bower Failed to execute git clone -

i trying import jplayer package through bower in asp.net application error code every time: ecmderr failed execute "git clone https://github.com/happyworm/jplayer.git -b 2.9.2 --progress . --depth 1", exit code of #-532462766 does know issue , if end? rest of imports work fine. { "dependencies": { "bootstrap": "^3.3.6", "jquery": "^2.2.1", "jquery-ui": "^1.11.4", "jquery-validate": "^1.15.0", "jquery-ajax-unobtrusive": "^3.2.4", "jquery-validation-unobtrusive": "^3.2.6", "select2": "^4.0.2", "dropzone": "^4.3.0", "jplayer": "*", // fails "font-awesome": "^4.5.0" }, "name": "test", "private": true, "version": "1.0.0", "authors": [

javascript - AJAX get() data -

i have block of jquery uses $.get() method in setinterval() . don't understand how data second url jquery code. jquery: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script type="text/javascript"> setinterval(function() { $.getjson("check_time.php", function(update) { if (update) { $("#slideshow").load("phppage.php"); } }); }, 600000); </script> php - check_time.php <?php require_once('connect_pdo.php'); header('content-type: application/json'); $stmt = $conn->prepare("$sqlst = $conn->prepare("select count(*) count ads lastupdate > now() - interval 10 minute"); $sqlst->execute(); $row = $sqlst->fetch();"); $stmt ->execute(); $row = $stmt ->fetch(); $update = $row['count'] > 0; $updtstatus = js

sql server - Can I use DT_STR in T-SQL -

i using ssis in have code use parsing files year / month , day in expression builder use: (dt_str,4,1252)month( dateadd( "dd", -1, getdate() )) gets month (dt_str,4,1252)day( dateadd( "dd", -1, getdate() )) gets day (dt_str,4,1252)year( dateadd( "dd", -1, getdate() )) gets year however, when coding, paste code sql server query window well, dt_str seems specific ssis ? is there equivalent replacement, or why can't use in t-sql? edit: ok, see code not all portable t-sql , nor used correctly month , day never being length of 4 (dt_str, 4, 1252) year (dateadd ( "dd", 0, getdate())) + right ("0" + ltrim ((dt_str, 4, 1252) month (dateadd ("dd", 0, getdate()))), 2) + right ("0" + ltrim ((dt_str, 4, 1252) day (dateadd ("dd", -1, getdate()))), 2) + ".txt" the ssis expression language not tsql. might ask why can't paste motorola 68k assembly code r compiler? dt_str integra

How do I change opacity of background in css without altering the entire container -

this question has answer here: how give text or image transparent background using css? 26 answers simple may need create background website container semi-transparent. if add opacity: 0.5; inside of #content end having entire container, widgets , letters going ghost. should apply transparency background image? 1 answer add transparency picture inside of ps still curious. #content .container { background:url(images/menu_bar.png) left top repeat-y !important; } give try: #content .container { width: 500px; height: 100px; background: url(../images/menu_bar.png) left top repeat-y rgba(0, 0, 0, 0.5) !important; } the 'a' in rgba sets opacity of color 'rgb'. of course can set values liking though. if helps, click checkmark ;) also, don't forget set width , height of image.

apache pig - How to load data from the output of mapreduce part-r to Pig or Hive -

i have data generated part r mapreduce job in following format: (19,[2468:5.0,1894:5.0,3173:5.0,3366:5.0,3198:5.0,1407:5.0,407:5.0,1301:5.0,2153:5.0,3007:5.0]) (20,[3113:5.0,3285:5.0,3826:5.0,3755:5.0,373:5.0,3510:5.0,3300:5.0,22:5.0,1358:5.0,3273:5.0]) 19 , 20 users ids , array within [] recommendations users, each recommendation separated comma. want load data in tabular format - row 1 =19,2468,5.0,3175, row 2 = 19, 1894, 5.0, 3173 , on. how achieve pig or hive? so far, have tried in pig haven't been able parse desired output. i looking create report can display user name (by joining user table), recommended movie names user (by joining movie table) , user rating. in data above, 19 user id. within parentheses recommended movie ids user along rating. each recommendation separated comma.

javascript - Sorting an array of objects? -

i have following data structure , i'm stuck on way sorting variants items in ascending order based on price. ideally need way find lowest price of item variant while still having access variant's parent. var items = [ { "id" : 1 , "name" : "name1", "variations" : [ { "subid" : 1000011, "subname" : "name1a", "price" : 19.99 }, { "subid" : 1000012, "subname" : "name1b", "price" : 53.21 }, { "subid" : 1000013, "subname" : "name1c", "price" : 9.49 } ] }, { "id" : 2, "name" : "name2", "variations" : [ { "subid" : 1000021, "subname" : "name

string - Creating an R data.frame column based on the difference between two character columns -

i have data.frame, df, have 2 columns, 1 title of song , other combined title , artist. wish create separate artist field. first 3 rows shown here title titleartist i'll never smile again i'll never smile again tommy dorsey & orchestra / frank sinatra & pied pipers imagination imagination glenn miller & orchestra / ray eberle breeze , breeze , jimmy dorsey & orchestra / bob eberly there no issues on set of data code library(stringr) library(dplyr) df %>% head(3) %>% mutate(artist=str_to_title(str_trim(str_replace(titleartist,title,"")))) %>% select(artist,title) artist title 1 tommy dorsey & orchestra / frank sinatra & pied pipers i'll never smile again 2 jimmy dorsey & orchestra / bob eberly breeze , 3 glenn miller & orchestra / ray eberle imagination bu

math - Lagrange polynomial: Unexpected interpolation results -

i trying interpolate series of data points using 2nd lagrange polinomial. having point1:(5;100) point2: (9;17) point3: (12;17) and formula y=(x-x2)*(x-x3)/(x1-x2)*(x1-x3)*y1+ (x-x1)*(x-x3)/(x2-x1)*(x2-x3)*y2+ (x-x1)*(x-x2)/(x3-x1)*(x3-x2)*y3 it obvious quadratic function might not fit data.. example. but wonder why value surprisingly high x=7 . if not wrong y=1500 . is above formula correct? answer: in summary: for same x , can't have 2 different y values; violates definition of function. you missing brackets in formula! not (x-x2)*(x-x3)/(x1-x2)*(x1-x3) , ((x-x2)*(x-x3)) / ((x1-x2)*(x1-x3)) . back 1>, note interpolation formula has x3-x2 in denominator. if have tied values, dividing 0. how can make interpolation on such small data set? yet asking quadratic interpolation! follow-up: 1) fixed it. accidentally switched x , y values. points in format (y,x). ah, haha, no wonder. 2) thank you! brackets improved approximation. r

Java: Modifying parameter passed as a Reference -

i have implement interface method has signature like: public int runmethod(final int key, reference <string> result); i have update value of result parameter before method returns. example if value of result abc when method invoked, need modify def , return caller. can suggest how achieve it? you can't modify variable passed method. example: public int runmethod(final int key, reference <string> result) { result = null; // changed method's version of variable, , not variable passed method } ... reference<string> ref = ... runmethod(0, ref); // ref still assigned however, can modify fields , call methods of object pass. public int runmethod(final int key, reference <string> result) { result.somefield = ...; // here changing object, same object passed method. } ... reference<string> ref = ... runmethod(0, ref); // ref.somefield has been changed an alternative change method's return type reference<string&g

angularjs - angular ui router nested state with params cannot load stylesheet -

i'm still new angular ui router , have problem nested state / nested views need help. have angular app using ui.router states definition bellow: $locationprovider.html5mode(true); $stateprovider .state('root',{ abstract:'true' views:{ 'top@':{}, '@':{} } }) .state('childone',{ url:'/childone, parent:'root' views:{ 'top':{ template:"top navigation bar"}, '':{template:"main navigation"} } }); for childone state, every thing work expected until add params state : ... .state('childone',{ url:"/childone/:child_id", parent:"root", views:{ 'top@':{ template:"top navigation styling in app.css"

while loop - Java recursion class variable value is reset to 0 -

i trying implement coin change problem using recursion. have written following code , facing problem static class variable. 'answer' class variable , trying add return value in loop. works fine within while loop after while loop ends answer reset 0; while (i * currentcoin <= sum) { system.out.println("inside while; answer " + answer); answer = answer + findcombinations( sum - * currentcoin, new arraylist<integer>(denominations.sublist(1, denominations.size()))); i++; } below code have written. can copy , run check. import java.util.arraylist; import java.util.collections; public class coinchangehashmap { static int answer = 0; public static void main(string[] args) { int[] array = new int[] { 7, 3, 2 }; arraylist<integer> input = new arraylist<integer>(); getlist(array, input); findcombinations(12, input);

Spark application development on local cluster by IntelliJ -

i tried many things execute application on local cluster. did not work. i using cdh 5.7 , spark version 1.6. trying create dataframe hive on cdh 5.7. if use spark-shell, codes works well. however, have no idea how can set intellj configuration efficient development environment. here code; import org.apache.spark.{sparkconf, sparkcontext} object dataframe { def main(args: array[string]): unit = { println("hello dataframe") val conf = new sparkconf() // skip loading external settingg .setmaster("local") // "local[4]" 4 threads .setappname("dataframe-example") .set("spark.logconf", "true") val sc = new sparkcontext(conf) sc.setloglevel("warn") println(s"running spark version ${sc.version}") val sqlcontext = new org.apache.spark.sql.hive.hivecontext(sc) sqlcontext.sql("from src select key, value").collect().foreach(println) } } wh