Posts

Showing posts from February, 2010

Implementation of hashing algorithm with arrays and c++ strings - Segmentation fault (core dumped) -

i'm getting "segmentation fault (core dumped)" error, when hash-function gives similar hash-values. both "hash" , "hash" functions should stay way are. "keyvalue" part of assignment, not exact implementation, numbers should upper case (hence "toupper" function) , start @ 1 (for example a=1, b=2 etc.). guess "hashinsert" 1 making problems, unfortunately couldn't figure out on own. (and should use arrays) #include <iostream> #include <string> using namespace std; /**********************/ int toupper( int ); int keyvalue( int ); int hash( int ); int hash( int ); int hashvalue( string, int ); void hashinsert( string[], string ); /**********************/ const int days = 7; string week[days]; int keyvalue( int ch ){ return toupper(ch) - 64; } int toupper( int ch ){ if( ch >= 92 && ch <= 122 ) return ch - 32; return ch; } int hash( int ch ){ return keyvalue( ch ) %

dnspython 1.11.1 EmptyLabel exception in python 2.7.6 -

i installed dnspython using "pip install dnspython". opened python shell , tried following code: import dns.resolver answers = dns.resolver.query('dnspython.org', 'mx') and getting following: traceback (most recent call last): file "<stdin>", line 1, in <module> file "dns/resolver.py", line 973, in query return get_default_resolver().query(qname, rdtype, rdclass, tcp, source, file "dns/resolver.py", line 961, in get_default_resolver default_resolver = resolver() file "dns/resolver.py", line 489, in __init__ self.read_resolv_conf(filename) file "dns/resolver.py", line 540, in read_resolv_conf self.search.append(dns.name.from_text(suffix)) file "dns/name.py", line 638, in from_text raise emptylabel dns.name.emptylabel i on osx mavericks using python 2.7.6, pip version 1.5.4, , dnspython version 1.11.1 it looks might have dns issues locall

javascript - jsonp with asmx error 500 -

when try works perfact function test() { debugger; $.ajax({ url: "http://testweb.com/myapi.asmx/getpersontest", type: "get", contenttype: "application/json; charset=utf-8", data: { userid: 1 }, datatype: "jsonp", success: function(json) { alert(json.userid + ' ' + json.firstname + ' ' + json.lastname); }, error: function() { alert("hit error fn!"); } }); } in same asmx, have method called below function post_test(){ var newurl = window.location.protocol + '//' + window.location.host + '/' + window.location.pathname; var user = document.getelementbyid('username').value; var email = document.getelementbyid('email').value; debugger; $.ajax({ url: "http://testweb.com/myapi.asmx/getperson", type: "get", contenttype: "application/json; charset=utf-8", data: json.stringify({ usern

Why getting 403 - Forbidden Error with ASP.NET MVC 4? -

Image
unable understand problem ? getting 403 error. within our server have 2 4 mvc site, few of them working .net target framework 4 (vs 2010) but getting 403 error of site running .net target framework 4.5 (vs 2013 ). when ever deploy new publish 403 error, when try access site. when reset user permission, site running couple of hours after few hours same 403 error. i tried aspnet_regiis -i . no luck. in web.config <modules runallmanagedmodulesforallrequests="true" /> user permission (iis_iusrs) have full access (adminstrator) have full access (application developer) have full access (system) have full access (user) have limited access authentication anonymous authentication : enabled forms authentication : enabled note: other disabled

Render SVG in C# Windows RT metro app -

is there way render string (containing svg) png using windows rt? know there libraries this , rely on gdi+ , seems work changing dependencies e. g. writablebitmapex. don't need clean solution , i'd happy rendering browser control displying svg, don't know if that's possible either. you may able use sharpvectors . can feed svg string in filesvgconverter can convert svg file corresponding xaml; can rendered on screen. according documentation there no gdi+ dependencies.

android - Determine if mobile user scanned QR code or typed URL in browser? -

is possible determine html 5 or javascript (or via method) whether user entered url mobile browser typing or scanned qr code opened url in browser? no, isn't possible. depending on whether have control on content of qr-codes, can use deeplink redirects original page (e.g. http://www.yoursite.com/qrcode redirecting http://www.yoursite.com ) , thereby "track" usage of qr-code.

javascript - How do I display randomly an array without click on the button? -

i'd have page button , when click button text should shown. text taken different arrays randomly javascript. works in project except 1 thing: on first load of page see no text button. how make 1 of arrays randomly chosen , displayed on fist page load (without click on button) <!doctype html> <html> <head> <script> function myfunction() { var quotes = [{ text: " <br> 1 <br><br> 2 <br><br> 3 ", }, { text: " <br> 4 <br><br> 5 <br><br> 6 ", }, { text: " <br> 7 <br><br> 8 <br><br> 9 ", }, ]; var quote1 = quotes[math.floor(math.random() * quotes.length)]; document.getelementbyid("quote1").innerhtml = '<p><font size="7"

python - Creating two separate registration forms in Web2py? -

so want create 2 registration forms side side. 1 users , other employees. index page have "click here if user" , "click here if employee". redirect appropriate registration page. want user registration how built in web2py registration is. employee registration want following fields: name 2. store name 3. store type 4. zip code i new web2py not sure how implement this. please tell me how should go creating registration.py model this? want index redirect these 2 links appropriate: [app]/user/register [app]/employee/register also controller file like? need separate controller user , employee? your question not quite clear. want show 2 forms side side or want redirect appropriate registration page? let's assume opt second option described in question. i'm assuming whatever reason, employees , users not same understood question. first create employee table in models: store_type = ['department store', 'discount store',

Many to many relationship on Mongodb based e-learning webapp? -

i relatively new no-sql databases. designing data structure e-learning web app. there x quantity of courses , y quantity of users. every user able take number of courses. every course compound of many sections (each section may video or quiz). i need keep track of every section user takes, think whole course should part of user set (for each user), so: { _id: "ed", name: "eduardo ibarra", courses: [ { name: "node js", progress: "100%", section: [ {name: "introdiction", passed:"100%", field3:"x", field4:""}, {name: "quiz 1", passed:"75%", questions:[...], field3:"x", field4:""}, ] }, { name: "mongodb", progress: "65%",

javascript - GM_xmlhttpRequest data is being placed in the wrong places -

Image
i using following excellent userscript (for chrome, chrome's tampermonkey , firefox greasemonkey). it's supposed display movie ratings next each imdb movie link, stopped working properly. this complete script: // ==userscript== // @name add imdb rating next imdb links (+voter count) // @author ali // @description adds movie ratings , number of voters imdb link. modified version of http://userscripts.org/scripts/show/9174 // @include * // @version 2013-05-12 // @namespace http://userscripts.org/scripts/show/96884 // @grant gm_xmlhttprequest // @downloadurl http://www.alibakir.com/upload/addimdbratings.js // @updateurl http://www.alibakir.com/upload/addimdbratings.js // ==/userscript== var imdbpluginlinks = document.links; var imdbcontinueelement=document.createelement("button"); imdbcontinueelement.innerhtml="get rating"; function processimdblinks(s){ imdbcontinueelement.style.display = &#

generate sql file with python (for mysql) -

i need write in txt file, sql statements values escaped can later import mysql database. some background info: created program in python reads csv file , inserts data remote mysql database. program except insert statements, performs several select statements in order collect information such primary keys, max ids etc. what need in general: since whole procedure time consuming hoping there way write statements in .sql file import mysql database via phpmyadmin. what tried , stuck: far can generate sql statements concatenating text. stuck point need escape characters. in sql server can include text between n'' , accept is.. there similar in mysql? example in sql server: n'my escaped text isn't affected single quote ->' or double quote " ' notice have surrounded text n''. thanks in advance! you're going want learn how use prepared statements. solve several problems you, including escaping characters , preventing sql in

authentication - Stop ApplicationDbContext creating a database -

is there way can stop in .net 4.5, mvc5 application applicationdbcontext creating authentication database me. i'm on shared hosting it's not option. right i'm quite happy have 2 database's running, 1 production , 1 authentication, sorting out later. need working on seo , put authentication database manually. i'm guessing mean re-writing code? public class applicationdbcontext : identitydbcontext<applicationuser> { public applicationdbcontext() : base("defaultconnection", throwifv1schema: false) { } public static applicationdbcontext create() { return new applicationdbcontext(); } } the site ready go bar issue, can done? got it! kind of tricked it, long use same database name wont try , re-create , it's working now. seo now!

java - Implementation of ArrayList using a LinkedList -

i need implement both queue , arraylist using internal linkedlist. created doublylinkedlist class , able implement queue no problem. problem running add or delete to/from arraylist, add/delete methods take in integer index , object/element. methods inside doublylinkedlist class take in either elements and/or nodes. my question this, how can implement doublylinkedlist methods inside arraylist when dll class doesn't take int values in. i want able add or delete node using index, can't. realistically, want list.addafter(i) without being integer. note: goal of assignment implement adts, can't modify method signatures of arraylist adt. doublylinedlist class public class doublylinkedlist<e> { private node<e> head; private node<e> tail; private int size; public doublylinkedlist() { this.head = new node<e>(null, null, null); this.tail = new node<e>(null, null, null); this.size = 0; head.setnext(tail); tail.setpr

xpath - XML Path needed -

i have following xml file: <?xml version="1.0" encoding="utf-8"?> <bookstore> <book category="cooking"> <title lang="en">everyday italian</title> <author>giada de laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="children"> <title lang="en">harry potter</title> <author>j k. rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="web"> <title lang="en">xquery kick start</title> <author>james mcgovern</author> <author>per bothner</author> <author>kurt cagle</author> <author>james linn</author> <author>vaidyanathan nagarajan</author> <year>2003</year> <price>49.99</price> </book>

c - Differences between scanf & scanf_s -

this question has answer here: difference between scanf , scanf_s 4 answers what's difference between scanf , scanf_s in c. i'm using visual studio 13 , keeps on giving me errors when try use scanf . both read formatted data standard input stream. ' _s ' microsoft's 'secure' versions. these versions of scanf, _scanf_l, wscanf, _wscanf_l have security enhancements , described in security features in crt : many old crt functions have newer, more secure versions. if secure function exists, older, less secure version marked deprecated , new version has _s ("secure") suffix . in context, "deprecated" means function's use not recommended; not indicate function scheduled removed crt. the secure functions not prevent or correct security errors; rather, catch errors when occur. p

performance - node.js concurrent connection limit -

i wrote trivial node.js client/server pair test local limits on concurrent connections. no data sent between them: 10.000 clients connect, , wait. each time run test, spawn server , 10 clients create 1000 connections each. it takes little on 2 seconds reach ~8000 concurrent connections. stops. no errors happen ( on 'error' callbacks don't fire, close doesn't fire either). connections "block", no result or timeout. i've raised max file descriptor limit ( ulimit -n ), , allowed more read/write memory consumed tcp stack via sysctl ( net.ipv4.tcp_rmem , wmem ). what's cap i'm hitting? how can lift it? -- edit -- server program, logging code stripped: clients = [] server = net.createserver() server.on 'connection', (socket) -> clients.push socket server.listen 5050 client (this runs n times): sockets = [] [1..num_sockets] socket = new net.socket sockets.push socket socket.connect 5050 these sy

javascript - Mandatory field is not working on texarea -

i have form , have fields, filling fields , passing form , decreasing spam written js codes make fields mandatory , disable submit button till filling fields, js works great input type=text not working texarea. js code <script type="text/javascript"> $(document).ready(function() { $(function() { $('#sbtbtn').attr('disabled', 'disabled'); }); $('input[type=text],input[type=textarea],input[type=password]').keyup(function() { if ($('#target1').val() !='' && $('#target2').val() != '' && $('#target3').val() != '' && $('#target4').val() != '' && $('#target5').val() != '' && $('#target6').val() != '' && $('#target7').val() != '' && $('#target8').val() != '' && $('#target9').val() != ''

SQL query returns no result from Java although it returns a result in Access -

when run query: select character tbl_unknown format(fw,'.###')='48.143' , code='0001' it returns result in access query interface when try run java doesn't return result. my table (tbl_unknown): char_id: autonumber value:1 fw: short text value:'48.1425' hint:after format become '48.143'. code: short text value:'0001' character: short text value: 'x' my java code: public static string getlostedcharacter(string font,string fw, string code) { connection conn = connectdb.getconnection(); string character = null; try { statement statement = conn.createstatement(); string query = "select character tbl_"+font+" format(fw,'.###')='"+fw+"' , code='" + code + "'"; resultset rs = statement.executequery(query); while (rs.next()) { character = rs.getstring(1); return ch

javascript - How can I set the http RequestHeader for a file load in the $script.js library? -

the $script.js library using https://github.com/ded/script.js/ has following javascript. need set request header in code block not sure how this: var el = doc.createelement("script"), loaded = false; el.onload = el.onreadystatechange = function () { if ((el.readystate && el.readystate !== "complete" && el.readystate !== "loaded") || loaded) { return false; } el.onload = el.onreadystatechange = null; loaded = true; // done! }; el.async = true; el.src = path; document.getelementsbytagname('head')[0].insertbefore(el, head.firstchild); here's example of similar (not part of $script.js) set request header: var xmlhttp = new xmlhttprequest(); xmlhttp.open("get", "/scripts/pages/home.js", false); xmlhttp.setrequestheader("x-custom-header", "my values"); xmlhttp.send(); var m = document.createelement('script'); m.appendchild(document.createtextnode(xmlhttp.res

hadoop - Oozie workflow xml error -

running oozie workflow include these lines:  <?xml version="1.0" encoding="utf-8"?> <workflow-app xmlns="uri:oozie:workflow:0.2" name="cs-wf-fork-join">     <start to="fork-node"/>     <fork name="fork-node">         <path start="my-node" />     </fork> i following error: error: e0701 : e0701: xml schema error, cvc-complex-type.2.3: element 'fork' cannot have character [children], because type's content type element-only. i'm using guide: http://www.thecloudavenue.com/2013/10/executing-oozie-workflow-with-pig-hive.html checking schema , seem need @ least 2 element in fork: <xs:complextype name="fork"> <xs:sequence> <xs:element name="path" type="workflow:fork_transition" minoccurs="2" maxoccurs="unbounded"/> </xs:sequence> <xs:attribute nam

debugging - Visual Studio 2013 only showing attach in debug menu -

i'm visual studio , programming noob please don't give me advanced programming lingo i'm not going able understand. earlier today programming in c++ (i started yesterday) , let grandfather use laptop @ traffic information. accidentally closed visual studio and/or clicked messed (don't think he's incompetent computers ad programming because he's been programming , managing systems commercially since late 60's/early 70's). when reopened vs continue programming didn't give me option debug, said "attach...". this first post i'm not allowed post pictures. https://www.dropbox.com/s/gepn6o9seal2veg/spinglespangle1.png please help. noobish. in visual studio need have solution (.sln) open build , debug against. have single file open, not solution containing it. should able find solution in file->recent projects , solutions menu.

c# - Ignore Mapping all zero properties, AutoMapper? -

i wanna ignore numeric properties 0 value in automapper configuration. so, i've written following extension method : public static imappingexpression<tsource, tdestination> ignorezeronumericproperties<tsource, tdestination>(this imappingexpression<tsource, tdestination> expression) { type sourcetype = typeof(tsource); type destinationtype = typeof(tdestination); list<propertyinfo> numericpropertis = sourcetype.getproperties().tolist(); foreach (propertyinfo propertyinfo in numericpropertis) { string sourcepropertyname = propertyinfo.name; type sourcepropertytype = propertyinfo.propertytype; if (!sourcepropertytype.isnumerictype()) continue; bool isthesamepropertyexistindestinationtype = destinationtype.getproperties().any(q => q.name == sourcepropertyname && q.propertytype == sourcepropertytype); if (!isthesamepropertyexistindestinationtype) continue; parameterexpressio

python - Black screen when trying to create a menu -

i have problem. have made menu game making python (it more of start screen). however, when run code, see windows titled appropriately, screen black. doing wrong? #importing libraries import pygame import sys import os windowwidth = 640 windowheight = 480 #colour r g b white = (255, 255, 255) black = ( 0, 0, 0) red = (255, 0, 0) green = ( 0, 255, 0) darkgreen = ( 0, 155, 0) darkgrey = ( 40, 40, 40) bgcolor = black displaysurf = pygame.display.set_mode((windowwidth, windowheight)) pygame.init() #drawing message def drawpresskeymsg(): presskeysurf = basicfont.render("press key play...", true, darkgrey) presskeyrect = presskeysurf.get_rect() presskeyrect.topleft = (windowwidth - 200, windowheight - 30) displaysurf.blit(presskeysurf, presskeyrect) #showing start screen def showstartscreen(): titlefont = pygame.font.font(none, 100) titlemain = titlefont.render('badger defense', true, white,

Python interpreting equal values as non-equal -

for part of code, inside for loop s = 'cl_num = %d, prev_cl_num = %d\n' % (cl_num, prev_cl_num); fd.write( s ); if cl_num != prev_cl_num: bb.instructions[i].is_cache_miss = 1; s = 'instruction %x cache miss, cl_num = %d, prev_cl_num = %d, base_cache_line = %d\n' % (bb.instructions[i].address, cl_num, prev_cl_num, base_cache_line); fd.write( s ); bb.instructions[i].cache_line = cl_num - base_cache_line; prev_cl_num = cl_num; i output, in fd file, cl_num = 65557, prev_cl_num = 65557 instruction 400558 cache miss, cl_num = 65557, prev_cl_num = 65557, base_cache_line = 65557 cl_num = 65557, prev_cl_num = 65557 instruction 400560 cache miss, cl_num = 65557, prev_cl_num = 65557, base_cache_line = 65557 cl_num = 65557, prev_cl_num = 65557 instruction 400568 cache miss, cl_num = 65557, prev_cl_num = 65557, base_cache_line = 65557 cl_num = 65557, prev_cl_num = 65557 instruction 400570 cache miss, cl_num = 65557, prev_cl_num = 65557, base_cache_line

mysql multi join from same table give alias -

currently have following query select * tabs join users d on tabs.`debit` = d.id join users c on tabs.`credit` = c.id as table contains 2 user objects names returned same so: id | amount | type | id | username | avatar | id | username | avatar i need return following id | amount | type | debit.id | debit.username | debit.avatar | credit.id | credit.username | credit.avatar or simmilar long column names users prefixed. i think looking for. give try. (assuming id | amount | type belongs tabs table) select t.id, t.amount, t.type, d.id 'debit.id', d.username 'debit.username', d.avatar 'debit.avatar', c.id 'credit.id', c.username 'credit.username', c.avatar 'credit.avatar', tabs t join users d on t.`debit` = d.id join users c on t.`credit` = c.id

c# - How to retrieve value from nested struct -

i creating application retrieve data facebook page using fql. fql query is: select id, text, attachment.media.image.src comment post_id in (select post_id stream source_id = "mypageid" , actor_id = "mypageid" limit 100) i got value id , text using way: public class mycomments { public string id { get; set; } // comment id public string text { get; set; } // comment } list<mycomments> q = jsonconvert.deserializeobject<list<mycomments>> (results.data.tostring()); if (q.count != 0) { post_id = q[0].id.tostring(); post_text = q[0].text.tostring(); } but how value src, because struct in struct attachment > in struct media > in struct image > string src. is there possible way value string src? in c# code? please guys, in advance. i haven't played fql, json easy enough deal with. the first thing examine json object returned fq

actionscript 3 - Type Coercion Failed in Action Script 3, getting element from an array -

i'm getting error when i'm getting element array , trying use functions on it: typeerror: error #1034: type coercion failed: cannot convert jogador$ jogador. @ laser/mover_tiro_baixo() sorry it's in portuguese, code i'll paste below, think it: when retrieve element array it's of type 'jogador$', , if try use being of 'jogador' doesn't work. i'm trying manually force coercion, trying convert object displayobject (because i'm trying use hit test function), didn't work: typeerror: error #1034: type coercion failed: cannot convert jogador$ flash.display.displayobject. @ laser/mover_tiro_baixo() code: package { import flash.display.movieclip; import flash.display.stage; import flash.events.event; import flash.debugger.enterdebugger; import flash.utils.getdefinitionbyname; import flash.utils.getqualifiedclassname; import flash.display.displayobject; public class laser extends

Python TypeError: 'float' object has no attribute '__getitem__' -

anybody knows how solve problem? i'm studying collective intelligence now, , compared example when made code. it's getting error this: traceback (most recent call last): file "<pyshell#8>", line 1, in <module> clust=clusters.hcluster(data) file "d:\kuliah\smt1\phyton class\contoh coding\coding-collective intelligence\myself_maulida\bab3-documentclustering\clusters.py", line 78, in hcluster in range(len(clust[0].vec))] typeerror: 'float' object has no attribute '__getitem__' here code, can help? thank you. def hcluster(rows,distance=pearson): distances={} currentclustid=-1 #clusters rows clust=[bicluster(rows[i],id=i) in range(len(rows))] while len(clust)>1: lowestpair=(0.1) closest=distance(clust[0].vec,clust[1].vec) #loop through every pair looking smallest distance in range(len(clust)): j in range(i+1,len(clust)): #distance

c# - How to include .net framework 4.5.1 in VS 2013 -

i want create installer windows application, , include .net framework installation (i have selected * download same site application). in compilation of setup project error, saying there no framework installation exists. how fix it? in flowing microsoft post can find have install: • .net framework 4.5.1 • visual studio 2013 ( sdks , targeting packs ) 4.5.1 required part of vs2013, without can't run vs2013. if have installed vs2013, have installed 4.5.1. create msi installers need add extension: visual-studio-installer-projects-extension

jsf - Pass h:inputText value to f:ajax listener -

this question has answer here: how pass parameter f:ajax in h:inputtext? f:param not work 1 answer i trying create sql data table can edited , displayed on single page. using jsf , named bean. use arraylist bean object store , display data. public list<regionbean> getregions()throws sqlexception{ the data displayed in inputtext element. when try update information using sql method in backing bean fails add updated text sql data base. put same value displayed. want have input text box display data values array list , store them in different field in bean after have been edited. here code now. <h:datatable value="#{regionbean.regions}" var="regions"/> <h:column> <f:facet name="header">region id</f:facet> #{regions.regionid} </h:column> <h:column> <f

Neo4j https communication -

is there way allow https, instead of http, communication neo4j server? also, channel neo4j shell's communication use, http or https? this neo4j documentation: https support the neo4j server includes built in support ssl encrypted communication on https. first time server starts, automatically generates self-signed ssl certificate , private key. because certificate self signed, not safe rely on production use, instead, should provide own key , certificate server use. to provide own key , certificate, replace generated key , certificate, or change neo4j-server.properties file set location of certificate , key: # certificate location (auto generated if file not exist) org.neo4j.server.webserver.https.cert.location=ssl/snakeoil.cert # private key location (auto generated if file not exist) org.neo4j.server.webserver.https.key.location=ssl/snakeoil.key note key should unencrypted. make sure set correct permissions on private key, neo4j server user can read/write

c# - Application Bar icons appearing as white even if the icons are colored in Windows phone app? -

Image
actual intended result but appearing in emulator this icon image asset using am adding application bar icon in c# this: public void setappbar() { if (applicationbar == null) { applicationbar = new applicationbar(); applicationbar.mode = applicationbarmode.default; } this.applicationbar.buttons.clear(); applicationbariconbutton applicationbariconbutton = new applicationbariconbutton(); applicationbariconbutton.text = "play all"; applicationbariconbutton.iconuri = new uri("images/play_off.png", urikind.relative); applicationbariconbutton.click += appbarbutton_click_1; this.applicationbar.buttons.add(applicationbariconbutton); applicationbar.isvisible = true; } i have read best practices bottom app bar icons here of dont have access icon white forgeround on transparent background. icon have, there way can intended green color in app ba

Sessions in PHP 5.3.3 and kirby -

Image
situation i have implemented modified version of kirby auth plugin on client website, works way user accounts simple kirby content files title serving login , password field containing bcrypt encrypted version of users password on website, visitors can click on "customer area", goes template managed modified auth plugin (which redirects "login" form). the website multilingual. accounts file content/extranet/login/login.fr.txt or example content/extranet/bastian/bastian.fr.txt , modified auth plugin looking for, finds file , reads it, checks password, , logins users. this system requires account pages title same url, , invisible pages user logged in , can see in « secure » template files present in folder this works here on local mamp server can see in screenshots, on production server http://www.driving-evolution.com , doesn’t work, , don’t know why, have looked in lot of places , don’t understand going on. (it doesn’t work on staging server either)

ruby - how to set "data-" of rails f.select -

i use rails 4. <%= f.select :industry_id, options_from_collection_for_select([], "id", "name"), 'data-option-dependent' => true, 'data-option-observed' => 'pre_industry_id', 'data-option-url' => '/industries/:pre_industy_id:/sub_industry.json', 'data-option-key-method' => :id, 'data-option_value-method' => :name %> but... in result, data-attributes don't appear. <select id="review_industry_id" name="review[industry_id]"></select> pass data hash option select 's html_options argument: <%= f.select :industry_id, options_from_collection_for_select([], "id", "name"), {}, data: { 'option-dependent' => true, 'option-observed' => 'pre_industry_id', 'option-url' => '/industries/:

Bash: Keeping indentation during interpolation -

i have variable containing multiline string. i going interpolate variable multiline echoed string, echoed string has indentation. here's example: ip_status=`ip -o addr | awk 'begin { printf "%-12s %-12s %-12s\n", "interface", "protocol", "address" printf "%-12s %-12s %-12s\n", "---------", "--------", "-------" } { printf "%-12s %-12s %-12s\n", $2, $3, $4 }'` echo -e " -> $ip_status -> " when running that, first line of $ip_status left justified against -> , subsequent lines not justified against -> . it's easier see if run in bash. output: -> interface protocol address --------- -------- ------- lo inet 127.0.0.1/8 lo inet6 ::1/128 eth0 inet 10.0.2.15/24 eth0 inet6 fe

android - Get MAC address in mobile devices? -

i need retrieve available mac addresses available in current mobile device, , if possible active network card ip address. how can active network card mac , ip address in delphi xe5 / xe6 ? following @wholegrain's answer , info link posted @user3631728 how can programmatically mac address of iphone : "in ios 7 , later, if ask mac address of ios device, system returns value 02:00:00:00:00:00. if need identify device, use identifierforvendor property of uidevice instead. (apps need identifier own advertising purposes should consider using advertisingidentifier property of asidentifiermanager instead.)" if this suffice, can ios: uses {$ifdef ios} iosapi.uikit; {$endif} procedure tform1.button2click(sender: tobject); var {$ifdef ios} device : uidevice; {$endif} begin {$ifdef ios} device := tuidevice.wrap(tuidevice.occlass.currentdevice); showmessage(device.uniqueidentifier.utf8string); showmessage(device.id

Android gridview : Trying to reproduce interface + lags -

Image
i have 2 problems : i trying reproduce interface (see below) my gridview lag much i reproduce interface : each item has random height of imageview. today here result : what best way create gridview ? here code of adapter : import java.util.arraylist; import java.util.list; import java.util.random; import android.app.activity; import android.graphics.typeface; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.imageview; import android.widget.textview; import com.nostra13.universalimageloader.core.displayimageoptions; import com.nostra13.universalimageloader.core.imageloader; import com.nostra13.universalimageloader.core.imageloaderconfiguration; public class allannonces_custom_adapter extends arrayadapter<annonce> { typeface robotolight = typeface.createfromasset(getcontext().getassets(), "fonts/roboto-light.ttf"); typeface robotobold =