Posts

Showing posts from April, 2015

javascript - Detecting the end (drop) of a Scrollbar Event -

i need detect when user has stopped scrolling only in scrollbar . there site: http://beoplay.com/products/beoplaya9 , doing need. i need readjust page position if user has scrolled (with scroll bar) , left scroll between 2 pages. notice in example website page position readjusted @ 'drop' of scroll bar. this question has been asked many times, not way, i've seen this plugin james padolsey , doesn't work example website. i have code in jsfiddle: http://jsfiddle.net/promatik/7rkgv/ handling of mouse wheel done, can't figure out how handle scroll bar move know when dropped. maybe there away differentiate event wheel scroll , scroll bar scroll. $(window).on('scroll', function (event) { console.log(event); }); does know how replicate effect in example ?

python 2.7 - Django not translating the site properly -

after spending many hours on this, stackoverflow rescue. i configured settings.py below: ... time_zone = 'europe/berlin' language_code = 'de' languages = ( ('en', u'english'), ('de', u'german'), ('fr', u'french'), ) use_i18n = true use_l10n = true middleware_classes = ( 'django.middleware.locale.localemiddleware', 'django.middleware.common.commonmiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', ) template_context_processors = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.request', 'django.c

java - Looking for a way to add data to bean validation exception -

i have custom bean validator implements boolean isvalid(object, constraintvalidatorcontext) performs business logic , returns true/false depending on logic. what able add data constraintviolation exception thrown. exception handlers catch , process can tease out data include more details error/arg caused it. right can associate message violation lacks these dynamic details. for example, object passed isvalid contains map contents validated validator. because validator api returns boolean lose granularity of member(s) of map triggered constraint violation. looking way of being able preserve , pass information forward. edit 8/13/2013 - example solution involving jax-rs (leaves out jaxb details not relevant question) fooparam.java public class fooparam { private map<string, string> subparammap; public map<string, string> getsubparammap() { return this.subparammap; } public void setsubparammap(map<string, string> subparammap) { this.subparamma

Mp4parser - android - cant make it work -

i trying make video splitting app of shorten example. trying implement following project github. https://github.com/dadachi/testmp4parser . but app not working , aborting. logcat - 08-05 17:03:42.161: d/openglrenderer(6834): enabling debug mode 0 08-05 17:03:44.934: d/do shoren starting(6834): shoren starting 08-05 17:03:44.944: w/dalvikvm(6834): threadid=12: thread exiting uncaught exception (group=0x4151e700) 08-05 17:03:44.944: e/androidruntime(6834): fatal exception: doshorten 08-05 17:03:44.944: e/androidruntime(6834): java.lang.runtimeexception: no box object found ftyp 08-05 17:03:44.944: e/androidruntime(6834): @ com.coremedia.iso.propertyboxparserimpl$fourcctobox.invoke(propertyboxparserimpl.java:187) 08-05 17:03:44.944: e/androidruntime(6834): @ com.coremedia.iso.propertyboxparserimpl.createbox(propertyboxparserimpl.java:90) 08-05 17:03:44.944: e/androidruntime(6834): @ com.coremedia.iso.abstractboxparser.parsebox(abstractboxparser.java:87) 08-05 17:03:44.

ocaml - The type constructor is not yet completely defined -

here's simplified code : type t1 = [ `a of t2] , t2 = [ `b | t1 ] i know in case don't need "and" because types don't need mutual definition, in real world need it. why doesn't work ? can make work doing and t2 = [`b | `c of t1] but lose interest of polymorphic variants , i'll switch normal variants. is there way can ? in definition of t2 trying "extend" type t1 not defined @ point (as requre t2 in `a branch). if want "emulate" recursive ordinary data types (but using polymorphic variants instead) should use references mutually-recursive types under data constructor. example in case may this: type t1 = [ `a of t2 ] , t2 = [ `b | `c of t1 ] note in ocaml construction [ `b | t1 ] not mean extending polymorphic row row - type synonym substitution.

angularjs - Node.js + Angular = Uncaught ReferenceError: require is not defined -

i'm creating express.js api on node.js server. api used access data stored on server. keep log of who's accessing api in database. i'm trying create admin section use angular.js display admin access logs neatly. used angular express bootstrap seed start project: https://github.com/jimakker/angular-express-bootstrap-seed/ my problem need controllers.js access node modules doesn't seem know node exists. here error: controller.js var mongo = require('mongodb'); [uncaught referenceerror: require not defined] how can use node modules in angular.js files? node server side technology, not typically use node modules on browser angular.js. however, if want commonjs require functionality in browser see: https://github.com/substack/node-browserify . ofcourse, browser can't talk mongodb directly why need api in first place, angular communicate api using http. angular.js makes $http call node.js requires , talks mongodb.

javascript - How to select element by id within existing selection? -

given html: <div id="div-a"></div> <div id="div-b"></div> <div id="div-c"></div> and previously-created jquery selection: var $divs = $("div"); how can select particular div in selection id? note: $divs selection has not yet been appended dom, can't select directly (e.g. $("#div-b") ). find() selects descendants of selection, not work: $divs.find("#div-b"); has() / :has() selects elements contain element specified selector, not work: $divs.has("#div-b"); you want use filter() reduce set/. var elem = $divs.filter("#div-b");

atlassian - JIRA 6.0 Username Change on Database -

i'm working on making bulk change our usernames inside of jira. i'm using jira 6.0 , have changed individual names 1 one. looked @ tables jira changed, when made individual username change. username changed @ app_user, cwd_user , cwd_membership. went through , changed usernames inside 3 tables. re-indexed jira , don't see changes. ideas on step i'm missing? thank help. appreciated. this old question answer might else. jira 6.2 + supports renaming of users. upgrade , rename.

ruby on rails - How to query across three models -

i have workspace, project, user, , membership models. user has many memberships, , many projects through memberships. project belongs work space. getting users projects pretty easy: user.projects but reaching across work spaces tricky. raises error of undefined method spaces collection proxy . user.projects.work_spaces.unique how can unique set of work spaces user involved in? (work spaces projects user belongs through memberships). if using activerecord, suggest leveraging association methods in order avoid verbose code , poorer performance of .collect(&:work_spaces).flatten.uniq. class user < activerecord::base has_many :memberships has_many :projects, through: :memberships has_many :work_spaces, through: :projects end you able ask user.work_spaces .

python - Scrapy: Importing a package from the project that's not in the same directory -

i'm trying import package project not in same directory scrapy in. directory structure project follows: main __init__.py /xpaths __init.py xpaths.py /scrapper scrapy.cfg /scrapper __init.py settings.py items.py pipelines.py /spiders myspider.py i'm trying access xpaths.py within myspider.py . here attempts: 1) from main.xpaths.xpaths import xpathshandler 2) from xpaths.xpaths import xpathshandler 3) from ..xpaths.xpaths import xpathshandler these failed error: importerror: no module named ....... my last attempt was: 4) from ...xpaths.xpaths import xpathshandler which failed error: valueerror: attempted relative import beyond toplevel package what doing wrong? xpaths independent scrapy, therefore file structure has stay way. //edit after further debugging following @alecxe comment, tried adding path main inside sys.path , , print before importing xpaths. weird thing is, scrapper dire

