[Solved] To peek into kernel by socket failure with levels and kill-9

This more a Server Fault kind of question, but try running psql like this: sudo -u postgres psql When you install PostgreSQL, there’s no user account created for your current user, so you’d have to create one. That can be achieved like this (where masi is the wanted username): sudo -u postgres createuser -sdrPE masi … Read more

[Solved] Base64 decoding – incorrect string length

Are you using str[n]cpy? You can’t! Base64 encoded data can contain null characters, which C string processing functions interpret as end-of-string. Use memcpy instead of str[n]cpy, memcmp instead of strcmp, etc. These functions require you to know your data size, but I believe that you do know it. Also if you’re not very confident about … Read more

[Solved] What is an alternative for split in Perl? [closed]

Howzabout this: #!/usr/bin/perl use warnings; use strict; my $s = q/a: b d: e f: a:b:c g: a b c d f:g:h h: d d:dd:d f /; open my $input, “<“, \$s or die $!; my @left; my @right; while (<$input>) { chomp; my ($left, $right) = /^(.):?\s+(.*)$/; push @left, $left; push @right, $right; } … Read more

[Solved] How to get the trending topics of twitter with php? [closed]

I’m not sure you should be asking people to write code for you, but anyway, here you are. <?php $request = file_get_contents( ‘http://search.twitter.com/trends/current.json’ ); $json = json_decode( $request, true ); $trends = $json[ ‘trends’ ]; $keys = array_keys( $trends ); $trends = $trends[ $keys[ 0 ] ]; $trends = array( $trends[ 0 ][ ‘name’ ], … Read more

[Solved] How to read the entire content of a file character by character?

I would do this like this: std::ifstream infile(“myfile.txt”); char ch; while(infile.get(ch)) { … process ch … } This avoids the problems that appear on the last character, or having to read a character before the first iteration of the loop. solved How to read the entire content of a file character by character?

[Solved] Print a for-loop, Java

There are multiple things. One is that some of your code is unnecessary. public Dice(int dice1 /*, int a, int b, int c, int d, int e, int f*/ ){ this.dice1 = dice1; //this.a = a; //this.b = b; //this.c = c; //this.d = d; //this.e = e; //this.f = f; } You don’t need … Read more

[Solved] Grouping JavaScript array with sum

Do it like this: var array = [{t_id:”1″,val1:”1″,title:”cash to purchase”,unit:”bag”},{t_id:”1″,val1:”1″,title:”cash to purchase”,unit:”bag”},{t_id:”1″,val1:”1″,title:”cash to purchase”,unit:”bag”},{t_id:”2″,val1:”4″,title:”offload”,unit:”bag”},{t_id:”2″,val1:”5″,title:”onroad”,unit:”bag”},{t_id:”3″,val1:”5″,title:”Onroad”,unit:”bag”},{t_id:”3″,val1:”6″,title:”Onroad”,unit:”bag”}]; var grouped = []; array.forEach(function(o) { var count = 0; if (!this[o.t_id]) { this[o.t_id] = { t_id: o.t_id, val1: 0, title: o.title, counter: count }; grouped.push(this[o.t_id]); } this[o.t_id].val1 += Number(o.val1); this[o.t_id].counter += Number(++count); }, Object.create(null)); console.log(grouped); Now in HTML show like … Read more

[Solved] Got stuck with Caesar.c

A function to caesar an alphabetic char should be like (decomposed in elementary steps): int caesar_lower(int c,int key) { int v = c-‘a’; // translate ‘a’–‘z’ to 0–25 v = v+key; // translate 0–25 to key–key+25 v = v%26; // translate key–key+25 to key–25,0–key-1 v = v+’a’; // translate back 0–25 to ‘a’–‘z’ return v; … Read more

[Solved] Convert a `while` loop to a `for` loop

I think it should be something like this : for(;a<b–;){ for(d += a++ ; a != c ; ) { d += a++; } c+= a&b } The above logic works ! I ran both programs as below and they output the same result : Program1:[derived from your program 1] #include<stdio.h> int main(){ int a=10,b=10,c=10,d=10; … Read more

[Solved] Special character PHP HTML

It’s important that your entire line code has the same charset to avoid issues where characters displays incorrectly. There are quite a few settings that needs to be properly defined and I’d strongly recommend UTF-8, as this has most letters you would need (Scandinavian, Greek, Arabic). Here’s a little list of things that has to … Read more

[Solved] Spring MVC Service class NullPointerException [closed]

It seems EmployeeDAO is not being injected in EmployeeServiceImpl, wire EmployeeDAO using @Autowire or @Inject, Second EmployeeDAOImpl has not been declared a component (not sure if you have declared already in xml) so declare it with @Repository and also @Autowire SessionFactory. Hope this will do.. 1 solved Spring MVC Service class NullPointerException [closed]

[Solved] Using $.ajax to get more values from php

Why dont you pass array with ajax? Like make an array in php code, and pass it in encoding form, eg. echo json_encode($arrResult); than in html form again parse it with parseJSON(). eg. of ajax call for your reference $.ajax({ type: “POST”, url: “phpfile.php”, }).done(function( msg ) { //alert(msg); msg = $.trim( msg ); if(msg … Read more