Posts

java - lwjgl freezes on creation of Font object -

i making simple game of snake, because can, , stumbled across interesting bug. trying use slick-util draw text on screen, whenever try create font object game freezes. here code. highlighted section prints 'a' once. package tlf.snake.main; import tlf.snake.main.game.helper.pos; import tlf.snake.main.game.input.input; import java.awt.font; import java.nio.bytebuffer; import java.nio.intbuffer; import org.lwjgl.bufferutils; import org.lwjgl.glfw.glfwwindowposcallback; import org.lwjgl.glfw.glfwwindowsizecallback; import org.lwjgl.glfw.glfwvidmode; import org.lwjgl.opengl.glcontext; import org.newdawn.slick.truetypefont; import static org.lwjgl.glfw.callbacks.glfwsetcallback; import static org.lwjgl.glfw.glfw.*; import static org.lwjgl.opengl.gl11.*; import static org.lwjgl.system.memoryutil.null; /** * @author thislooksfun */ public class snakegame { private static final game game = new game(); private int width = game.gamewidth*15; private int heigh...

java - utf-8 is not working when i am attaching file name using mimeMessageHelper using webLogic -

it's working on tomcat not working on weblogic body can , when trying decode information not getting proper output file name not getting proper output when attaching file name mimemessage message = mailsender.createmimemessage(); mimemessagehelper mh = new mimemessagehelper(message, true, "utf-8"); multipart multipart = new mimemultipart(); mimebodypart messagebodypart1 = new mimebodypart(); mh.setto(to); mh.setfrom(from); mh.setsubject(subject); mh.settext(content, true); string attachmentname = "cây chàm sự kiện.pdf"; if (!stringutils.isempty(attachmentname) && attachmentdata != null) { when coverting string utf - 8 not getting propet when printing value getting proper output attachment file name not getting mh.addattachment(attachmentname, new bytearrayresource(attachmentdata)); } mailsender.send(message);

Read words/phrases from a file, make distinct, and write out to another file, in Java -

i have text file word or phrase on each line. how i: read phrases memory, make distinct (eliminate duplicates), sort alphabetically, write results out file? stackoverflow has answers similar questions in other languages such c , php , python, prolog , , vb6 . cannot find 1 java. you can leverage: nio (non-blocking i/o) api (available since java 7) streams api (available since java 8) …to solve problem elegantly: public static void main(string... args) { path input = paths.get("/users/youruser/yourinputfile.txt"); path output = paths.get("/users/youruser/youroutputfile.txt"); try { list<string> words = getdistinctsortedwords(input); files.write(output, words, utf_8); } catch (ioexception e) { //log error and/or warn user } } private static list<string> getdistinctsortedwords(path path) throws ioexception { try(stream<string> lines = files.lines(path, utf_8)) { return lines.map(string::trim...

windows - Undefined subroutine &UUID::generate called at -

i encountering problem following perl script else wrote generate uuid , print stdout. has misconfigured perl setup on windows 7 machine activestate's perl http://downloads.activestate.com/activeperl/releases/5.20.2.2001/activeperl-5.20.2.2001-mswin32-x86-64int-298913.msi . have data::uuid perl module versiion 1.220 installed. #!/usr/bin/perl use uuid; uuid::generate($uuid); uuid::unparse($uuid, $string); print $string . "\n" when script in dos shell run no arguments following error: undefined subroutine &uuid::generate called @ xxx any advice on how debug this?

How can make the width of string the same in Android? -

Image
there 3 strings, each length of string same, there spaces in strings. after fill 3 strings in listview control, find width of 3 row isn't same. how can make width of string same in android? thanks! btw, use android studio. min api 9. string1= "a b" string2= "aa b" string3= "aaa b" listview lv=(listview)findviewbyid(r.id.listview); string[] countries=new string[]{"a b","aa b","aaa b"}; lv.setadapter(new arrayadapter<string>(this, android.r.layout.simple_list_item_1, countries)); unless you're using monospaced font, achieving wanted going quite difficult. non-monospaced fonts has different width each of characters posses. however, there's workaround using layout arrangement. here's example: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orient...

ruby - Rails model relation MissingAttributeError -

i have models in application, , i'm trying save data got error: activemodel::missingattributeerror (can't write unknown attribute product_id ): app/controllers/admin_controller.rb:27:in `create_product' i have 3 models category model class category < activerecord::base has_many :features has_many :products end migration: class createcategories < activerecord::migration def change create_table :categories |t| t.string :name, null: false t.boolean :active, null: false, default: false t.timestamps null: false end end feature model class feature < activerecord::base has_and_belongs_to_many :categories has_and_belongs_to_many :products end migration class createfeatures < activerecord::migration def change create_table :features |t| t.belongs_to :category, index:true t.string :name, null: false t.timestamps null: false end end product model class product < acti...

python - Does Wokkel (XMPP Library) support following features? -

i want develop xmpp protocol implement rpc communication following features. 1.security authentication between client , server. 2.support null values(send null values server) 3.can able send arbitrary values(xml-rpc support 32 bits) 4.can send method arguments custom.(for eg sum(default,4,default) default values chosen server ) 5.return error if, should arbitrary object i know whether wokkel library support these features or know other libraries support these features.(eg:sleekxmpp or xmpppy) this question seems have 2 parts: 1) there existing xmpp extension protocol supports listed feature? 2) wokkel (or possibly other python xmpp libraries) support this? the xmpp extention protocols generic rpc behaviour xep-0009 (jabber-rpc) , xep-0050 (commands) . xep-0009 uses xml-rpc payloads sent on xmpp. mention xml-rpc doesn't fit use case. xep-0050 uses xep-0004 data forms perform predefined command exchanges server. don't think fits requirements #2,...