Posts

Showing posts from February, 2011

How could I view absent and present with unique color code in winform C# gridview -

i have table(payroll_attendancestatus) contains 4 columns ====================================== statusid | status | shortname | color ====================================== 01 | present| p | yellow 02 | absent | | red ======================================= from above mentioned table used mark day wise attendance table (payrollmarkattendance)and contains values ==================================================== markid | employee_code | statusid | datetime ==================================================== 1 | 001 | 01 | 2016-06-11 2 | 002 | 02 | 2016-06-11 ==================================================== for view using pivot table , code pivot table select * (select [employeename] ,[employee_code] ,[shortname], datename(m, [datetime])as [month] ,day([datetime]) [dayvalue] [view_payrollmarkattendance]) composite pivot (max([shortname]) [dayvalue] in ([1], [2], [3], [4],[5]

pip - Installing extra_requires with tox -

if want install requirements package being tested tox it? e.g. if testing package called websauna , want instal websauna[test] instead of websauna in tox.ini: [testenv] extras = test documentation

c# - ASP Label Replace new line -

Image
hello have label in project gets text database because label not support multline method need convert new lines tried using tweetlabel.text.replace(environment.newline, "<br />") not work. i'l add images showing problem. string.replace() returns new string. doesn't change string put method. therefore tweetlabel.text.replace() on own nothing. need change to: tweetlabel.text = tweetlabel.text.replace(environment.newline, "<br/>");

javascript - Preventing blank input not working -

i'm trying prevent blank input on editable list item, i'm using same code use somewhere else reason not working. i have: if(foldername == "" || foldername == " " || foldername.charat(0) == " "){ $(this).remove(); } it removing item if not type anything, though if enter blank space doesn't call remove. strange thing using exact same code in different area , it's working fine. here full function: $(document).on('focusout', '#folders li', function(){ //add class when lose focus/shorten name if long var foldername = $(this).text(); $('#folders li').removeattr('contenteditable'); $('#folders li').removeclass('active-tab'); $(this).addclass('active-tab'); if(foldername.length > 15){ $(this).attr('title', $(this).text()); shortfoldername=foldername.substring(0,15) + '...'; $(this).text(shortfoldername);

javascript - Cancelling the anchor when clicking on a div inside the anchor -

Image
i have anchor element in html: <a class="info-tiles tiles-inverse has-footer" href="somepage.html?id=15"> <div class="tiles-heading"> <div class="pull-left">it department - hosting environment</div> </div> <div class="tiles-body"> <div class="nav-justified" style="font-size: small;">started: 19-05-2015 07:00</div> <div class="btn btn-sm btn-default pull-right">ae</div> <div class="btn btn-sm btn-default pull-right">pj</div> <div class="btn btn-sm btn-default pull-right">sl</div> </div> <div class="tiles-footer"> <div class="progress"> <div class="progress-bar progress-bar-info" style="width: 20%"></div> </div> </div> </a> this code renders this: the behavior ok

javascript - How does this callback call work in Node.js with mongo .find call -

models/category.js var mongoose = require('mongoose'); // category schema var categoryschema = mongoose.schema({ title: { type: string }, description: { type: string }, created_at: { type: date, default: date.now } }); var category = module.exports = mongoose.model('category', categoryschema); // categories module.exports.getcategories = function(callback, limit) { category.find(callback).limit(limit).sort([['title', 'ascending']]); } routes/categories.js var express = require('express'); var router = express.router(); category = require('../models/category.js'); router.get('/', function(req, res, next) { category.getcategories(function(err, categories) { if (err) res.send(err); res.render('categories', { title: 'categories', categories: categories }); }); }); router.post('/add', function(req,res) { res.send('form

integer - Is there a way to determine the size of BLAS IDAMAX function? -

i determine size of integer function idamax in blas fortran library. can either 4-bytes (i32lp64 model) or 8-bytes (ilp64). knowing size can determine overall integer declaration (integer*4 or integer*8) in prebuild blas library. the problem sizeof(*idamax_(&n, dx,&incx)) of program below returning 4, though expect 8 mkl-integer*8 blas. any comments, please ? #include <stdio.h> void main() { extern * idamax_(); // external fortran blas function idamax int n=2; int incx=1; //long n=2; long incx=1; double dx[2]; dx[0]=1.0; dx[1]=2.0; printf("sizeof(n)=%i\n",sizeof(n)); printf("sizeof(*idamax_(&n, dx, &incx))=%i\n",sizeof(*idamax_(&n, dx,&incx)) ); // still returns 4 !!! //printf("sizeof(idamax_(&n, dx, &incx))=%i\n",sizeof(idamax_(&n, dx, &incx)) ); // idamax call crashes wrong integer sizes - mkl, gnu ibblas.a ! same fortran idamax_(&n, dx, &incx); } your code not determining functi

c# - Replace a variable in a JSON string -

i have json file containing dialogue rpg i'm making, , i'd able place players chosen name in comes up. example if player's name public string playername = "leon"; and in json had "npcidxxgreeting":{ "text": "yo, _____, what's up?" } i'd able insert "leon" wherever blank space showed in dialogue json. there way this? .net supports json converting. read in file contents , parse json information. example public class stats { public int attack; public string playername; public float speed; ...... } public static list<string>getjson() { using (streamreader r = new streamreader("file.json")) { string json = r.readtoend(); list<stats> stats = jsonconvert.deserializeobject<list<stats>>(json); return stats ; } }

MySQL - Use derived column names in the subsequent comparisons -

i have following 2 tables: (i apologise being unable paste them here, have created snapshot , given link it): table exams +---------+------------+-------------+ | exam_id | exam_date | description | +---------+------------+-------------+ | 1 | 2016-06-01 | exam 1 | | 2 | 2016-06-06 | exam 2 | | 3 | 2016-06-07 | exam 3 | | 4 | 2016-06-10 | exam 4 | +---------+------------+-------------+ table subjects +------------+---------+-------------+ | subject_id | exam_id | result | +------------+---------+-------------+ | 1 | 1 | attended | | 2 | 1 | fail | | 3 | 2 | distinction | | 4 | 2 | distinction | | 5 | 3 | pass | | 6 | 3 | distinction | | 7 | 4 | attended | | 8 | 4 | pass | +------------+---------+-------------+ the possible values in &q

swing - Game in java: rotating selected object -

i'm developing java game study purposes. want player select object. selected object can move, others (non-selected objects) must not move. game.java: import javax.swing.jframe; public class game { public static void main(string[] args) { jframe frame = new jframe("kibe"); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setcontentpane(new gamepanel()); frame.pack(); frame.setvisible(true); } } gamepanel.java: import javax.swing.jpanel; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.util.*; public class gamepanel extends jpanel implements runnable, keylistener { // fields public static final int width = 640, height = 480; private thread thread; private boolean running; private int fps = 30; private double averagefps; private bufferedimage image; private graphics2d g; public arraylist<circle> circles; private int selec

configuration - what is SQL Server 2012 required memory for bigger databases -

i reading through this msdn document check whether servers resources enough or not. found interesting requirements not have further clarification online, recommended: @ least 4 gb , should increased database size increases ensure optimal performance. can body give more information on how memory should increase when data increase? (ex: each 10gb we'll need 1gb of memory or each 100 table/sp we'll need additional gb) there not answer question. required memory depends on many factors , 1 of them database size. number of users, volume of server request, concurrency, codes (like etl , procedures) , many more factors involved. the right way find out how memory need, monitoring server using tools , performance monitor on windows. you need see if memory bottleneck or not. if bottleneck disk , cpu or network bandwidth, adding more memory won't , not required. edit: data size alone doesn't mean anything. may have terabyte database reports , a

python - New to programming and trying to finish this task for school, I can't seem to add numbers in a list together -

i have bit of code thats task have complete school. i'm trying add numbers in list can average number. whenever try tells me unsupported operand type int , str. think have convert inputs floats rather strings i'm not sure how to. code below: final = false while final == false: judgescoreforloop = 0 judgescoreloop = [] while true: try: eventname = str(input("what event's name? ")) numberjudges = int(input("how many judges there? ")) competitorname = str(input("what competitor's name? ")) judgescoreforloop in range (0, numberjudges): judgescore = input("enter judge score here: ") judgescoreloop.append(judgescore) judgescoreforloop + 1 break except valueerror: print("one of inputs invalid, please try again.") finaljudges = numberjudges - 2 judgescorecombined =

continuous integration - Pull only latest changes from SVN -Jenkin build -

i working jenkins ci , have connected svn repository files on build. facing 2 issues here. i need changed files -not whole set of files. i don't need project files files needed deploy (code files should excluded). .pubxml have parameters exclude it. while fetching svn jenkin pulls files , jenkin ftp plugin can points workspace. need upload files needed release. jenkin workspace contains files have in svn. there option restrict this? you want have powershell or batch script @ point determine files need throw out. suggest pulling down , throwing out files not need. can determine such files running magic svn command line utility. go through documentation see how can run diff receive list of changed files.

objective c - Initialising CoreData in AppleScript-objc -

i'm trying write , read coredata on osx, combinig cocoa classes applescript-objc. wrote methods handle coredata in tutorial ( youtube, cocoa tutorial: core data introduction in ios , mac os programming part 2 ) <- cocoa classes in project i have class called coredatahelper defines methods manipulate core data. here of them: +(nsmanagedobjectcontext *) managedobjectcontext{ nserror*error; [[nsfilemanager defaultmanager] createdirectoryatpath:[coredatahelper directoryfordatabasefilename] withintermediatedirectories:yes attributes:nil error:&error]; if(error){ nslog(@"%@", [error localizeddescription]); return nil; } nsstring* path = [nsstring stringwithformat:@"%@/%@",[coredatahelper directoryfordatabasefilename],[coredatahelper databasefilename]]; nsurl *url = [nsurl fileurlwithpath:path]; nsmanagedobjectmodel* managedmodel = [nsmanagedobjectmodel mergedmodelfrombundles:nil]; nspersistentstorecoordi

javascript - Parser blocking vs render blocking -

i've been reading google developers documentation on optimizing web performance. i'm little confused terminology used there. both css , javascript files block dom construction. but, css called render-blocking whereas javascript called parser-blocking. difference in 'parser-blocking' , 'render-blocking' terms? or same , terminology interchangeably used? imagine html page has 2 <script src="..."> elements. parser sees first one. has stop* parsing while fetches , executes javascript, because might contain document.write() method calls fundamentally change how subsequent markup parsed. fetching resources on internet comparatively slower other things browser does, sits waiting nothing do. js arrive, executes , parser can move on. sees second <script src="..."> tag , has go through whole process of waiting resource load again. it's sequential process, , that's parser blocking. css resources different. when pars

ruby - google books api conflicts with isbn number -

i'm building library retrieve informations googlebooks api.. works pretty good.. although have problem risks screw aim of web app. apparently googlebooks doesn't read isbn of book searched , gives me informations different book different isbn have no idea from. for example search book "emma" jane austen; got list books available title; clicked on 1 of them has isbn 9780987072269 , got book : "fundamentals of rf , microwave transistor amplifiers" isbn 9780470462317 . why happen? there way correct it? my code @texts = googlebooks.search(params[:isbn_13]) @texts.each |text| @book_title = text.title @book_author = text.authors @book_year = text.published_date @book_cover = text.image_link(:zoom => 2) @book_page_count = text.page_count @book_notes = text.description @book_type = text.categories @book_isbn = text.isbn_13 end into views retrieve list of books same title <div class=

java - Heroku Webapp CRASHING when process type is configured in pom.xml -

Image
i creating web service , using embedded tomcat in application. this, i've implemented main class(main.java) tomcat server instance created. now deploying application on heroku, using maven plugin. in configuration tag i've given process type as: <processtypes> <web>java $java_opts -cp target/classes:target/dependency/* main</web> </processtypes> when deployed, app crashed saying main class not found, i've kept main.java in root directory.do need make changes in command? above eclipse directory structure. it looks main.java not in maven src directory. doubt it's being compiled maven (but eclipse compile it). try moving main.java file src/main/java directory.

algorithm - Union-Find operations on a tree? -

Image
can please explain answer in bold? how it's done? below sequence of 4 union-find operations (with weighted-union , full com- pression) led following up-tree. last 2 operations? answer: union(d,a), union(b,c), union(d/a,b/c),find(b/c). the notation used because of sets . let apply 4 operations: union(d,a) leads following tree: d / union(b,c) leads following tree: b / c now union(d/a,b/c) means because d , belong same set , not matter first argument is, can d or can a . because b , c belong same set , not matter second argument is, can b or can c , the result same . the result after third operation: d / \ b \ c now because compression allowed, find(c) operation result in tree: d /|\ b c if fourth operation find(b) , tree remain same, because when apply compression after find operation, make nodes encountered in path upto root immediate child of root, since not encounter c , not able make c immedia

cmake - About Magick++, how to write the CMakeLists? -

everyone. there cmakelists. cmake_minimum_required(version 3.5) project(blah) set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11") set(source_files main.cpp) add_executable(blah ${source_files}) find_package(imagemagick) find_package(imagemagick components magick++) find_package(imagemagick components convert) find_package(imagemagick components magick++ convert) include_directories(${imagemagick_include_dirs}) target_link_libraries(blah ${imagemagick_libraries}) and code looks this. #include <iostream> #include <magick++.h> using namespace std; int main(int argc, char **argv) { magick::image image("640*480", "white"); } it reports errors undefined reference 'magick::color::color(char const*)' . , solution seems should write g++ 'magick++-config --cxxflags --cppflags' -o example example.cxx 'magick++-config --ldflags --libs' . sadly, don't know how write correct cmakelists' items it, or,

c# - convert byte array to 16 bits float -

i have network array of 2 bytes need convert float [values between -1 ... 1-2.e(-15)] examples : byte[] arr1={0x70 , 0x54} //==> result = 0.660 byte[] arr2={0x10 , 0x37} //==> result = 0.430 any solutions overpass ? what standard have used gave {0x70 , 0x54} ? i have made sample code half-precision floating point conversation according ieee 754-2008 standard. https://en.wikipedia.org/wiki/half-precision_floating-point_format public static float totwobytefloat(byte ho, byte lo) { var intval = bitconverter.toint32(new byte[] { ho, lo, 0, 0 }, 0); int mant = intval & 0x03ff; int exp = intval & 0x7c00; if (exp == 0x7c00) exp = 0x3fc00; else if (exp != 0) { exp += 0x1c000; if (mant == 0 && exp > 0x1c400) return bitconverter.tosingle(bitconverter.getbytes((intval & 0x8000) << 16 | exp << 13 | 0x3ff), 0); } else if (mant != 0) { exp = 0x1c400;

ios - How to calculate same substring from given entire NSString -

i wan calculate total white space in given string.if total white space more 1 want replace 2nd number of space "\n" for example: my string : "i iphone" . string contains 3 space. want o/p "i \niphone". this example. string not static. give string dynamic how can implement ?? thanks in advance nsstring *givenstring = @"i iphone ok"; nsarray *stringarray = [givenstring componentsseparatedbystring:@" "]; nsstring *string = @""; (int = 0; i<stringarray.count; i++) { string = i==2 ? [nsstring stringwithformat:@"%@\n%@",string,stringarray[i]] : [nsstring stringwithformat:@"%@ %@",string,stringarray[i]]; } nslog(@"%@",string); hope helps!

php - Results that include space don't get fetched -

this code used results of different category names. here, if category names have space result won't displayed while names without having spaces displayed. this code: <ul> <li><a href="<?php echo base_url();?>clients">view </a></li> <?php foreach($clientdropdown $row){?> <li class="<?php if($active_mn== $row->id) echo 'active'; ?>"> <a href="<?php echo base_url();?>client/<?php echo $row->category_name;?>"> <?php echo $row->category_name;?> <span></span> </a> </li> <?php }?> </ul> i'm little bit confused use replace() avoid spaces. i had changed code please see having looked @ trying in edited code, problem had isn't $row->category_name won't fetch. space in url not being encoded page won't redirect correctly.

php - How to insert data to table ,before save create user and use id user for table prime (yii2)? -

i have table student , table user user_id foreign key table student. want save information student , create user , set id user user_id in table student student models: class student extends \yii\db\activerecord { public $username; public $password; public $email; ...... public function rules() { return [ [['name', 'lastname', 'tell', 'mobile', 'codemeli', 'birthday' , 'jensiyat', 'address', 'fathername', 'user_id', 'created'], 'required'], [['tell', 'mobile', 'codemeli', 'postcode', 'number', 'user_id', 'salary', 'remove'], 'integer'], ['address', 'string'], ['pic','file'], ['username','string'], ['password','string'], ['email','string'], [['username','passw

Purpose of using union within structure in c -

typedef struct { int k; union { int i; int j; }use; }std; directly can use variable , j in structure why used within union. in example, i.e. typedef struct { int k; union { int i; int j; }use; }std; it doesn't seem make sense i , j same type , names of variables isn't descriptive. it can make sense have same type union elements if make code easier write, read, understand , maintain. example: ... union { int numberofcars; int numberofbicycles; }use; ... when writing code handling cars use numberofcars , when writing code handling bicycles use numberofbicycles . in way code easier understand/maintain , 2 code blocks still share common structure. in 1 code block have: std cardealer; cardealer.use.numberofcars = 9; and in code block (other file perhaps), have: std bicyclesdealer; bicyclesdealer.use.numberofbicycles = 9; a more typical case unions elements of different type.

sharedpreferences - Declared Shared Preferences in Android causes error when run on Android device? -

the ide doesn't seem detect error. when system run on physical device, system crashes when gets class. seems problem? shared preferences declared? how can fix this? package com.example.mobile_app; import android.os.bundle; import android.app.activity; import android.content.sharedpreferences; import android.view.menu; import android.view.window; import android.widget.textview; public class post_4 extends activity { static int time = post_1.gettime(), post_error = post_3.get_pos_err(); int percent; float quotient_float = (float)post_error/(float)time; float computation=0; sharedpreferences value = getapplicationcontext().getsharedpreferences("values", mode_private); sharedpreferences.editor editor = value.edit(); textview percentage_display; @override protected void oncreate(bundle savedinstancestate) { requestwindowfeature(window.feature_no_title); super.oncreate(savedinstancestate);

java - Spring LDAP Authentication -

i have made spring mvc user login java application, want user login authenticated using openldap ? can explain procedure ? i think tutorial helpful you.

image - How do I calculate the width and height of a bitmap from this file header? -

00000000 42 4d 3a fe 05 00 00 00-00 00 36 04 00 00 28 00 00000010 00 00 d1 02 00 00 1d 02-00 00 01 00 08 00 00 00 00000020 00 00 04 fa 05 00 13 0b-00 00 13 0b 00 00 00 00 what values of width , height? according wikipedia - bmp file format offset (hex) offset (dec) size (bytes) windows bitmapinfoheader[1] 0e 14 4 size of header (40 bytes) 12 18 4 bitmap width in pixels (signed integer) 16 22 4 bitmap height in pixels (signed integer) with bitmap header posted, width , height be width: d1 02 00 00 height: 1d 02 00 00 the wikipedia link above states that all of integer values stored in little-endian format (i.e. least-significant byte first). if understanding correct, converts to width = 209 + (2 x 256) + (0 x 256^2) + (0 x 256^3) = 721 height = 29 + (2 x 256) + (0 x 256^2) + (0 x 256^3) = 541

php - POST request with data specified in text file via CURL? -

i have simple cms based on css,html , php witout db. made curl script update content, including templates (mix of text , html) via post. curl_setopt ($upload, curlopt_postfields, $postfields); and &postfields: $postfields["person"] = "kris"; $postfields["action"] = "update"; $postfields["page"] = "name of page"; $postfields["newcontent"] = $post; + $post=file_get_contents("update.txt"); what need send via post data specified in text file (update.txt) including mix of html/css/php.i don't want upload single file post content idea? :) thanks! updated using questions field names , setting mimetype file according send file via post curl , php , php manual following: $file_name_with_full_path = realpath('update.txt'); $postfields = array('person' => 'kris', 'action' => 'update', 'page' => &#

c++ - std::function implicit type conversion -

using g++ (ubuntu 4.8.5-1ubuntu1) 4.8.5 , compiling g++ -std=c++11 -wall -wextra -wconversion the following not compile expected: template <typename t> struct foo { foo(t t) {} }; struct bar { bar(foo<float> foo) : foo(foo) {} //trying convert foo<float> foo<double> foo<double> foo; }; the following compiles warning -wconversion , expected: void foo(float t){} int main() { foo(3.141592653589794626); return 0; } however, following compiles no warnings : #include <functional> void foo(double t){} struct bar { bar(std::function<void(float)> foo) : foo(foo) {} //convert std::function<void(float)> std::function<void(double)> std::function<void(double)> foo; }; int main(){ bar bar(foo); //convert std::function<void(double)> std::function<void(float)> bar.foo(3.141592653589794626); //rounded to: 3.141592741012573 foo(3.141592653589794626); //not rounded:

javascript - How do I display the code as plain text -

this code : <!doctype html> <html> <head> <p id="x"></p> <p id="y"></p> <style> </style> </head> <body> <button id="btn">click me!</button> <script src="jquery/jquery1.12.js"></script> <script> var txt = '<!doctype html>\ <html>\ <head>\ </head>\ <body>\ <script>\ alert("ok");\ </script>\ </body>\ </html>'; $(document).ready(function(){ $("#btn").click(function(){ $("#x").text(txt); }) }) </s

c# - How can I set the COM apartment state for code loaded with `AppDomain.ExecuteAssembly`? -

when create thread , have option of setting com apartment state explicitly before start it. example: // using system.threading; var thread = new thread(…); thread.setapartmentstate(apartmentstate.sta); thread.start(); but when create appdomain , load code it, seem have no explicit control on thread creation, have no way of calling setapartmentstate : // using system; var pluginappdomain = appdomain.create("pluginappdomain"); pluginappdomain.executeassembly(@"plugin.dll"); is there way specify main/entry thread created inside appdomain should use specific com apartment state? i know plugin.dll 's main entry method marked [stathread] or [mtathread] attribute; let's assume plugin.dll not explicitly declare or set com apartment state, , cannot change plugin.dll . i re-posting hans passant's comment above answer since answers of question: "no, creating [app domain] not create thread. executing state of thread made appdom

html - Hidden <ul> vanishes while hovering between <li> to it -

below have hidden <ul> appears when <li> 'more' hovered over. due margin of <li> , <ul> dissapears when hovering between 'extras' , <ul> - how prevent happening? #container ul { list-style: none; margin: 0px; padding: 0px; } #container li { color: #fff; width: 80px; height: 60px; float: left; line-height: 60px; margin: 10px; background: black; } #container li { display: block; } .extras:hover > ul.hidden { display: block; } ul.hidden { display: none; } <div id="container"> <div class="center" style="text-align: center; display: inline-block;"> <nav> <ul class="nav"> <li>example 1</li> <li>example 2</li> <li class="extras">more <ul class="hidden"> <li>hoverable</li>

html - custom layout with bootstrap, form lacking responsiveness -

i have bootstrap layout consisting of left column sidebar , right column main content area. my sidebar has min-width: 260px; max-width: 260px; , main content has width:calc(100% - 260px); now main content form, can see when decrease browser width (view in full screen , decrease), elements decrease in-sync browser , forces labels drop down , makes form-controls overlap labels , each of buttons text overflows outside boundary, , looks ugly. is there simple method can do, in keeping sidebar width, make form respond nicer when browser decreased until hits 992px breakpoint (goes mobile view)? i have tried various ways myself using media queries, finding challenging regarding layout , including proper breakpoints. html * { box-sizing: border-box; } html, body { font-family: 'lato-black', verdana, sans-serif; background-color: #fff; color: #fff; font-size: 14px; height: 100%; } /* ------ ------ general styles -------------------------------