Posts

Showing posts from June, 2010

Simple PHP If Statement Not Acting As Expected -

this simple year validation should check if year between 1900 , current year. if year valid should displayed input's value. if(!empty($year) && $year >= 1900 || !empty($year) && $year <= date('y')){ $yearholder = 'value="'.$year.'"'; }else{ $yearholder = 'placeholder="year"'; } the problem i'm having statement not work, , passes numbers through. you can try this. if(!empty($year) && $year >= 1900 && $year <= date('y')){ $yearholder = 'value="'.$year.'"'; }else{ $yearholder = 'placeholder="year"'; }

ios - Apple watch standup detection -

i working on app dealing user's motion on apple watch. shown on apple watch, recognize when sitting or standing. there way access using api? thanks yes, should able obtain type of motion using cmmotionactivity , part of core motion framework (introduced in watchos 2.0).

computer vision - How to speed up caffe classifer in python -

i using python use caffe classifier. got image camera , peform predict image training set. work problem speed slow. thinks 4 frames/second. suggest me way improve computational time in code? problem can explained following. have reload network model age_net.caffemodel size 80mb following code age_net_pretrained='./age_net.caffemodel' age_net_model_file='./deploy_age.prototxt' age_net = caffe.classifier(age_net_model_file, age_net_pretrained, mean=mean, channel_swap=(2,1,0), raw_scale=255, image_dims=(256, 256)) and each input image ( caffe_input ), call predict function prediction = age_net.predict([caffe_input]) i think due size of network large. predict function takes long time predict image. think slow time it. full reference code. changed me. from conv_net import * import matplotlib.pyplot plt import numpy np import cv2 import glob import os caffe_root = './caffe' import sys sys.path.insert(0, caf...

javascript - output translations without document.write -

i understand document.write evil , should not used output text on website. however, did not find better solution yet usage, output translated text via javascript on page. consider this: my template code looks this: <h1><script>_e("title");</script></h1> in javascript file have similar code translate strigs: // initialize dictionaries , set current language. window.lang = {}; window.lang.en = { "title": "sample page" }; window.lang.de = { "title": "beispiel seite" }; window.curlang = "en"; // translation function should output translated text. function _e(text) { var dictionary = window.lang[window.curlang]; var translation = dictionary[text]; // below line evil. // what's alternative without having change template code above? document.write( translation ); } question : can change javascript function not use document.write work without changing template code...

python - flask-assets - sass don't resolve relative path in @import scss directive -

i have flask application buildout environment ./bin/pip show flask | grep version version: 0.10.1 ./bin/pip show flask-assets | grep version version: 0.10 in src folder src/setup.py have following strings setup( name = 'spf', install_requires = [ 'flask', 'flask-assets', ], entry_points = { 'console_scripts': [ 'spf_dev = spf.manage:dev', /* see manage.py dev function */ ], }, } for generated bin/spf_dev have src/spf/manage.py following code from flask.ext import assets . import env def init (app): manager = script.manager(app) manager.add_command( 'assets', assets.manageassets(app.assets), ) return manager def dev (): init(env.dev.app).run() for flask environment initialization use src/spf/env/dev.py from spf import init app = init({ 'assets_dir': 'src/spf/static/assets', 'assets_url'...

swift - iOS Device Token example for Push Notifications -

i need pass through server auth method, needs devicetoken registration. have simulators, , can't take tokens them, , want send server false token (like 000 000 000) don't know how many digits there in device token. can me out sample device token? device token of 32 bytes. sample device token provided reference raywenderlich 740f4707 bebcf74f 9b7c25d4 8e335894 5f6aa01d a5ddb387 462c7eaf 61bb78ad

javascript - Get DOM values in browser extension -

i want read value of dom element. new browser extensions. came across codes provided in executing code in browser context how fetch value , use in extension's context? var value = document.getelementbyid('id1'); // here document should of browser context. try var value = document.getelementbyid('id1').value; // note .value . you have access dom content scripts .

ios - Crashing after lightweight Core Data migration -

i trying master code data migration, going important supporting app. reason need migration preserve data. app used psychological research , collection reaction time data. have game session , every game session has ordered set of moves. every move has properties. 1 of properties interval: date . in store version 1 named date , in version 2 renamed interval , changed property's model version identifier date. app not crashing on startup when trying view old logs crashes. have uitextview , display logs this: textview.text = "interval = \(move.interval)" if create new game session , view log - app works. what best way protect users? should add additional logic inside app this? how can display old data after property renamed? update: there's no messages in console, app stops working line of code updating uitextview , highlighted in green error message: thread 1: exc_bad_access (code=1, address=0x0) i tried again scratch , instead of renaming v...

java - Efficient Algorithm to a Complicated backpack variation -

i trying find efficient algorithm problem i have list of people each person knows how items need/want order , list of available items him. the list of options contains options ordered kind of "score" person: num - number of wanted items availableitems - list contains available items person option the items should ordered some connection between item , person (the format not important) input- list of people batchnum output - list of options notes (may used efficiency) - each person needs 1-8 items each person have 3-n available items the available items come closed list contains n available items (n 30 can change bit in future) the list of options ordered score each person prefers order unique items (effects score) batchnum represents batches of each item (usually 2,3 or 4) meaning item can ordered in batch of batchnum if batchnum =3 item x can ordered if there 3,6,9... on duplicates needed . . . currently algorithm...

HTML / PHP: Which parts of an HTML head can be saved in a separate file -

i new html , hope can me this. i trying set website code every page saved separate php file. since these pages use same document head , includes i remove as possible of pages , save in separate includes file ( header.php ) can include using php. my current head looks follows , since same on pages have saved in separate header.php file , use <?php include "header.php"; ?> on single pages. can tell me parts of should remain on single pages proper setup , if should changed or added here ? note: jquery , js included separately in footer. my php (header file): <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="x-ua-compatible" content="ie=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="author" content="john doe" /> ...

Python: Spawn New Minimized Shell -

i attempting to launch python script within python script, in minimized console, return control original shell. i able open required script in new shell below, it's not minimized: #!/usr/bin/env python import os import sys import subprocess pytivopath="c:\pytivo\pytivo.py" print "testing: open new console" subprocess.popen([sys.executable, pytivopath], creationflags = subprocess.create_new_console) print raw_input("press enter continue...") further, need able later remotely kill shell original script, suspect i'll need explicit in naming new process. correct? looking pointers, please. thanks! note: python27 mandatory application. need work on mac , linux. do need have other console open? if commands sent, i'd recommend using popen.communicate(input="shell commands") , automate process you. so write along lines of: # commands pass subprocess (each command separated newline) commands = ( "comma...

php - .htaccess to rewrite image urls -

hello im having problem images in wordpress directory plug-in doesnt have support, i've fixed bits images. know have alter .htaccess in root im not sure how. heres current .htaccess looks like: # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule> # end wordpress my site doesnt load images in plugin, when inspecting sourcecode on chrome looking image @ following url, gives 404 error. http://www.example.com//http://www.example.com/wp-content/plugins/wprx/wpt_image.php?i=/wp-content/wpt_cache/7/1713/01.jpg the correct url image be: http://www.example.com/wp-content/plugins/wprx/wpt_image.php?i=/wp-content/wpt_cache/7/1713/01.jpg any ideas on altering .htaccess remove " http://www.example.com// " start of url? many thanks, pete disclaimer: while you're asking possibl...

oracle12c - SQL*Loader-704 and ORA-12154 -

sqlldr "xxxx/xxxx@yyyyyxxxx" control=/home/local/internal/xxxxx/presc_sqlldr_file/presc_sqlldr.ctl log=/home/local/internal/xxxxx/presc_sqlldr_file/presc_log.log data=home/achand/presc_sqlldr_file/presc_sqlldr.ctl whenever i'm trying execute sqlldr i'm getting below error sql*loader-704: internal error: ulconnect: ociserverattach [0] ora-12154: tns:could not resolve connect identifier specified i tried tnsping yyyyyxxxx i got below error tns-03505: failed resolve name tnsnames.ora contain ddcppsd.world = (description = (address = (protocol = tcp)(host = xxxxxyyy)(port = 1521)) (connect_data = (server = dedicated) (sid = yyyyyxxxx) ) ) this error explains it. not specify connect string , username , password. therefore, oracle tries connect local database. must specify username/password@connect_string , connect_string name correspionding entry in client side file tnsnames.ora (same connect string use in sql...

c# - Should i do authorization on my Domain Services? -

i have following domain service: pulic void deletecustomer(int customerid, string useridentity, string userpassword) { //1º login operation verify if credentials valid. customerrepository.deletebyid(customerid); } let's consuming code of asp.net mvc or windows forms application has login window. the login validated again in each operation, wasting resources. let's change to: pulic void deletecustomer (int customerid, int requestuserid) { //1º trust requestuserid valid. //do requestuserid (e.g set userid deleted customer) customerrepository.deletebyid(customerid); } in case, login operation made asp.net mvc or windows forms application 1 time caller can pass requestuserid, leaving terrible security hole. it makes sense authorization in methods need authorization otherwise there security problem, when these methods entry points in backend logic. means if deploy these domain services tier accessible outside, these methods really nee...

javascript - How to change audio src by click using jquery? -

how change dynamically audio src using jquery? <audio id="audio" controls="" > <source src="" type="audio/mpeg" /> </audio> <ul id="playlist"> <?php if($lists) { foreach ($lists $list) { ?> <li class="active"> <a href="music/<?php echo $list; ?>.mp3"> <?php echo $list; ?> </a> </li> <?php }}?> </ul> you need bind click event handler a (or delegate events parent #playlist ) , assign new src #audio source : $('#playlist').on('click', 'a', function(e) { e.preventdefault(); var src = $(this).attr('href'); $('#audio source').attr('src', src); }); important: remember prevent default behavior of htmlanchorelement on click page reload.

git - How can a revert commit also be a merge commit? -

recently @ work, lost code on project under version control using git (and private github repository). i used git bisect find culprit commit, , got surprised discovering looking revert commit, had 2 parents merge commits : commit b5f97311eea2905baf8a96fddec22321d952f05c merge: 8cc7371 131d463 author: bob <bob@othercompany.com> date: fri may 22 19:42:25 2015 +0200 revert "isb-cpw-3627 - mise en place du calage des filtres ds1/ds2/ds3/ds4" reverts commit 8cc7371e7133b68db95ac8e9aeb730d7889a1166. this issue has been resolved creating new branch ancestor commit, , applying patches on top of new branch. so don't need fix that, want understand how can revert commit merge commit, happened, , how reproduce weird behavior. i tried reproduce : create new branch @ 8cc7371 git revert 8cc7371 it creates revert commit single parent ( 8cc7371 ) expected. the culprit commit author uses atlassian sourcetree instead of native command line interface...

database - how to migrate data from mySQL to PostgreSQL -

trying migrate database mysql postgresql. documentation have read covers, in great detail, how migrate structure. have found little documentation on migrating data. i want migration using transport tablespace, have tools migratin, or know how migrate using transport tablespace mysql postgresql i have 104 table in mysql , 200 mb data i not sure, can migrate using transport tablespace mysql postgresql. in order migrate big data sets can use postgresql copy. generally, better use program, automates process of migration (db structure , data). here few open source tools, can helpful: frommysqltopostgresql feature-reach tool , easy use. it maps data-types, migrates constraints, indexes, pks , fks in mysql db. under hood uses postgresql copy, data transfer fast. frommysqltopostgresql written in php (>= 5.4). pgloader   data loading tool postgresql, using copy command. main advantage on using copy or \copy , , on using foreign data wrapper, transaction behaviour...

regex - Match lines with possible preceding whitespaces -

in emacs, want use regex match lines such as list of symbols list of symbols list of symbols and not match lines begin digit or ( (with 0 or more preceding white spaces) such as 1. arithmetic , algebra 1. arithmetic , algebra (a) powers (a) powers but either ^ *[^[:digit:](] or ^[[:space:]]*[^[:digit:](] can match 1. arithmetic , algebra (a) powers where there space @ beginning of each line. i wonder wrong? thanks. you can reduce matching lines don't start digit or open parenthesis. ^[^[:digit:](]

LC3 assembly-how to print the next character of a character -

my aim create program receives letter , prints "next letter".to more specific,if input "p",the output should "q". code: .orig x3000 lea r4,data ldr r0,r4,#0 add r0,r0,#1 trap x21 halt data .fill x5001 .end x5001 has "p",i have checked it.so exmpecting see "q" output.however,i strange looking symbol p instead!what's wrong code?thank in advance.

javascript - include a module into another nodeJS file -

i getting started node , wrote little s3 reader looks following. sits in projectroot/routes/s3store.js directory. var aws = require('aws-sdk'), uploader = require('s3-upload-stream')(new aws.s3()), q = require('q'); module.exports = s3store; function s3store(config) { this.config = config; this.s3 = new aws.s3({ region: config.aws.region }); } s3store.prototype.readstream = function (filepath, metadata) { var readconfig = { 'bucket': this.config.s3.bucketname, 'key': filepath }; return this.s3.getobject(readconfig).createreadstream(); } now, created new file s3storemain.js in projectroot/routes/s3storemain.js , trying import s3store.js module this: var s3 = require('s3store'); on running: node s3storemain.js it cannot find module s3store . here stacktrace: shubham@turing:~/downloads/node-v0.12.4/exp2014$ node routes/s3storemain.js module.js:340 throw err; ^ error: cannot fi...

c# - assigning a string to a string variable throwing Arithmetic operation resulted in an overflow, -

while processing following code getting error. querycommand= "select user_name,user_lastname,user_address usertable" objodbcdatareader = dbconobject.getdatareader(querycommand) if objodbcdatareader.hasrows = true dim username = objodbcdatareader.item("user_name").tostring() 'here throws error arithmetic operation resulted in overflow end if getdatareader method that accept query string , return result datareader . let me know why error occurring while assigning string value string variable? am using visualstudio 2012 mysql 5.0 odbc driver 3.51 64 bit os in if statement testing see if rows exist, at point have not read data? querycommand= "select user_name,user_lastname,user_address usertable" objodbcdatareader = dbconobject.getdatareader(querycommand) if objodbcdatareader.hasrows = true objodbcdatareader.read() lsfinyear = objodbcdatareader.item("user_name") 'here throws error arithmetic operation result...

Send http-404 response BUT dont send custom error page setted in IIS server | PHP -

lets understand scenario: :- using php web application on iis 8.5 :- custom error page set 404 following web-config snippt: <httperrors errormode="custom" existingresponse="replace"> <remove statuscode="404" substatuscode="-1" /> <error statuscode="404" path="/path/404.php" responsemode="executeurl" /> </httperrors> :- working non-existing page and iis also return 404.php if set header 404 (via header('http/1.0 404 not found', true, 404); die; ) in php page. question: now, wan send 404 http response code in php-file on specific condition, lets if database returns 0 rows. can setting header above return custom error page also. is there way send 404 code , tell iis send response is, without sending custom error page along it? issues: :- if remove custom error page , put content between header() , die() meet requirement iis fail serve custom error on pages d...

model view controller - Accessing objects defined in main addon script from content and page scripts in Firefox addons -

i making bootstrapped extension firefox (actually, trying port working chrome extension). in chrome was: background page holds backgroundapp instance of marionette.application , modules hold backbone models of data , storage , sync stuff. popup page holds popupapp instance of marionette.application , modules take care of ui views , routers defined in them. data, popup uses reference backgroundapp accessed via chrome.extension.getbackgroundpage() . now having hard time finding how can pass models popup panel code in firefox, messaging mechanisms i've encountered far take jsonable data. you have no joy if you're trying use javascript frameworks in firefox addons. @ least if you're using them beyond scope of single window object. there multiple different, isolated environments in scripts run. if take e10s (multi-process firefox) consideration addon main code run in parent process while interacts page content run in content process(es). message-passin...

Visual Studio Enterprise RC 2015: Windows 10.0.10069 SDK etc install errors -

windows 10 sdk 10.0.10069 : installer failed. fatal error during installation. error code: -2147023293 (0x80070643) emulators windows mobile 10.0.10069 : installer failed. fatal error during installation. error code: -2147023293 (0x80070643) emulators windows mobile 10.0.10069 : installer failed. fatal error during installation. error code: -2147023293 (0x80070643) installing visual studio enterprise 2015 rc on windows 10 build 10130. dont know if related had windows sdk 10.0.10056 on machine , visual studio 2013 , first installed vs community 2015. have been uninstalled since , these errors on install attempt after of removed (i got same errors whilst on there). from install log: [0bc8:0c90][2015-06-13t12:22:38]i000: mux: executepackagebegin secondary installer [0bc8:0c90][2015-06-13t12:22:38]i000: mux: checking see if secondary installer pipe should created [0bc8:0c90][2015-06-13t12:22:38]i000: mux: creating secondary installer pipe: {386a44b6-1b61-419b-9d49-f8a3...

twitter bootstrap - Why can't I have two col-sm-6 side by side? -

Image
in home page https://balmainmassage.com.au have responsive image in col-sm-6 class on left , on right, same class. firther down, have 2 long images (fw.png , supertuesday.png) inside class col-sm-5 div. it's col-sm-5 because col-sm-6 2 img move left under figh480tjpg image. 2 long images shorter should be. advice? thanks much claudio it's difficult explain changes necessary fix you've got. others have said, way bootstrap meant work nest columns within rows. can't nest column directly inside of column , expect behave properly. need declare row first. however, way have @ time looking @ website, isn't problem. essentially want @ highest level 2 columns left column fight picture , right column of buttons , other stuff. therefore, need change elements following: i hate use picture here since it's not seo-friendly, changes complex without base code edit (i had in chrome devtools). this gets result: as others have stated, not use margins o...

wifi - Accept any Wi-Fi password on OpenWRT (hostap) -

after reading this article on ars technica started looking way enable encrypted, yet passwordless public network. not possible due specifications require number of characters , oss complying them, accepting password? it require custom scripting or modifying sources, i've chosen openwrt try out. relevant sources can found here , here , used building wpad , hostpad , wpa-supplicant packages. default openwrt uses wpad-mini (suffix mini means absence of wpa enterprise support). one of thoughts try wpa enterprise purpose. possible write simple script mimic radius server response, being positive, if credentials correct? another aspect of question security. if accepting password possible, wouldn't mean trick device connect ap same name, say, use @ home, , have control on traffic? can serious issue , better talk publicly pretending if don't publish way this, no 1 else same on black markets or in governments. upd: possible use simple captive portal 'negotiate...

python - Adding null=True , blank=True in custom model field -

i using custom modelfield language. snippet shown - from django.conf import settings class languagefield(models.charfield): def __init__(self, *args, **kwargs): kwargs.setdefault('max_length', 5) kwargs.setdefault('choices', settings.languages) super(languagefield, self).__init__(*args, **kwargs) def get_internal_type(self): return "charfield" i want allow null values language. so, know 1 thing have append ((none,"none"),) choices display none option in dropdown. how set null=true , blank=true field. language=languagefield(null=true,blank=true) doesnot works.it gives error column 'language' cannot null

linux - Rebuild shell script to case -

i want rebuild script little bit make more easier other people. think more easier case , functions. ip="192.168.123." #$1 last number ip-address regexp="^[0-9]+[-,0-9]*$" if [ "$#" -eq 0 ]; echo "no numbers given " exit 0 fi if [ "$1" == "-h" ]; echo "give numbers test" exit 0 fi i want make this: if [ "$#" -eq 0 ]; echo "no numbers given " # exit 0 --> have write this? case -h ) echo "give numbers test"; esac fi do have write exit? there things make easier? if statements inside case don't need exit case "$1" in '') echo no numbers given;; -h) echo give numbers test;; *) ... esac

java - Cannot send a GET request with RESTTemplate -

i need send request following http://server.com/server1/index.php?id=123&name=jack&date=12.1.2016 i using following code seems not send correct request response object empty. wondering how show complete url resttemplate sending? know wireshark can used there way retrieve using resttemplate? code string url = "http://server.com/server1/index.php?" map<string,string> vars = new hashmap<string,string>(); vars.put("id","123"); vars.put("name","jack"); vars.put("date","12.1.2016"); profile profile = resttemplate.getforobject(url,profile.class,vars); you can set log level org.springframework.web.client.resttemplate debug you'll output similar this: 12:11:22.072 [main] debug o.s.web.client.resttemplate - created request " http://echo.jsontest.com/key/value/one/two " 12:11:22.110 [main] debug o.s.web.client.resttemplate - setting request accept header [applica...

how to multiple login in one application like admin and employee in laravel -

i have 2 protected areas in 1 application admin user can login in both areas user (admin) , employee. please give me suggestion question. routes.php route::get('employee/login', array( 'uses' => 'logincontroller@create', 'as' => 'login.create' )); route::post('employee/login', array( 'uses' => 'logincontroller@store', 'as' => 'login.store' )); logincontroller.php <?php namespace app\http\controllers; use app\http\requests; use app\http\controllers\controller; use view; use illuminate\http\request; use input; use auth; use config; use redirect; use app\employee; use db; use validator; class logincontroller extends controller { public function __construct() { config::set('auth.model', 'employee'); config::set('session.path', '/employee'); } public function create() { return view::make('...

bash - Sed into Variable not working properly -

i trying strip except letters , delete letters less 3 characters in bash script... got delete words has 3 characters, other rules not applied. here's i'm using: name="the man u.n.c.l.e. official 2 2015 henry cavill armie hammer spy movie hd" keyword="$(sed -e 's/ [a-za-z]\{3\} / /g' <<< "$name")" desired output is echo $keyword shows the man official henry cavill armie hammer spy movie any kind of can on appreciated! try gnu sed: name="the man u.n.c.l.e. official 2 2015 henry cavill armie hammer spy movie hd" keyword="$(sed -e 's/\b(.{1,2}|[0-9]+)\b/ /g;s/ +/ /g' <<< $name)" echo "${keyword% }" output: man official henry cavill armie hammer spy movie

php - Extract only first level paragraphs from html -

i have following html: <div id="myid"> <p>i want this</p> <p>and want this</p> <div> <p>i don't want this</p> </div> </div> i want extract first level <p>...</p> elements. i've tried using excellent simple_html_dom library e.g. $html->find('#myid p') in case above, finds 3 <p>...</p> elements is there better way this? instead of having use external library why don't use built in classes handle dom? first create domdocument instance using html: $dom = new domdocument(); $dom->loadhtml($yourhtml); after use domxpath select elements: $xpath = new domxpath($dom); $nodes = $xpath->query("//*[@id='myid']/p"); var_dump($nodes->length); // outputs 2 this selects p elements direct children of element id myid . demo

mysql - Dynamic Drop Down AngularJS and Database with JSON -

i have figured out how populate first dropdown menu database angular, stuck on how grab selected value of first dropdown box query populate second box. also, if data in separate tables, have make api call everytime dropdown selected? have seen plenty of examples doing pre set tables, not actual api calls. confused. here have now. app.controller('selectoptgroupcontroller', function($scope,$http) { $http.get('api2.php'). success(function(data) { $scope.animals = data; }); $scope.species= []; $scope.getoptions2 = function(){ //not sure here }; }) html file <div ng-controller="selectoptgroupcontroller" class="md-padding selectdemooptiongroups"> <div> <h1 class="md-title">select animal</h1> <div layout="row"> <md-select ng-model="animals" placeholder=...

c# - Why do Chart Stacked Columns show up as thin lines? -

Image
i trying create stacked column chart 4 series in it. somehow, after populating series , making sure aligned, instead of columns, thin lines appears. code below. foreach (series s in chartevents.series) s.points.clear(); foreach (datarow dr in data.rows) { string reason = ""; double xval = 0; double yval = 0; double overflow = 0; double existflow = 0; try { reason = dr["reasonid"].tostring(); xval = math.round(convert.todatetime(dr["xvalue"].tostring()).tooadate(), 6); yval = math.round(convert.todouble(dr["duration"].tostring()) / 60, 3); overflow = 0; // assume tooltip prepared , format length here { overflow = 0; #region check if duration @ x value exceed 60 mins foreach (series s in chartevents.series) { if (s.points.count > 0) { foreach (datap...

ruby - ActiveRecord query to join Posts, post authors and likes in Rails 4 -

so, have read through quite few rails active records pages, stack o questions , answers (about 12 hours of time) trying figure out how heck tie of these things single query display them on page. here page view secrets owner info </h3> <% @secretinfo.each |i| %> <p><%= i.content %> - <%= i.first_name %></p> <p><%= i.created_at %></p> --> "this i'd have likes post" <-- <% end %> and here controller def show @user = user.find(params[:id]) @secrets = gossip.all @mysecrets = gossip.where(user_id: [params[:id]]) @secretinfo = gossip.joins(:user).select("content", "first_name", "created_at") @secretwlikesninfo = wtf mate? end also, may see models , schema here those class user < activerecord::base attr_accessor :password has_many :gossips has_many :likes has_many :liked_secrets...

html - give margin bottom inside dd class -

Image
i want give margin bottom them code shown below, <div class="dd" id="menu_list_drag"> <?php echo $li; ?> </div> where $li shown below, foreach ($p1 $p) { $inner_li = ""; $p2 = array_filter($menu, function($a)use($p) { return $a['parent_id'] == $p['id']; }); if ($p2) { $inner_li = $this->generate_li($menu, $p['id']); } $li .= "<li class='dd-item' data-id='" . $p['id'] . "' id='menu-list'><div menu-id='" . $p['id'] . "' id='drag' class='dd-handle'>" . $p['title'] . "<div style='float:right; margin-bottom:10px' class='dd-nodrag'>" . "<a class='btn-group btn-group-xs edit_menu' data-toggle='tooltip' id='...

android - How to solve Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 2 -

i created 1 project in eclipse mars,then gradle project , import android studio,in project not find issue,but when run application,it shows following error,and running process got stopped error process 'command 'c:\program files\java\jdk1.8.0_31\bin\java.exe'' finished non-zero exit value 2 myproject.gradle file apply plugin: 'com.android.application' dependencies { compile filetree(dir: 'libs', include: '*.jar') compile project(':android-support-v7-appcompat') compile project(':google-play-services_lib') compile project(':facebooksdk') } android { compilesdkversion 21 buildtoolsversion "21.1.2" compileoptions { sourcecompatibility javaversion.version_1_7 targetcompatibility javaversion.version_1_7 } sourcesets { main { manifest.srcfile 'androidmanifest.xml' java.srcdirs = ['src'] resourc...

javascript - readmore if giving the opposite response to what I expect -

i using readmore javascript in program , runs, answer not correct. when click on "see more" gives less output , when click on "less" 'see more'. ie showing opposite of should be. i tried changing code doesn't work properly. <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function() { // configure/customize these variables. var showchar = 50; // how many characters shown default var ellipsestext = "..."; var moretext = "show more >"; var lesstext = "show less"; $('.more').each(function() { var content = $(this).html(); if(content.length > showchar) { var c = content.substr(0, showchar); var h = content.substr(showchar, content.length - showchar); var html = c + '<span class="moreellipses">'...

3d - Does ol3-cesium accept DEM files? -

i'm using openlayers 3.6.0. want use ol3-cesium . ol3-cesium use cesium glob visualization. have question: in ol3-cesium, can see ups , downs of land? in other words accept dem files? the short answer yes, has pre-processed different format because dem files , other "raw" terrain data not suitable visualization. standard cesium quantized-mesh , support traditional height maps. premier application processing terrain cesium stk terrain server , commercial product. there other open source projects, of various quality, attempt generate terrain compatible cesium. disclaimer: i'm 1 of cesium cofounders , work company makes stk terrain server.

c++ - My code is returning two really weird errors -

my code isn't working. don't know why. errors getting don't make sense. 17 18 c:\users\the beast\desktop\case study phase 3.0.6.cpp [error] function-definition not allowed here before '{' token i dont know why throwing error. 77 1 c:\users\the beast\desktop\case study phase 3.0.6.cpp [error] expected '}' @ end of input ^ brackets present checked no idea why throwing error #include<iostream> #include<fstream> #include<string> #include<cstdlib> using namespace std; //loading libraries float const taxnet = .9; float const taxwh = .1; float employeenumber; float payrate=0; float gross=0; float net=0; float manhours=0; float overtime=0; float taxes=0; char usercontrols; void data_loop(char usercontrols); void writeworkerinfo(ofstream &stream, float employeenumber, float manhours, float payrate, float gross, float taxes, float net); void payrollcalc(float employeenumber, float manhours, float pa...

angularjs - Complex ng-repeat orderBy -

[{"score":"0.995074","content":"video games"},{"score":"0.950704","content":"media"},{"score":"0.916667","content":"arts & entertainment"}] with above data available on each single ng-repeat item, able sort score "content":"video games" . how can this? edit clarification: item 1 { property1: value1, property2: value2, ..., scores: [{"score":"0.9","content":"video games"},{"score":"0.8","content":"media"},{"score":"0.7","content":"arts & entertainment"}] } item 2 { property1: value1, property2: value2, ..., scores: [{"score":"0.7","content":"video games"},{"score":"0.8","content":"media"},{"score":...

c++ - How to Measure How Many Results App Can Produce Per Second -

i have 1 c++ app called idcreator takes 2 arguments produce ids. prints return value stdout ---- using printf ---- calling process fetches. now, wonder how many ids idcreator able produce per second (must done outside application), how can achieve this? is below code proper doing such job? there other way? string getid; getid.append("./idcreator arg1 arg2"); int count = 0; const int period = 100; const int len = 512; char buff[len] = {0}; time_t tick1 = time(null); while(1) { time_t tick2 = time(null); if ((tick2 - tick1) > period) break; file* res = popen(cmd.c_str(), "r"); if (res) { fgets(res, buff, sizeof(buf)); pclose(res); count++; } } printf("products per second is: %d", count/period); instead of creating function indepedently measure function time , doing fancy/complex stuff, suggest simple way. add logger/timers @ start , end of id generation m...