Posts

Showing posts from March, 2014

java - How to fire an ActionEvent from a JPanel -

i'm trying repaint simple massage in panel firing actionevent. i have messagepanel extends jpanel , in defined addactionlistener method , processevent method process event: import java.awt.graphics; import javax.swing.jpanel; import java.util.*; import java.awt.event.*; public class messagepanel extends jpanel { private string message = new date().tostring(); arraylist<actionlistener> actionlistenerlist; public messagepanel(string message) { this.message = message; } public void setmessage(string message){ this.message = message; } public void addactionlistener(actionlistener listener) { if (actionlistenerlist == null) { actionlistenerlist = new arraylist<>(2); } if (!actionlistenerlist.contains(listener)) { actionlistenerlist.add(listener); } } public void removeactionlistener(actionlistener listener) { if (actionlistenerlist != null &

c# - Deserialize the content of one of the template to check if it is in valid XML format -

i want deserialize content of 1 of template check if in valid xml format.can 1 give me sample code this? you can use validate sample : using system; using system.collections; using system.data; using system.io; using system.xml; using system.xml.schema; using system.text; public class xmlvalidator { // validation error count static int errorscount = 0; // validation error message static string errormessage = ""; public static void validationhandler(object sender, validationeventargs args) { errormessage = errormessage + args.message + "\r\n"; errorscount ++; } public void validate(string strxmldoc) { try { // declare local objects xmltextreader tr = null; xmlschemacollection xsc = null; xmlvalidatingreader vr = null; // text reader object tr = new

svn - I can't specify the location of Subversion repository in Netbeans -

in tools>options>miscellaneous>versioning>subversion, can't type repository url under "manage connection settings..." shows me blank drop-down menu when click on input field. also, if select "svnkit" under "preferred client", doesn't configure way, click ok when come options menu, "cli" marked , can't use because it's deprecated, according netbeans website ( http://wiki.netbeans.org/faqsubversionclients ). when try use checkout, get: netbeans subversion support required subversion client! install subversion commandline client 1. download , install subversion 1.5 or later (http://collabnet.net/netbeans). 2. add path. test installation running 'svn --version' command line 3. restart ide i've specified c:\program files\tortoisesvn\bin under path environment variable still get 'svn' not recognized internal or external command, operable program or batch file. i'm running tortoise 1.8.3

web - javascript: program get stuck -

i'm learing javascript on codecademy . following program got stuck when submitted it. new can not find bug. downloaded aptana studio don't know how debug:(. there way trace code? in advance. var slaying = true; var youhit = math.random() > 0.5; var damagethisround = math.floor(5 * math.random()); var totaldamage = 0; while (slaying) { if (youhit) { console.log("you hit dragon."); totaldamage += damagethisround; if (totaldamage >= 4) { console.log("you've stew dragon!"); slaying = false; } else { youhit = math.random() > 0.5; } } else { console.log("the dragon defeated you.") } } as per understanding. need set slaying = false in else section, otherwise program thrown infinite loop. } else { slaying = false; //added here - breaks while() condition console.log("the dragon defeated you.") } simple, when t

How to implement a default view in CakePHP? -

in cakephp each method of controller has own view , view template file name of method. class datacontroller extends appcontroller { public function one() { // render one.ctp } public function two() { // render two.ctp } } accourding api documentation there $view property of controller specifies view render. should have ability specify default view file, all.ctp , methods of controller class datacontroller extends appcontroller { public $view = 'all'; public function one() { // should render all.ctp } public function two() { // should render all.ctp } } however not work , cakephp ignores $view property , continues template file of same name method. is there way have default view without having insert $this->render('all'); in each of controller's methods? the value going overridden in controller::setrequest() being called in controllers class constructor . you use controllers beforefilter()

objective c - Do two steps - one by one -

i can't figure out how this: i have imageview , clicking the button i'd in imageview shown: first image, wait few seconds , while loop find second image (by following instructions in while loop many other images), , show chosen (second) image. i'm not sure i've described issue clear here sample code: - (ibaction)button:(id)sender { i=0; uiimage *img = [uiimage imagenamed:@"image1.png"]; [first setimage:img]; /*some code sets time image1 stay shown*/ while (i<some_variable) { /*blah blah blah*/ if (something) {uiimage *img = [uiimage imagenamed:@"image2.png"]; [first setimage:img];} if (something else) {uiimage *img = [uiimage imagenamed:@"image3.png"]; [first setimage:img];} ... /*code code code*/ i++; } } this 1 hasn't solve problem: [nsthread sleepfortimeinterval:1.0]; it wait's blank process code , show chosen image. this should basic ,

matrix - Generate lattice paths in R -

for example, if have lattice looks this: 133.1 / 121 / \ 110 108.9 / \ / 100 99 \ / \ 90 89.1 \ / 81 \ 72.9 where lattice starts @ 100 , either goes factor 1.1 , goes down factor 0.9. lattice has 3 periods in goes or down. clear matrix filled in more periods. the lattice in matrix form looks this: [,1] [,2] [,3] [,4] [1,] 100 110 121 133.1 [2,] na 90 99 108.9 [3,] na na 81 89.1 [4,] na na na 72.9 i'm working in r. code generate lattice matrix follows: #parameters s0 <- 100 #price @ t0 u <- 1.1 #up factor d <- 0.9 #down factor n <- 3 #number of periods #matrix prices prices <- matrix(data=na, nrow=(n+1), ncol=(n+1)) prices[1,1] <- s0 #fill matrix for(column in 2:(n+1)){ for(row in 1:(column-1)){ prices[row,column] <- u*prices[row,column-1]; } prices[column,column] <- d*prices[column-1,column-1]; } i create

javascript - Yeoman (bower,grunt) - 'SockJS' is not defined -

i trying manage javascript frontend application yeoman. don't have yeoman experience. while running grunt command getting error: running "jshint:all" (jshint) task linting app/scripts/services/stopmoversockjs.js ...error [l7:c26] w117: 'sockjs' not defined. var socket = new sockjs(url); i have defined sock js dependency in bower.json : { "name": "web", "version": "0.0.0", "dependencies": { "sockjs": "~0.3.4", "angular": "~1.0.7", ... and bower install command runs without problems , downloads dependencies including sockjs. this file grunt command complains : 'use strict'; angular.module('webapp').factory('sockjshelper', function($rootscope) { function handler(url) { var socket = new sockjs(url); //it complains line .... what have in order make sockjs recognized? jshint thinks sockjs un

javascript - Remove symbols by RegExp -

i need remove next symbols : \ / . ? : and tried use next regexp : var nouse = new regexp("\/|\\|\:|\?","g"); ... var name = fullname.replace(nouse,"g"); ... but falls error : syntaxerror: invalid regular expression: `//|\|:|?/:` nothing repeat how can change regexp? in regexp constructor, have double escape backslashes: new regexp("/|\\\\|:|\\?|\\.","g"); and backslash has escaped. oh , didn't have period in regex. otherwise, can use character class: new regexp("[/\\\\:?.]","g"); or use construct: var nouse = /[\/\\:?.]/g;

mysql - Sort query results alphabetically, but exclude "the" in sorting? -

let's have laravel 4 application. let's have populated movies table. this: $movies = movie::orderby('title', 'asc')->get(); returns this: braveheart silent hill big lebowski waterworld what i'd though, ignore "the" in sort return this: the big lewbowski braveheart silent hill waterworld is there inside laravel make easy? how approach this? need write custom sql query? thanks! i not know laravel, query may want: select title movies order case when substring(title 1 4) = 'the ' substring(title,5) else title end desc the other answer referring replace function might enough, note replace replace occurrences of target string (for example "gone wind" changed.

c++ - Simple Pointer Array Equality Explanation Needed -

just going bit of c++ programming uni , remembered why thought pointer business crazy. give me quick explanation whats happening here? possible int 20 in main function? #include <stdio.h> void test(int *b) { b[0] = 10; b[1] = 20; printf("\n %i \n ", b[1]); // prints 20 } int main( int argc, char* argv[] ) { int a; test(&a); printf("%i \n", a); //prints 10 // printf("%i \n", a[1]); // doesn't compile - why not 20? return 0; } edit: sorry simple question such burden users deal , thank users did take , inform me undefined behavior. reason asked question code found couldn't work out how use. did not pull out of air. here if interested. @ glhunprojectf function , last argument how meant use it. http://www.opengl.org/wiki/gluproject_and_gluunproject_code honestly, i'm sort of surprised lets assign value b[1]. guess if took out part not compile, segfault when try assign 20 b[1], beca

Python - Understaning CSV Module and line_num object -

in code, able print line number if error found during processing (called in piece of code), i'm having trouble doing using line_num object. here code .csv 4 rows long: with open(infile, 'u') infh: csvreader = csv.reader(infh, delimiter = ',') header = csvreader.__next__() linenum = csvreader.line_num row in csvreader: print(linenum) when execute code, see in console: 1 1 1 1 my expectation see: 1 2 3 4 it looks code printing index , not line number... linenum not changed after first assignment. printing inside loop print same value repeatedly. why don't print csvreader.line_num follow? for row in csvreader: print(csvreader.line_num)

FLEX AIR scroll to the bottom of an HTML component -

i building chatroom using mx:html component. usually, able make textarea scroll last entry automatically using : chattext.verticalscrollposition = chattext.maxverticalscrollposition but, when using html component, using code above nothing , not throw out error, im missing ? is there way without using canvas ? thanks !

c# - Approve / reject through dropdownlist -

previously tried approve / reject through button , try code it.. this code when add buttons of approve / reject protected void grdfileapprove_rowcommand(object sender, gridviewcommandeventargs e) { if (e.commandname == "_approve") { //using (sqlconnection con = dataaccess.getconnected()) using (sqlconnection con = new sqlconnection(configurationmanager.connectionstrings ["mydms"].connectionstring)) { try { con.open(); int rowindex = convert.toint32(e.commandargument); gridviewrow row = (gridviewrow) ((control)e.commandsource).namingcontainer; button prove_button = (button)row.findcontrol("btnapprove"); sqlcommand cmd = new sqlcommand("approveee", con); //cmd.commandtype = commandtype.storedp

javascript - Display image as popup on page load -

i learning php , totally unfamiliar javascript. want know how generate popup having text , image.(if html formatting allowed, fine me) i want generate popup message each time page loads, here www.000webhost.com, each time open/refresh home page of 000webhost.com image displayed. how can ? i recommend using 1 of lightbox plugins simple , easy use , require minimal javascript or jquery knowledge.

objective c - Reactive NSMutableDictionary? -

how subscribe objects being added , removed nsmutabledictionary using reactivecocoa? also, i'd broadcast notification when changes. guess broadcasting can done using racmulticastconnection how tie dictionary change? i'm trying use reactivecocoa first time in project , stuck on first thing wanted :( racobserve wrapper around key-value observing , , inherits same features , flaws. unfortunately, nsmutabledictionary not automatically observable. there 2 ways work around that: subclass , add kvo support . create real model object, properties instead of dictionary keys. you'll kvo on properties, long use setters instead of direct ivar modification. i'm not sure mean "[broadcasting] notification when changes," or why it'd valuable. notifications way global taste, , i'd promote using more limited observation instead (like kvo). however, assuming want this, it's simple enough post notification in response new signal value: @weak

c++ - Utf-8 to URI percent encoding -

Image
i'm trying convert unicode code points percent encoded utf-8 code units. the unicode -> utf-8 conversion seems working correctly shown testing hindi , chinese characters show correctly in notepad++ utf-8 encoding, , can translated properly. i thought percent encoding simple adding '%' in front of each utf-8 code unit, doesn't quite work. rather expected %e5%84%a3 , i'm seeing %xe5%x84%xa3 (for unicode u+5123). what doing wrong? added code (note utf8.h belongs utf8-cpp library). #include <fstream> #include <iostream> #include <vector> #include "utf8.h" std::string unicode_to_utf8_units(int32_t unicode) { unsigned char u[5] = {0,0,0,0,0}; unsigned char *iter = u, *limit = utf8::append(unicode, u); std::string s; (; iter != limit; ++iter) { s.push_back(*iter); } return s; } int main() { std::ofstream ofs("test.txt", std::ios_base::out); if (!ofs.good()) { std::co

Android studio Gradle :: dependencies {compile 'com.android.support:appcompat-v7:18.0.0' } fails compilation -

Image
i switched android studio development. had created project minsdk,targetsdk , compile sdk google api level 8. the project compilation fails due following code in build.gradle file. dependencies { compile 'com.android.support:appcompat-v7:18.0.0' } can tell why hapenning? my whole build.gradle posted below. buildscript { repositories { mavencentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android' repositories { mavencentral() } android { compilesdkversion 8 buildtoolsversion "18.1.0" defaultconfig { minsdkversion 8 targetsdkversion 8 } } dependencies { compile 'com.android.support:appcompat-v7:18.0.0' } below screenshot you can't compile against api below 11 , use appcompat library. references holo style , compiler have no way resolve symbols if you're building against old versio

Unsolved MATTER with data core in iOS iPhone App -

i tried best solve problem keep getting following error: -[__nscfconstantstring ling]: unrecognized selector sent instance 0x12f80b0 what trying add line core data , table view text alertview, fire alertview , user put name of new language, text in alertview saved core data , added table view when user click save. in table view, relevant code: - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; if(cell == nil){ cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } languages *languagesdict = (languages *)[languagesarray objectatindex:indexpath.row]; cell.textlabel.text = [languagesdict ling]; return cell; } and in alertview code when "save" button clicked:

oauth - Which SSO tool fits this scenario best? -

clientsitea.com, clientsiteb.com, .... (client domains unknown us) ourserver.com (contains user credentials) we need users able login on ourserver.com (using javascript) on client site. login form must reside on client sites. envisioning ajax call sent ourserver.com containing username (from client site). if username logged in, let them stuff, if not show them login form. login form send username/password server , log them in. is possible? i've been reading saml, i'm seeing having login form on client sites problem. i've been reading oauth. i'm pretty lost. can give me guidance. i don't think easier have same ui repeated on multiple sites, makes maintenance more difficult. on other hand, if there explicit link users login or automatically redirected when accessing restricted sites there no need awkward requirement. awkward - because makes tricky use existing sso protocols. answering question - oauth2 lets exchange username/passwords access t

python - Plotting a histogram from pre-counted data in Matplotlib -

i'd use matplotlib plot histogram on data that's been pre-counted. example, have raw data data = [1, 2, 2, 3, 4, 5, 5, 5, 5, 6, 10] given data, can use pylab.hist(data, bins=[...]) to plot histogram. in case, data has been pre-counted , represented dictionary: counted_data = {1: 1, 2: 2, 3: 1, 4: 1, 5: 4, 6: 1, 10: 1} ideally, i'd pass pre-counted data histogram function lets me control bin widths, plot range, etc, if had passed raw data. workaround, i'm expanding counts raw data: data = list(chain.from_iterable(repeat(value, count) (value, count) in counted_data.iteritems())) this inefficient when counted_data contains counts millions of data points. is there easier way use matplotlib produce histogram pre-counted data? alternatively, if it's easiest bar-plot data that's been pre-binned, there convenience method "roll-up" per-item counts binned counts? you can use weights keyword argument np.histgram (whic

c# - GeoCoordinateWatcher on different phones -

i'm using standard way of using class , strange thing on phones works (nokia lumia 920, htc, etc) , on doesn't (lumia 610, samsung omnia 7w). geocoordinatewatcher watcher = new geocoordinatewatcher(geopositionaccuracy.high); watcher.movementthreshold = 0.1; watcher.statuschanged += (x, y) => { messagebox.show(y.status.tostring()); }; watcher.positionchanged += watcher_positionchanged; watcher.start(); what i'm getting here on phones gcw initializes, i'm getting nodata on lumia 610 , samsung. what problem? maybe answer someone: be sure if phone doesn't give gps reading, stick in sim card, can location it. apparently lumia 610 , samsung omnia 7w don't have built in gps or something... :)

yii - Tabular Input In Create Action -

i have followed tutorial http://www.yiiframework.com/doc/guide/1.1/en/form.table tabular input got stuck. everything works fine except filling inputs. when fill fields , do $model->attributes=$_post['racingtable']; it doesn't pick of entries , when user doesn't fill , suppose show error remove entries inputs. but when this $model->attributes=$_post['racingtable'][0]; it takes entries first group of input fields , fill other groups entries. i'm not talking saving database. i'm talking when user wrong takes him create action , should fill inputs user's entries. post complete controller/action code can better picture. now, guessing not validating model before trying save. , tabular input array hence not able value doing $_post['racingtable']; have define index of array too. that's reason when defining index [0] in second line of code it's taking first set of values. should run loop , try values defining

Python: Converting ANSI color codes to HTML -

i have program reads minecraft console output, , puts in qt text edit field (irrelevant). however, minecraft consoles use ansi color codes ( [0;32;1m ) output colors, , i'd them in html format (since qt text edit fields read that). i've researched bit , found bunch of solutions require style sheets, not want. want simple <span style="color: green"></span> or similar, inline. can me achieve this? import re color_dict = { '31': [(255, 0, 0), (128, 0, 0)], '32': [(0, 255, 0), (0, 128, 0)], '33': [(255, 255, 0), (128, 128, 0)], '34': [(0, 0, 255), (0, 0, 128)], '35': [(255, 0, 255), (128, 0, 128)], '36': [(0, 255, 255), (0, 128, 128)], } color_regex = re.compile(r'\[(?p<arg_1>\d+)(;(?p<arg_2>\d+)(;(?p<arg_3>\d+))?)?m') bold_template = '<span style="color: rgb{}; font-weight: bolder">' light_template = '<span styl

c# - Move/Rename a file using FtpWebRequest -

i trying moving file 1 folder using ftpwebrequest keep getting error 550. code; var requestmove = (ftpwebrequest)webrequest.create(helper.pathftp + helper.newfolder + file); requestmove.method = webrequestmethods.ftp.rename; requestmove.credentials = networkcredential; requestmove.renameto = "../" + helper.oldfolder + file; requestmove.getresponse(); i can list, upload, download , delete files moving/renaming hopeless. have read several posts both on stackoverflow , other sites , have tried things setting proxy null , adding special characters paths cant find solution works. the path use in webrequest.create correct can delete must renameto got issue with. ideas? error 550 means access denied. if ftp user has sufficient rights, program (e.g. antivirus, windows thumbnail generator etc) have file opened , deny move request. you need contact server administrator around problem.

jquery - Change text of option value with image -

i need change text images in option value. html code this: <select id="topics" class="taxonomies-filter-widget-input" name="topics"> <option value="0">todas</option> <option class="level-0" value="unaestrella">una estrella</option> <option class="level-0" value="dosestrellas">dos estrellas</option> <option class="level-0" value="tresestrellas">tres estrellas</option> <option class="level-0" value="cuatroestrellas">cuatro estrellas</option> <option class="level-0" value="cincoestrellas">cinco estrellas</option> </select> i change "una estrella" image " http://www.domain.com/images/unaestrella.png " example. possible? thanks! no not . becuase option element can have text . can change tex jquery using $('option[value="u

java - Pass Logger as argument to another class -

public class sessionlogger { private final string sessionid; public sessionlogger(string sessionid) { this.sessionid = sessionid; } public void info(log log, string message, object... args) { log.info(formatmessage(message, args)); } public void error(log log, string message, throwable t, object... args) { log.error(formatmessage(message, args), t); } private string formatmessage(string message, object... args) { (int = 0; < args.length; i++) { message = message.replacefirst("\\{\\}", args[i].tostring()); } return string.format("sessionid [%s]: %s", sessionid, message); } } what want pass, logger instance sessionlogger class , see class name, logger initialized. public class { private static final log log = logfactory.getlog(a.class) public void doit() { sessionlogger.info(log, "hello world"); } } i expect see class in log message in

osx - Parallel Coordinates program written with Processing can't show anything in Mac -

Image
so write parallel coordinates program processing in mac pro. however, can't see lines on screen when try run program. confused because program runs pretty in friend's windows based computer. tried add "noloop()" in end of "draw()" function , works. still can't figure out reasons. knows specific reason? in advance! floattable data; string datapath = "cars.csv"; int numrows; int numcols; int[] colmin; int[] colmax; string[] colnames; float plotx1, ploty1; float plotx2, ploty2; float diffbetweenxcoords; pfont titlefont; pfont labelfont; pfont axislimitsfont; color[] axiscolor = { #333333, #000000 }; color[] fontaxiscolor = { #333333, #ff2222 }; color[] fontlimitscolor = { #555555, #ff2222 }; color trianglecolor = #888888; color[] linescolor = { #ed1317, #1397ed }; int[] axisorder; boolean[] axisflipped; // setup void setup() { size(1000, 500); // read data data = new floattable(datapath); numrows = data.getrowc

java - Generating xml graphs using POI -

i using poi create report in xls format. enhanced show graphs data in report. per limitation of poi, cannot create graphs in excel. so, using template , rewriting data in everytime , graph gets refreshed. cell cell = row.getcell(columnsarray[j1]); cell.setcellvalue(integer.valueof(count)); bad practice, have hardcode position of cells in array. int columnsarray[] = { 1,2,3,4,5,6,7,8,9,10 }; anyone using better approach or other alternative of poi achieve this? thanks in advance, gv till apache poi limitation saying "you can not create charts. can create chart in excel, modify chart data values using hssf , write new spreadsheet out. possible because poi attempts keep existing records intact far possible". however in same case, have created chart manually on excel sheet using named ranges , using java, updating named ranges per requirement. since chart based on named ranges updated. you can update existing reference of named ranges , set per req

javascript - how to solve this Jquery error? -

i have made jquery can see fiddle below: http://madaxedesign.co.uk/dev/test/ http://jsfiddle.net/x82mu/1/ code: $(document).ready(function() { var $root = $('html, body '); $('.scroll a').click(function(e) { var href = $.attr(this, 'href'); $root.animate({ scrolltop: $(href).offset().top }, 500, function () { window.location.hash = href; }); return false; }); // responsive menu $(function() { var pull = $('#pull'), menu = $('nav ul'), menuheight = menu.height() $(pull).on('click', function(e) { e.preventdefault(); menu.slidetoggle(); }); $(window).resize(function(){ var w = $(window).width(); if(w > 320 && menu.is(':hidden')) { menu.removeattr('style'); } }); }); }); but pulls through error: uncaught typeerror: cannot read property 'top' of undefine

javascript - Backbone.js getting target attribute -

i trying figure out why value of e.target.getattribute('data-text') becoming null when go html backbone js file. html: <script type="text/template" id="lesson-template"> <span id="lesson-title"><%= tracks[0].title %></span> <select class="sel"> <% _.each(tracks, function(track) { %> <option value = "<%= track.text %>" data-text="<%= track.title %>"><%= track.title %></option> <% }); %> </select> <p id="tracktext"><%= tracks[0].text %></p> </script> js: window.librarylessonview = lessonview.extend({ events: { "change .sel " : "changetext" }, changetext: function(e) { alert(e.target.getattribute('data-text')); //i getting null value here! document.getelementbyid("lesson-title").innerhtml= e.target.getattribute('data-text&

android - how I can access menu items in fragment? -

i created menu items in main activity have fragment , wanna access menu items ( copy , paste,share ) in fragment . public class frag_angel extends fragment { ..... @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { wrapper = new linearlayout(getactivity()); setretaininstance(true); v = inflater.inflate(r.layout.frag_angel, wrapper, true); sethasoptionsmenu(true); ..... } i wrote below code does't work me ! public boolean onoptionsitemselected(android.view.menuitem item) { switch (item.getitemid()) { case r.id.copy:{ refreshlist(); // add measurement } default: return super.onoptionsitemselected(item); } } private void refreshlist() { // todo toast.maketext(getactivity(), "refreshing first list...", toast.length_short).show(); } and can't use getsystemservice ! you need override onoptionsitemselected.

sql server - How to check input patterns within a store procedure SQL? -

i have store procedure takes 21 parameters. @concept_name,@k1,@w1 .....@kn, @wn would know how can use check input pattern ensure correctly formatted , correct data types used. , prints error message user if string pattern invalid (missing w, k, comma or reversed) data type @concept_name varchar(55) data type @k varchar(55) data type @w decimal (3,2) can treat 2 strings i.e '@concept_name' , other '@k1,@w1.....@kn,@wn' thanks help

jquery - Fire Wordpress Plugin/Shortcode after Ajax Load -

i have website loads main content via ajax, have run problem getting plugins/shortcodes in said content load. plugins work fine if directly load each page via url bar. ajax code jquery(document).ready(function() { var history = window.history; if (!history.enabled) { return false; } // bind statechange event history.adapter.bind(window,'statechange',function(){ var state = history.getstate(); //history.log(state.data, state.title, state.url); var goto_url = state.url; jquery('.content').load(goto_url+ ' #main').hide().delay(750).fadein(1000); }); jquery('.main-menu a').click(function(evt){ var href = jquery(this).attr('href'); history.pushstate({}, '', href); var elementclassname = jquery(this).attr('class'); jquery('.main-menu a').removeclass('active'); jquery('.main-menu a.'+elementclassnam

Store images in array PHP -

i'm new @ php doing work, want save images in php array , show them in screen, cannot save them or display them. <?php $min = 1; $max = 9; $number1 = rand($min,$max); ($i=1 ; $i<=$number1 ; $i++){ $firstn [$i] = echo "<img src='index.jpg' border='0'>"; } echo $firstn [1]; ?> this got , , last line test nothing works, google topic doesn't help. in advance. as long index.jpg in same directory file, should work: <?php $firstn = array(); $min = 1; $max = 9; $number1 = rand($min, $max); ($i = 0; $i < $number1; $i++){ $firstn[] = '<img src="index.jpg" border="0">'; } echo $firstn[0]; ?> cleaned code bit. when storing information in array, don't use echo and, mister pointed out, had space in echo @ bottom of code between array-variable , brackets.

c# - How to intercept and record or modify signals between hardware and software -

my understanding of how stuff works limited, make library calls make audio / video magically show up. i want able mitm "attacks" programs on own computer. (i'd guy intercepting signals between software , hardware). kind of thing useful in number or scenarios. for instance, audio: xp doesn't have way change audio specific programs while keeping others unchange. has 1 audio manager across programs. if intercept signal (and detect program coming from) in theory make own audio manager. i record conversations, possibly testing out audio -> text software may have/create. many more. for video: (primary goal here): record conversations. have used third party program, i'm guessing doing taking snapshots because 1) video choppy , 2) when mouse or other thing gets in way of video, records too. wouldn't easier record signal going video card specific program of interest, play when want see again? for network traffic: for recording traffic

mysql - How do I use MAX() to return the row that has the max value? -

i have table orders fields id , customer_id , amt : sql fiddle and want customer_id largest amt , value of amt . i made query: select customer_id, max(amt) orders; but result of query contained incorrect value of customer_id . then built such query: select customer_id, max(amt) maximum orders group customer_id order maximum desc limit 1; and got correct result. but not understand why first query not worked properly . what doing wrong? and possible change second query obtain necessary information me in simpler , competent way? mysql allow leave group by off of query, returning max(amt) in entire table arbitrary customer_id . other rdbms require group by clause when using aggregate. i don't see wrong 2nd query -- there other ways it, yours work fine.

ios - Capture view with custom UIView in storyboard returning nothing? -

i using signature class add signatures ios application: https://github.com/jharwig/signaturedemo/blob/master/signaturedemo/nicsignatureview.h i have signature view in storyboard form sheet, , able draw , , works.... however, want save signature image. that, doing this: uiview *view = self.view; uigraphicsbeginimagecontextwithoptions(view.bounds.size, view.opaque, 0.0); [view.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage * img = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); uiimagewritetosavedphotosalbum(img, nil, nil, nil); the image, however, white, without signature. assume becuase view not add programmatically, storyboard. however, addsubview not adding view. the signature class has built in method return uiimage, unsure how call view controller has view set in storyboard. so question is, how can image? add property view controller @property (retain, nonatomic) iboutlet uiview* mysigview; connect mysigvi

python - how to translate custom language to html -

i'm trying conversion of custom language html . following example should intuitive-easy enough understand without explaining: input file... css: define(style): if default: background-color=black if hovered: background-color=blue apply(style, tag=h1, tag=h2) html: body(id="hello"): paragraph(id=demo): "this paragraph. input(type="button", onclick="displaydate()"): "display date js: def displaydate(): document.getelementbyid("demo").innerhtml=date() ...should translated to... h1 { background-color: black } h1 :hover { background-color: blue } id { background-color=black } id :hover { background-color=blue } <html> <body id="hello"> <p id="demo">this paragraph.</p> <input type="button", onclick="displaydate()">dis

css - a:visited links - opacity not working -

i'm trying make when link has been visited, persistently color , opacity matches non-visited links when webkit transitions them. using this: a:visited { color:#cc7839; opacity:0.1; } i can visited links color, except opacity isn't doing anything. set 0.1 make easier see if working. when hover on visited link, transitions opaque color set webkit a:link:hover. here's css that's in file setting links: a:link:hover,a:hover,a:visited:hover { color: #cc7839; opacity:0.8; text-decoration:none; -webkit-transition:all 0.5s ease-in; -moz-transition:all 0.5s ease-in; } i'm thinking have change latter css in terms of "a"s specifies? not possible. can use :visited selector change color of element. opacity doesn't work. sec7115 :visited , :link styles can differ color. reference here - unable find w3 documentation stating it..

php - Preg_replace transform parameter inside function -

is possible make preg_replace parse variables inside function? i looking transform [shorturl]full-url[/shorturl] clickable short url. i want this: $code = array( ... '#\[shorturl\]((?:ftp|https?)://.*?)\[/shorturl\]#i' => '<a href="'.file_get_contents("http://...some_api?url=$1").'">$1</a>', ... ) $result = preg_replace(array_keys($code), array_values($code), $text); but don't works... api receive "$1" url rather url. any thoughts? this cannot work. have in execution sequence of example: file_get_contents gets executed before preg_replace called. but want result of regular expression part of function call. solution: preg_replace_callback . function calls code every time match found. example: preg_replace_callback('#\[shorturl\]((?:ftp|https?)://.*?)\[/shorturl\]#i', function($a) { return '<a href="'. file_g

java - Doubly Linked List Null Pointer Exception -

i'm trying work on remove function doubly linked list, keep getting null pointer exception on current.prev.next = current.next; part. don't think understand null pointer exception is, because have no idea fix this. log function 1 wrote write output file, , retval[1] element i'm searching delete. node current = head; while(current != null) { if((current.data).compareto(retval[1]) == 0) { if(current.prev == null) head = current.next; if(current.next == null) tail = current.prev; current.prev.next = current.next; current.next.prev = current.prev; current = null; valid++; log(line + "\n" + "sucsessfully removed \n"); } else { log(line + "\n" + invalidtransaction + &quo

ios - How can I add an interactive view controller inside of a UITableViewCell? -

in project have uitableview holds horizontal scrolling uicollectionviews. each cell in table view new collection view. need have interactive view on left side of each cell. view collapsed along left side, if tap view, animate open little bit. if collection view scrolled way left, i.e. beginning, open. once user starts scrolling collection view automatically close. here visual example: table view cell.. the view collapsed in image. ____________________________ |v | | |i | collectionview | |e | scrolls </> | |w_|_______________________| view open in image. ways opens described above. ____________________________ |v | | |i | collectionview | |e | scrolls </> | |w______|__________________| how able have interactive controller on left side of cell, has collection view within? also if there 3rd party controls this, great also! that uiview - not uiviewcontroller - placed

Allow php in wordpress page -

i want use following code in wordpress. how can that? <?php $theme_name = get_template(); $directory = "wp-content/themes/" . $theme_name . "/pdf/ece340/"; $pdfs= glob($directory . "*.pdf"); foreach($pdfs $pdf) { $link= substr($pdf,48,90); ?> <a href="<?php echo $pdf; ?> "><?php echo $link; ?></a> <?php echo "\n\n"; echo "<br />"; } ?> below answer (taken here ): add_filter('widget_text','execute_php',100); function execute_php($html){ if(strpos($html,"<"."?php")!==false){ ob_start(); eval("?".">".$html); $html=ob_get_contents(); ob_end_clean(); } return $html; } copy above function @ end of functions.php file. but best soluttion create custom template instead of using php in pages/widgets/posts. find more wordpress custom templates here .

delphi - TIdNNTP fallback to XOVER for legacy/non-compliant NNTP server -

i using tidnntp , encountered situation news.astraweb.com server announces in list extensions supports new command hdr , over (formal versions of xhdr , xover ) - see http://tools.ietf.org/html/rfc3977#section-8.3 , http://tools.ietf.org/html/rfc2980#section-2.8 the problem server replies command code 500 (invalid command) when issued on command (instead of xover). although non-rfc-compliant behavior i'd see if there possibility force tidnntp use xover instead of over, in other words work in sort of "legacy" mode. same thing works compliant server news.aioe.org log example news.astraweb.com (problematic server) ->capabilities <-500 what? ->list extensions <-202 extensions supported: <-hdr <-over <-. ->group group.name <-211 100031 1 100031 group.name ->over 100031-100031 <-500 what? proper log news.aioe.org (works expected) -> capabilities <- 101 capability list: <- version 2 <- implementation inn 2.5.2 <