PHP Calling a static function -

given following code looking pro's , con's of calling $this->mystaticfunc(); vs self::mystaticfunc(); class myclass private function myprivatefunc() { ... $this->mystaticfunc(); // or self::mystaticfunc(); ... } // no need tell me can't use $this in here public static function mystaticfunc() { ... } } // access static function myclass::mystaticfunc(); the cons of using $this->mystaticfunction() are: it doesn't indicate intend ( -> indicates doing object, but aren't ), it may wind calling didn't expect, it confuse reader (all reader able determine sure author doesn't understand basic oo principles), and it's wrong : static functions belong classes, not objects. call them through class (including self ), not object. the possible pro may want override static function in child class, indicates function belongs object , not class. in case more appropriate use instance method.

html - Jquery custom CSS not working -

i've used jquery's custom roller style accordions, reason, don't render they're supposed to. thing should change colors, size different, images missing, etc. here's html <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js" language="javascript"></script> <script type="text/javascript" src="http://www.compactcourse.com/js/accordionnew.js" language="javascript"></script> <link href="http://www.compactcourse.com/css/accordionnew.css" rel="stylesheet" type="text/css" /> <h1>toggle panels</h1> <div id="notaccordion"> <h3><a href="#">section 1</a></h3> <div>mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. integer ut neque. vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. nam nibh. donec suscipit eros. nam

python - Postgresql: "database does not exist" -

following postgresql installation instructions mac, created db , launched server. looks it's working fine. /opt/local/lib/postgresql93/bin/postgres -d /opt/local/var/db/postgresql93/defaultdb log: database system shut down @ 2013-08-12 15:36:09 pdt log: database system ready accept connections log: autovacuum launcher started however, when try access database python3 django, following error: operationalerror: fatal: database "/opt/local/var/db/postgresql93/defaultdb" not exist if go directory, defaultdb, see exists , there many files in it. aside above error message appearing in python traceback, appears in postgres log: fatal: database "defaultdb" not exist fatal: database "/opt/local/var/db/postgresql93/defaultdb" not exist i've tried replacing full path name "defaultdb", same message. edit: in fact, running following doesn't work either: /opt/local/bin/psql93 defaultdb psql93: fatal: database "defa

html - Linking images that are in separate folders -

i've been working in friends code, , of images called out as: <img src="/uploads..."> //the '/' before folder in src isn't allowing me link images. i know easy question of you, can't seem images link correctly. have file structure follows: project folder>two folders (uploads) & (code) now, if have html in 'code' folder, , i'm trying link of images in 'uploads' folder, how should restructure files link? i've tried putting html in root under 'project folder' , still doesn't link images in uploads. the point don't want take out '/' in every src inside html, , hoping structure files link correctly. if every image link looks this: /uploads/somefile.ext then files being linked going need in folder called uploads in root of web server. above gets translated this: http://server/uploads/somefile.ext no matter url of page is. in general sort of thing frowned upon because

jquery - Error loading src = ' ' when you click (ajax) -

i have need return json. failure when click link item clicked loads video. did requests using jquery, error page reloads. needs ajax, possible? jquery: var main = function () { var url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3d'http%3a%2f%2frss.cnn.com%2fservices%2fpodcasting%2fac360%2frss.xml'%20and%20itempath%3d%22%2f%2fchannel%22&format=json&diagnostics=true&callback=?"; $.ajax({ type: 'get', url: url, async: false, jsonpcallback: 'jsoncallback', contenttype: "application/json", datatype: 'jsonp', success: function (json) { // titulos var titles = json.query.results.channel.item.map(function (item) { return item.title; }); // urls var urls = json.query.results.channel.item.map(function (item) { return item.origli

android - Populating SQLite ListViews Dynamically in Real-time, Between Activities, Using onListItemClicks/intents/other? -

Image
i'm new android, , basic user flow of app accounted for, can sense of accomplishment keep me interested enough work on areas of it. know isn't best practice, go later , make sure have multi-threading, singleton db, async, , other stuff. want ui designing part asap. basically i'm trying update the sql queries based upon onlistitemclicks, , dynamically user navigation.. through authors, keywords, categories, etc. i have working, , thought sure there way make work corresponds db quite easily, i've yet find anything: @override protected void onlistitemclick(listview l, view v, int position, long id) { log.i("fragmentlist", "authors_id " + id); here's other code i've tried, failed with: public void onitemselected(adapterview<?> arg0, view arg1, int arg2, long arg3){} string selecteditem = (string) getlistadapter().getitem(position); string query = "select body \"main\".\"quotes\" _id = &

How do I determine if an activity is being launched from a back navigation versus being launched by the user in Android? -

the home screen of app needs have different behavior when app being launched outside app versus when navigation occurs. example, imagine android twitter client on launch tries updated feed when click on item hit detail page , hit back, screen doesn't reload new feeds instead left from. so far i've tried looking @ calling package property hasn't helped since seems null both when app launched user first time or when hit detail page. when user launches first time, oncreate() onresume() called sure. when navigating , getting activity backstack, onresume called. also if activity has singletop set, can onnewintent() called when navigate activity other screens. so, solution can suggest set singletop activity. while navigating using onnewintent(). 1st time launch oncreate() called. sorry if not understand question well..

How to embed the Google Maps iPhone app within my own native iphone application? -

the apple developer documentation explains if place link in web page , click whilst using mobile safari on iphone, google maps application provided standard iphone launch. how can launch same google maps application specific address within own native iphone application (i.e. not web page through mobile safari) in same way tapping address in contacts launches map? for ios 6.1.1 , lower, use openurl method of uiapplication. perform normal iphone magical url reinterpretation. so [someuiapplication openurl:[nsurl urlwithstring:@"http://maps.google.com/maps?q=london"]] should invoke google maps app. from ios 6, you'll invoking apple's own maps app. this, configure mkmapitem object location want display, , send openinmapswithlaunchoptions message. start @ current location, try: [[mkmapitem mapitemforcurrentlocation] openinmapswithlaunchoptions:nil]; you'll need linked against mapkit (and prompt location access, believe). you can use uiappli

opencv - How to pass data to Mat using pointer of image data -

in code, don't want read data rout of images,such as cv::mat img_1 = imread("f:\1.tif"); instead wanna read data pointer: float* srcimage;//pointer image data cv::mat img_1(height, width, cv_32fc1, srcimage); however, found that, way, when used img_1 in following orb function, didn't work cv::orb orb; vector<cv::keypoint> keypoints_1; cv::mat descriptors_1; orb(img_1, cv::mat(), keypoints_1, descriptors_1); how can pass data mat pointer? there difference between imread() function , pass data pointer? or, there special request in cv::orb function ? thanks much! i'm not familiar opencv, start using few weeks, need solve problem , rest part of code depends on results of part. orb wants 8bit grayscale image input, not cv_32fc1

ssh - Jenkins CLI Authentication -

i trying run groovysh on jenkins cli, using following command: java -jar jenkins-cli.jar -s <jenkins url> -i jenkinsprivatekey.ppk groovysh i generated private key file using puttygen, , pasted public key shh public keys box on /me/configure page of jenkins. it's not key doesn't work - seems it's not authenticating @ all. when run who-am-i using cli: java -jar jenkins-cli.jar -s <jenkins url> -i jenkinsprivatekey.ppk who-am-i it gives me response of: authenticated as: anonymous what missing here? thought if authentication failed @ least display error message of kind. there way verify private key works? edit: after experimentation, seems authentication via cli fail silently - put bogus public key in profile configuration, , still saw no error. you may need convert putty keys openssh format them work key. see https://wiki.cloudbees.com/bin/view/dev/customer%2bprovided%2bslaves%2bwindows "back putty key generator, use convers

c# - How to detect creation of folders/copying of files created by user/explorer.exe? -

how detect creation of folders/copying of files created user/explorer.exe? preferably in c# or vb.net, c fine. (note want folders created end users, not windows/applications) i found sample app made use of shchangenotifyregister: http://msdn.microsoft.com/en-us/library/windows/desktop/dd940348(v=vs.85).aspx but after testing found out doesn't detect files/folders created end user, applications (e.g. when hitting "save" in excel) is because detection scope "explorer namespace"? possible change sample app detect creation of files , folders initiated end user using explorer shell?

html - Table not align according to design -

Image
i have created table, table data , tablerow align things nicely. in design view of asp.net, shows table align nicely picture shown below however when enter websites, distorted i'm not sure why there such drastic difference between design in asp.net , browser. below html code table cant see problem in it. <h2 align="center">officer&#39;s profile</h2> <br /> </td> </tr> <tr> <td rowspan="6" colspan="4" width="50%"> <b>profile picture</b> <br /> <asp:image id="image2" runat="server" /> <br /> <br /> <b>rank</b> <br /> <asp:image id="image1" runat="server" /> <br /> <br /> </td> <td align="le

Syntax error in Python/pygame -

this question has answer here: nested arguments not compiling 1 answer i'm learning python/pygame , i'm doing physics tutorial. unfortunately, think made in older version of python. copied code in video exactly, when run it returns "failed run script - syntax error - invalid syntax(physics.py, line 7)". i'm sure it's stupid , obvious i'm missing, answer go long way me! import os, sys, math, pygame, pygame.mixer pygame.locals import * screen_size = screen_width, screen_height = 600, 400 class mycircle: def __init__(self, (x, y), size, color = (255,255,255), width = 1): self.x = x self.y = y self.size = size self.color = color self.width = width def display(self): pygame.draw.circle(screen, self.color, (self.x, self.y), self.size, self.width) screen = pygame.display.set_mode(scr

css - Separator between vertical menu items -

i'm making vertical menu website. it's supposed have mobile , feel. menu complete, don't know how add subtle divot/separator between each menu item. can show me how done? i'm styling menu off of jpanelmenu , take if like. here css menu: #menu { position: absolute; top: 0; left: 100%; font-family: ubuntu; font-size: 16px; color: #ffffff; height: 100%; width: 15%; background: #1b1b1b; display: none; box-shadow: -0px 0px 6px #888888; z-index: 2; } #menu { color: white; text-decoration: none; } #menu li { list-style: none; padding-left: 5px; line-height: 50px; } #menulinks li:hover{ background: #6b6b6b; } you can @ site if need visual demonstration. http://ion.comli.com fiddle here: html <ul class="menu"> <li><a href="#">overview</a></li> <li><a href="#">usase</a></li> <li>&l

Oracle compare string -

i have strange issue in oracle never seen before.... i have following insert select statement insert table2 ( key_field,value ) select key_field, case when type ='s' 100 else 1 end view1 key_field=1 when run select part 100 second field, if run insert select statement 1 in table2 . if include field type on insert, 100 if use "case when type like 's' 100 else 1 end" 100 in table2 (correct answer) anyone has idea why first select insert statement not working? thank you!

java - Getting Error 400 The request sent by the client was syntactically incorrect (): Using RestTemplate, Spring -

i have client-server architecture in rest, spring mvc. tghe client hitting server url , sending 2 parameters along it. server supposed reply client responce value. 1 client side using resttemplate access server url. when running, server url getting accessed (server side logic getting executed), getting following error on client side: http status 400 - -------------------------------------------------------------------------------- type status report message description request sent client syntactically incorrect (). the client side code is: rresult = resttemplate.getforobject("http://localhost:8081/merchant/api/movietheater"+params.tostring(), responsetext.class); the esrver side code is: @responsebody @requestmapping(value="movietheater") public responsetext getcustomerinput(@requestparam("name") string name, @requestparam("price") double price) { system.out.println("requst url got accessed here"); responset

d3.js - Bars Charts & json -

i'm new dev d3js. value bar in json [{},{}]? me. code [{value: 11}, { value: 111}] http://jsfiddle.net/y8fu5/ thank you. your code has multiple problems. you reference names.length names undefined. think meant json.length you call chart.selectall("rect").data(data) data (the parameter) undefined. think meant data(json) you using scales directly data not values in domain expecting: chart.selectall("rect") ... .attr("y", y) .attr("width", x) this works if data selection has values in domain of scale. in case, data objects value , name properties in domain of scales, so: chart.selectall("rect") ... .attr("y", function(d) { return y(d.name); }) .attr("width", function(d) { return x(d.value); }) similar issue text nodes: chart.selectall("text") ... .attr("x", x) .attr("y", function(d){ return y(d) + y.rangeband()

php - preg_replace function set but not working -

i working, sorry guys...i should not put $_post again inside $stm the below code received posted value security purpose, plan put preg_replace function..but not working? <?php if (isset($_post['cartoutput'])) { $customer_name = preg_replace("/[^a-za-z0-9 ]/", '', $_post['customer_name']); more code ...which might cause problem? checked php didn't filter <?php if (isset($_post['cartoutput'])) { $customer_name = preg_replace('/[^a-za-z0-9 ]/', '', $_post['customer_name']); $tel_num = $_post['tel_num']; $customer_address = $_post['customer_address']; $error_status = false; if (empty($_post['customer_name'])){ echo '<a href="cart.php">please fill name</a>'; $error_status = true; } if (empty($_post['tel_num'])){ echo '</br><a href="cart.php">please fill contact number</a></br>'; $error_status = t

c# - code for downloading documents in zip is not working -

i have written method download files in zip folder. after downloading when opening file it's giving error-"an attempt made move pointer before beginning of file." using ionic zip. code is- protected void zipdownload() { var list = db.documents.where(u => u.userid == (int)session["usrid"]).select(u => new { u.doc, u.docname, u.doctype }); zipfile zip = new zipfile(); foreach (var file in list) { zip.addentry(file.docname, (byte[])file.doc.toarray()); } var zipms = new memorystream(); zip.save(zipms); byte[] filedata = zipms.getbuffer(); zipms.seek(0, seekorigin.begin); zipms.flush(); response.clear(); response.addheader("content-disposition", "attachment;filename=docs.zip "); response.contenttype = "application/zip"; response.binarywrite(filedata); response.end(); }

visual c++ - CStatic not receiving WM_CTLCOLOR -

i think missing small here. i trying make class inherits cstatic transparent background. have managed create instance of class , displayed in parent cview . when add onctlcolor message handler going through class view on visual studio make background transparent, never fires. here code snippet: foo.h class foo: public cstatic { declare_dynamic(foo) public: foo(); virtual ~foo(); virtual void createctrl(cwnd * parent, point topleft, size sz); protected: declare_message_map() public: afx_msg hbrush ctlcolor(cdc* pdc, uint nctlcolor); afx_msg bool onerasebkgnd(cdc* pdc); }; foo.cpp void foo::createctrl(cwnd * parent, point topleft, size sz) { crect rect(topleft, sz); create(pitem->value->getbuffer(), ws_child | ws_visible | ss_center | ss_notify, rect, parent); showwindow(sw_show); } begin_message_map(foo, cstatic) on_wm_ctlcolor_reflect() on_wm_erasebkgnd() end_message_map() hbrush foo::ctlcolor(cdc* pdc, uint n

Get All Users in Google Apps Domain After Installing App from Google Apps Marketplace -

my client saas software provider. has app available in google apps marketplace. customer may add marketplace app domain. marketplace listing provides consumer key , consumer secret, have integrated in our saas product. the customers have installed our app should theoretically able synchronize users google apps domain saas installation using consumer key/secret pair have marketplace listing , configured in saas product. we using following, not work. api call returns "401 unknown authorization header" . require_once $gapps_vendors_dir . '/zend/oauth/consumer.php'; require_once $gapps_vendors_dir . '/zend/gdata/gapps/userentry.php'; require_once $gapps_vendors_dir . '/zend/gdata/gapps/userfeed.php'; require_once $gapps_vendors_dir . '/zend/gdata/gapps/userquery.php'; $options = array( 'requestscheme' => zend_oauth::request_scheme_header, 'version' => '1.0', 'signaturemethod' => 'h

asp.net - IIS hosted web core and websockets -

i have web app uses new websocket feature of asp.net 4.5. have custom handler following: public class websockethandler : ihttphandler { public void processrequest(httpcontext context) { if (context.iswebsocketrequest) { context.acceptwebsocketrequest(websocketrequest); } } public bool isreusable { { return false; } } private async task websocketrequest(aspnetwebsocketcontext context) { //processing } } this works when host app on iis 8, when run app in iis hosted web core, iswebsocketrequest property fasle . so, questin is: iis 8 hosted web core supports websockets , if does, need enable it? well, i've figured out hwc does support websockets fact iis express 8 does, , wrapper on hwc. after i've examined iis express applicationhost.config , found there few things there i've missed. the complete list of changes i've made hwc applicationhost.config enable websockets support

javascript - Ruby On Rails: how can I render a partial inside a loop using js.haml? -

i'm trying render partial every object in array of hashes: my controller: @active, @not_active = @objects.partition{ |obj| obj['active'] == 'true' } my js.haml file: # code works - @active.each |obj| $('#' + "#{obj['id']}").remove(); # remove row # code doesn't work - @not_active.each |obj| -p obj # prints object $('#' + "#{obj['id']}").html("#{escape_javascript(render :partial => 'objects/not_active', :locals => {:obj => obj})}"); this code should redraw of existing rows in table. in partial obj = [ ] instead of hash.. how else can render partial inside ruby loop? there's more concise way render partials , pass data it: render 'objects/not_active', obj: obj not sure if rails 4 only.

css - Switching php character limit for responsive media queries -

i have responsive site has php character limits on blocks of text. limit varies depending whether it's desktop, tablet or mobile i'm struggling switch limit depending on device/size. this php code i'm using limit text: <?php ob_start(); the_content(); $old_content = ob_get_clean(); $new_content = strip_tags($old_content); if(strlen($new_content) > 400) { echo substr($new_content,0,400) . "..."; } else { echo substr($new_content,0,400); } ?> how can switch limit in relation media queries make site responsive? far know can't done css can it? css attempt: p.tester { white-space: nowrap; width: 300px; overflow: hidden; text-overflow: ellipsis; min-height:300px; } at moment, limits 1 line, possible show 5 lines? you can not. php serverside, , server not know resolution of screen without help. you add , ajax-call tell php size of screen , load new text php gives you an easier wa

asp.net - Update Database if change in Google Calendar Event -

i creating app in asp.net google calendar. getting 1 problem if have created meeting google calendar using application , after manually deleted meeting google calendar, , again creating meeting on same time showing busy because have entry in database because manually deleted meeting google calendar. there other procedure of getting notification if there change our event on google calendar... channel channel = new channel(); channel.id = system.guid.newguid().tostring(); channel.type = "web_hook"; channel.address = "https://www.translitepc.net/notification.aspx"; channel ch1 = service.events.watch(channel, "hjain@scheduleonce.com").execute(); google calendar api supports push notifications . can use these monitor changes calendar , keep database synced up.

machine learning - SVM How to calculate tf-df of test documents in document classification? -

in svm, using tf-idf on documents feature extraction. these tf-idf calculated on whole of training documents. now when test-document want classify, how generate vector ? i used stemming before calculating tf-idf. can perform on test-document too. have count_of_words train-documents. should increment count of words in train-document count_of_words calculating tf-idf of test-document or should use directly ? calculate them same way during training but: use idf based on training documents , tf test documents. if have many new documents coming in, update training data time time , retrain model.

c# - Rounding to 2 decimal places, without using banker's rounding -

.net , compact framework default use banker's rounding means value: 1,165 rounded to: 1,16. sql server opposite rounds 1,17 me correct behaviour. has come across rounding topic , have workaround compact framework? (in .net there additional parameter has influence on rounding behaviour) here method can use instead of decimal.round: public static decimal roundhalfup(this decimal d, int decimals) { if (decimals < 0) { throw new argumentexception("the decimals must non-negative", "decimals"); } decimal multiplier = (decimal)math.pow(10, decimals); decimal number = d * multiplier; if (decimal.truncate(number) < number) { number += 0.5m; } return decimal.round(number) / multiplier; } taken from: why .net use banker's rounding default? this question asks why .net uses bankers rounding. believe read you. to answer why this bankers algorithm means results collected evenly spread of rounding up/down when decimal == .

iphone - iOS translation and scale animation -

i'm working on uibutton animation where: the uibutton set in bottom center of screen , scaled small size _menubtn.transform = cgaffinetransformmakescale(0.1f, 0.1f); when app starts should moving bottom left side of screen scales or grow original size. - (void)viewdidload { [super viewdidload]; _menubtn.frame = cgrectmake(160, 513, 30, 30); _menubtn.superview.frame = cgrectmake(160, 513, 30, 30); _menubtn.transform = cgaffinetransformmakescale(0.1f, 0.1f); nslog(@"_menubtn: %@ ; _menubtn.superview: %@", _menubtn, _menubtn.superview); [uiview beginanimations:nil context:nil]; [uiview setanimationdelegate:self]; [uiview setanimationduration:5]; [uiview setanimationcurve:uiviewanimationcurveeaseout]; cgaffinetransform scaletrans = cgaffinetransformmakescale(1.0f, 1.0f); cgaffinetransform lefttorighttrans = cgaffinetransformmaketranslation(-200.0f,0.0f); _menubtn.transform = cgaffinetransformconcat(scaletrans,

ruby on rails - Hide part of an email address -

what's best way hide 4 characters before @ sign of email address using ruby eg fakename@example.com = fake####@example.com it's going used in view when display list of testimonials , don't want display whole address. my long way round attempt: name = 'fakename@example.com'.split("@")[0] email = 'fakename@example.com'.split("@")[1] new_address = name [0..-4] + "@" + email try below handle short names a@example.com 'fakename@example.com'.gsub(/.{0,4}@/, '####@')

jquery - AJAX getting onChange to work -

i have set form user can comment entering name, email , comment. i want run validation on input once user leaves #name field, can't work please help. $(document).ready(function() { $('#name').on("change", function () { var name = $('input[name=name]'); if (name.val()=='') { //a regex check added later on check invalid caracters name.addclass('hightlight'); $('#name_error').show(); var error = true; } else { name.removeclass('hightlight'); $('#name_error').hide(); } if ($(error).length) { return false; } }); }); if want trigger on leave can use: $('#name').blur(function() { //your code } refer here: http://api.jquery.com/blur/ if want trigger on change than: $('#name').change(function() { //your code } refer here: http://api.jquery.com/change/

php - Facebook Events Display Order -

i made page can see event public page the php code <?php require 'src/facebook.php'; $facebook = new facebook(array( 'appid' => 'id', 'secret' => 'secret', 'cookie' => true, )); try{ $events=$facebook->api('/page/events?access_token=token'); }catch (facebookapiexception $e){ error_log($e); } foreach ($events["data"] $event){ // time $starttime=strtotime($event["start_time"]); // upcoming events if ((time()-$starttime)<=60*60*24*1 || $starttime>time()){ echo '<li><a href="#" id="'.$event["id"].'" class="event_link"> <img class="ui-li-thumb" src="https://graph.facebook.com/'.$event["id"].'/picture?type=small" width="70px;" height="100%" /> <h3 class="ui-li-he

node.js - Scrap data from site with browser-based Template Engine -

trying scrap data page templates in browser lot of js. , when playing jsdom can't data, maybe page doesn't have enough time load or render. how scrap data in case: use timer or download page request jsdom.env({ url: link, scripts: ["http://code.jquery.com/jquery.js"], done: function (errors, window) { var $ = window.$; var date = $('.date').text(); console.log(date); } }); a colleague of mine has phantomjs-based project doing that: https://github.com/vmeurisse/phantomcrawl . he has simple example looks lot snippet: 'use strict'; var phantomcrawl = require('./src/phantomcrawl'); var urls = []; urls.push('http://www.bing.com'); var ptc = new phantomcrawl({ urls: urls, nbthreads: 4, crawlerperthread: 4, maxdepth: 1 }); urls list of urls crawl. nbthreads number of instances of phantomjs launched. crawlerperthread number of pages crawled in parallel per instance of phantom

sample - Android app development suggestion/ workflow -

i trying develop android application, allow user send correct gps location remote server , can list previous recorded gps locations remote server. i bit confuse use @ level , how integrate them together. specific question is: which library (if there any) use sending data remote server , data (which in json format)? or there sample demo app?? for creating fledge application need maintain server database , local android sqlite database having same schema. there background service can capture gps location whenever device moves , can save gps location on local , real server. if device on offline mode uses it's local sqlite databse , sync server comes in online mode.

html - High resolution images aren't displaying on iPhone on a Website I built & 3 images aren't on the width it should be -

i'm facing problem on website built , there photo on contact page , works on macosx , windows , not on iphone 4/5/4s , etc.. picture details: dimensions 3508 × 2480 file size 320 kb mime type image/jpeg the picture doesn't appear on iphone , maybe it's because of resolution ? 320 kb minimum size i'm able go because it's not heavy load , quality great. hope can solved in way, there's code of calling image: <img src="/styles/images/contact.jpg" alt="something" title="something" style="max-width: 100%;"> the second problem important main page, in screen displays 3 pictures in row , in iphone width , can see 2 pictures , litle bit of 3rd. im using website , there no need optimized version mobile , same website smaller , though images aren't displayed on 100% of mobile width, can see 2 , abit of 3rd image. <div id="container" style="position:relative;overflow:hidden;margin: 0 aut

c++ - Cannot use the copy function -

what wrong copy (which generic function), here? cannot run code. vector<int> a(10, 2); vector<int> b(a.size()); auto ret = copy(a.begin(), a.end(), b); (auto : b) cout << << endl; here's output after compiling: 1>------ build started: project: project1, configuration: debug win32 ------ 1> mainex.cpp 1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(2176): error c4996: 'std::_copy_impl': function call parameters may unsafe - call relies on caller check passed values correct. disable warning, use -d_scl_secure_no_warnings. see documentation on how use visual c++ 'checked iterators' 1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(2157) : see declaration of 'std::_copy_impl' 1> c:\users\amin\documents\visual studio 2012\projects\project1\project1\mainex.cpp(40) : see reference function template instantiation '_outit std::copy<std::_ve

android - How to fetch data of API -

@override protected string doinbackground(string... params) { try{ jsonparser jparser = new jsonparser(); string url="http://earlykid.com/android/?page=2"; idarray=jparser.getjsonfromurl(url); log.e("fetch data",idarray.tostring()); mlatestlist.clear(); for(int i=0;i<idarray.length();i++){ try{ jsonobject jobject; mkids=new kids(); jobject=idarray.getjsonobject(i); mkids.settotalpages(jobject.getstring("totalitems")); mkids.setcurrentpage(jobject.getstring("currentpage")); }catch(jsonexception e){ log.e("log_tag", "error parsing data "+e.tostring()); log.e("log_tag", "failed data was:\n" + idarray); } } }catch(exception e){ } return null; } @override p

.net - How to compare the values in the dictionary with the new values? -

i have dictionary variable having 2 values have retrieved db. need update values in db , while updating need check whether updated values exists in dictionary values or not. how can compare. far have done much. please me whether right or wrong. retrieving datas db , stoing in dictionary variable "dictionaryname" for each row datarow in ds.tables(0).rows dictionaryname.add(row("engmemid").tostring(), row("engmememail").tostring()) next after have compare mew value. dim pair keyvaluepair(of string, string) each pair in dictionaryname if dictionaryname.containskey(newmember.engmemid) ---condition compare emailid's notifyonupdate(newmember) --- end if next after comparing containskey(), how can compare old , new email id's. please me compare these 2 values, dictionary new value. thanks, udhaya s. try this dim oldvalu

nullpointerexception - Specific java method return null pointer exception -

i want specify whether specific node neighbor set of nodes in defined graph or not? purpose wrote method: private boolean isneighbor(arraylist<customer> collection, customer node,directedsparsegraph<customer, transaction> network) throws sqlexception { for(customer customer:collection){ if(network.issuccessor(customer, node)) return true; } return false; } unfortunately method return null pointer exception. decided change to: private boolean isneighbor(arraylist<customer> collection, customer node,directedsparsegraph<customer, transaction> network) throws sqlexception { collection<customer> nodes=network.getvertices(); arraylist<customer> acctualnodes = new arraylist<customer>(); customer acctualnode=new customer(); for(customer customer: collection){ for(customer cust:nodes){ if(cust.getname().equals(customer.getname())) acctualnodes.a