http://ift.tt/1NmaMtn
I Have user control i set him background, but the problem is that the background hide the controls inside of him
via Chebli Mohamed
http://ift.tt/1NmaMtn
I Have user control i set him background, but the problem is that the background hide the controls inside of him
Is it possibile with EasyMock during the register phase to register a method call whose arguments is a mock? E.g:
String s = 'a string';
ClassA a = createMock(ClassA.class);
ClassB b = createMock(ClassB.class);
ClassC c = createMock(ClassC.class);
expect(c.bFactoryMethod()).andReturn(b);
a.someMethod(s, b);
replayAll();
ClassToTest toTest = new ClassToTest();
toTest.wrapperMethodThatCallsSomeMethod(s);
verifyAll();
EasyMock complains about:
java.lang.IllegalStateException: missing behavior definition for the preceding method call
I am trying to make regex for email my regex is:
^(?:[0-9a-zA-z.!!@#$%^&*+={}'/-]+@[a-zA-Z]{1}[a-zA-Z]+[/.][a-zA-Z]{2,4}|)$
According to this regex it should accept special characters as mentioned in rule but should not accept [ and ] but it accepting [ and ].
I want to use this regex but it should exclude [ and ].
I have just used Log.d(); statement to debug my app and for this I created a filter configuration. I got it working so that it shows the feedback.
But Now I deleted this Log.d(); from my app. But I can't access the Logcat Information as I got earlier. It's not a error. I just want to get my logcat as I used before Log.d(); statement.
I'm following a tutorial from Oracle, and in the last step I'm trying to execute a SQL script where I get the errors from DECLARE and end-of-file. Any idea where I went wrong? The following is the script:
create or replace
PROCEDURE ENQUEUE_TEXT(
payload IN VARCHAR2 )
AS
enqueue_options DBMS_AQ.enqueue_options_t;
message_properties DBMS_AQ.message_properties_t;
message_handle RAW (16);
user_prop_array SYS.aq$_jms_userproparray;
AGENT SYS.aq$_agent;
header SYS.aq$_jms_header;
MESSAGE SYS.aq$_jms_message;
BEGIN
AGENT := SYS.aq$_agent ('', NULL, 0);
AGENT.protocol := 0;
user_prop_array := SYS.aq$_jms_userproparray ();
header := SYS.aq$_jms_header (AGENT, '', 'aq1', '', '', '', user_prop_array);
MESSAGE := SYS.aq$_jms_message.construct (0);
MESSAGE.set_text (payload);
MESSAGE.set_userid ('Userid_if_reqd');
MESSAGE.set_string_property ('JMS_OracleDeliveryMode', 2);
--(header, length(message_text), message_text, null);
DBMS_AQ.enqueue (queue_name => 'userQueue', enqueue_options => enqueue_options,
message_properties => message_properties, payload => MESSAGE, msgid => message_handle );
COMMIT;
END ENQUEUE_TEXT;
DECLARE
PAYLOAD varchar2(200);
BEGIN
PAYLOAD := 'Hello from AQ !';
ENQUEUE_TEXT(PAYLOAD => PAYLOAD);
END;
I am in a situation where I will have a lot of numbers around about 0 - 15. The vast majority are whole numbers, but very few will have decimal values. All of the ones with decimal value will be "#.5", so 1.5, 2.5, 3.5, etc. but never 1.1, 3.67, etc.
I'm torn between using float and int (with the value multiplied by 2 so the decimal is gone) to store these numbers.
Because every value will be .5, can I safely use float without worrying about the wierdness that comes along with floating point numbers? Or do I need to use int? If I do use int, can every smallish number be divided by 2 to safely give the absolute correct float?
Is there a better way I am missing?
I'm not considering double because I don't need that kind of precision or range.
I'm storing these in a wrapper class, if I go with int whenever I need to get the value I am going to be returning the int cast as a float divided by 2.
When calling textView becomeFirstResponder from cellForRowAtIndexPath returns false, why?
But from other method i.e. from didSelectRowAtIndexPath it works.
Is it in connection that I am using iOS 8 introduced UITableViewAutomaticDimension row height approach?!
I want to scrolling view when navigationItem clicked. But..here is some error.
I want to make snapchatlike scroll view. It works fine, but... when I call scrollView out of viewdidload function, scrollView is nil!
I already make snapchat like swipe view. but I want to make swipe view when navigation Item(heart mark) clicked.
My ViewController viewdidload func - it works fine
@IBOutlet weak var scrollView: UIScrollView!
var V1 : LeftViewController = LeftViewController(nibName: "LeftViewController", bundle: nil)
var V2 : CenterViewController = CenterViewController(nibName: "CenterViewController", bundle: nil)
var V3 : RightViewController = RightViewController(nibName: "RightViewController", bundle: nil)
override func viewDidLoad() {
super.viewDidLoad()
self.addChildViewController(V1)
self.scrollView.addSubview(V1.view)
V1.didMoveToParentViewController(self)
self.addChildViewController(V2)
self.scrollView.addSubview(V2.view)
V2.didMoveToParentViewController(self)
self.addChildViewController(V3)
self.scrollView.addSubview(V3.view)
V3.didMoveToParentViewController(self)
var V2Frame : CGRect = V2.view.frame
V2Frame.origin.x = self.view.frame.width
V2.view.frame = V2Frame
var V3Frame : CGRect = V3.view.frame
V3Frame.origin.x = 2 * self.view.frame.width
V3.view.frame = V3Frame
println(self)
println(scrollView)
println(V2.view.frame)
self.scrollView.setContentOffset(CGPointMake(V2Frame.origin.x, self.view.frame.size.height), animated: false)
self.scrollView.contentSize = CGSizeMake(self.view.frame.width * 3, self.view.frame.size.height) }
My ViewController clickEvent func - why scrollView is nil?
func clickEvent() {
V2.view.frame = CGRect(x: 375.0, y: 0.0, width: 320.0, height: 568.0)
let scrollView = UIScrollView(frame: CGRect(x: 0.0, y: 0.0, width: 320.0, height: 568.0))
self.scrollView?.scrollRectToVisible(V2.view.frame, animated: true)
println(self)
println(scrollView)
println(V2.view.frame)
//self.scrollView.setContentOffset(CGPointMake(V2.view.frame.origin.x, self.view.frame.size.height), animated: true)
}
I call clickEvent in Viewcontroller from other CenterViewController - it can call fine but...in ViewController clickEvent functions' scrollView is nil.. How can I fix it?
func clickEvent(sender: AnyObject) {
ViewController().clickEvent()
}
Using Java FX 8, I have two text fields and a button to validate. I want this button to be disabled until both fields have a valid value.
What is the best way to do this ?
Thanks,
We are trying to test our IBM MobileFirst Platform Foundation-based mobile application with IBM Rational Test Workbench MobileTest version 8.7.
One issue we are running into is that the testing fails due to application authenticity tests failure when trying to test against a remote worklight server. We tried to test it locally and that works. However, we are wondering if turning off the app authenticity is the only way to test using a remote worklight server. If anyone knows of any setting etc to get around the issue without having to turn off app authenticity every time we test on a pre-production build ( using remote server ) please let us know. It will be a great help.
I have a problem with for loop in batch script. When I try:
for /f "delims=;" %g in ('dir') do echo %g%
i see this
'dir' is not recognized as an internal or external command,
operable program or batch file.
Did I miss somethig? Why windows command doesn't work?
Is it possible to create a basic single page web page which doesn't get stored into a users browser cache?
Or
Is it possible to create a basic single page web page which deletes itself from the users browser cache?
I understand that such a page can't be fool proof because the user could simply take a screenshot to capture the data on the web page.
So I have scoured the internet to put together this small macro, but I haven't had any luck figuring out what I'm doing wrong. I know the answer is going to be simple, but it certainly beyond me. The goal is to have a checkbox insert several rows from a separate sheet, then delete those same rows if you uncheck the box. The copy and insert functions are working perfectly, but I do not know how to write the line for the range of rows to delete. The Code below is obviously not correct, because rngD is specified for testing. rngD should be the 7 rows below the check box, or maybe there is a better way to do it. Thanks a lot for checking this out, and I'm open to any constructive criticism.
Working in Excel 2013
Sub Insert_LL()
Dim ws As Worksheet
Dim chkB As CheckBox
Dim rngA As Range
Dim rngD As Range
Dim lRow As Long
Dim lRowD As Long
Dim llRows As Range
Set llRows = Range("Lesson_Learned")
Set ws = ActiveSheet
Set chkB = ws.CheckBoxes(Application.Caller)
lRow = chkB.TopLeftCell.Offset(1).Row
lRowD = chkB.TopLeftCell.Offset(7).Row
Set rngA = ws.Rows(lRow)
Set rngD = ws.Rows("18:24") 'needs to specify the range of rows dependant where the checkbox is located'
Application.ScreenUpdating = False
Select Case chkB.Value
Case 1
llRows.Copy
rngA.Insert Shift:=xlDown
Case Else
rngD.Delete
End Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Very new to VBA. I need to copy all paid account numbers into Column A of the current sheet. The Accounts sheet has the account numbers in column A and in column B either "Paid" or "Unpaid". I just keep getting error after error and I'm not sure if I'm fixing it or making it worse, but the last error I couldn't get past was for the line Cells(t,1).Value =i: "Application Defined or Object Defined Error."
Sub Button1_Click()
Dim t As Integer
Dim i As Range
Dim sheet As Worksheet
Set sheet = ActiveWorkbook.Sheets("Accounts")
Dim rng As Range
Set rng = Worksheets("accounts").Range("A:A")
'starting with cell A2
target = 2
'For each account number in Accounts
For Each i In rng
'find if it's paid or not
If Application.WorksheetFunction.VLookup(i, sheet.Range("A:B"), 2, False) = "PAID" Then
'if so, put it in the target cell
Cells(t, 1).Value = i
t = t + 1
End If
Cells(t, 1).Value = i
t = t + 1
Next i
End Sub
I'm trying to implement the NSCoder, but am currently facing a stubborn issue. My goal is to save the array of strings via NSCoder to a local file and load it when the app opens next time.
Here is the class i've created, but i'm not sure how i should handle the init and encoder functions:
class MyObject: NSObject, NSCoding {
var storyPoints: [String] = []
init(storyPoints : [String]) {
self.storePoints = storePoints
}
required init(coder decoder: NSCoder) {
super.init()
???
}
func encodeWithCoder(coder: NSCoder) {
???
}
}
Moreover, how do i access it in my view controller? where should i declare a path for saving the NSCoder? It's not really clear enough.
Looking forward to any advices.
Thank you.
I have an object with a couple decades of settings, some settings depend on other settings, so, I need to observe if some setting changed.
import Ember from 'ember';
export default Ember.Controller.extend({
allPermissionChanged: function () {
alert('!');
}.observes('hash.types.[].permissions'),
permissionsHash: {
orders:{
types: [
{
label: 'All',
permissions: {
view: true,
edit: false,
assign: false,
"delete": false,
create: true
}
},
}
],
permissions:[
{
label:'Просмотр',
code:'view'
},
{
label:'Редактирование',
code:'edit'
},
{
label:'Распределение',
code:'assign'
},
{
label:'Удаление',
code:'delete'
},
{
label:'Создание',
code:'create'
}
]
}
}
});
Next I try to bind each setting to input
<table class="table table-bordered">
<thead>
<tr>
{{#each hash.types as |type|}}
<th colspan="2">{{type.label}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each hash.permissions as |perm|}}
<tr>
{{#each hash.types as |type|}}
{{#if (eq (mut (get type.permissions perm.code)) null)}}
<td> </td>
<td> </td>
{{else}}
<td>{{perm.label}}</td>
<td>{{input type="checkbox" checked=(mut (get type.permissions perm.code)) }}</td>
{{/if}}
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
But observer doesn't work.
Also I prepared Jsbin example - http://ift.tt/1NmaLWj
I'm fairly new to AngularJS and am trying to put together a small demo application. The part I'm trying to get working is as follows:
Code
Directives
financeApp.directive('watchlistItem', function () {
return {
restrict: 'E',
templateUrl: 'app/directives/watchlistItem.html',
replace: true,
scope: {
asxCode: "@"
}
}
});
financeApp.directive('myAddCodeButton', ['$compile', '$resource', function ($compile, $resource) {
return function(scope, element, attrs){
element.bind("click", function () {
scope.financeAPI = $resource('http://ift.tt/1qXLaIk', {callback: "JSON_CALLBACK" }, {get: {method: "JSONP"}});
//scope.financeResult =
scope.financeAPI.get({q: decodeURIComponent('select%20*%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22' + scope.asxcodeinput + '.AX%22)'),
format: 'json', env: decodeURIComponent('store%3A%2F%2Fdatatables.org%2Falltableswithkeys')})
.$promise.then(function (response) {
scope.quote = response.query.results.quote;
console.log(scope.quote);
angular.element(document.getElementById('watchlistItemList')).append($compile("<watchlist-item asx-code=" + scope.quote.Symbol + "></watchlist-item")(scope));
}, function (error) {
console.log(error);
});
});
};
}]);
Directive Template
<div class="watchItem">
<a href="#/{{asxCode}}">
<div class="watchItemText">
<p class="asxCodeText"><strong>"{{asxCode}}"</strong></p>
<p class="asxCodeDesc"><small></small></p>
</div>
<div class="watchItemQuote">
<p class="asxPrice lead"></p>
<p class="asxChangeUp text-success"></p>
</div>
</a>
</div>
HTML
<html lang="en-us" ng-app="financeApp">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta charset="UTF-8">
<title>ASX Watchlist and Charts</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://ift.tt/1K1B2rp">
<link rel="stylesheet" href="css/styles.css">
<script src="http://ift.tt/1FBSnCz"></script>
<script src="http://ift.tt/1NmaLWh"></script>
<script src="http://ift.tt/1FBSkGR"></script>
<script src="app/app.js"></script>
</head>
<body>
<div class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#/">ASX Watchlist and Charts</a>
</div>
</div>
</div>
<div class="container-fluid" id="mainContainer">
<div class="row">
<div class="floatLeft" id="leftDiv" ng-controller="navController">
<form class="inline-left">
<div class="form-group floatLeft">
<label class="sr-only" for="asxinput">ASX Code</label>
<input type="text" class="form-control" id="asxinput" placeholder="ASX Code" ng-model="asxcodeinput" />
</div>
<button class="btn btn-default floatRight" my-add-code-button>Add</button>
</form>
<div id="watchlistItemList">
<!-- Test item -->
<div class="watchItem">
<a href="#/AFI">
<div class="watchItemText">
<p class="asxCodeText"><strong>AFI</strong></p>
<p class="asxCodeDesc"><small>Australian Foundation Investments Co</small></p>
</div>
<div class="watchItemQuote">
<p class="asxPrice lead">$6.50</p>
<p class="asxChangeUp text-success">+ 5%</p>
</div>
</a>
</div>
</div>
</div>
<div class="floatLeft" id="rightDiv" ng-view>
</div>
</div>
</div>
</body>
</html>
The directive "compiles" and is appended to the DOM element as expected, but the asxCode variable is not interpolating within the directive template.
Any suggestions greatly appreciated.
I need to change the color of the Header Cell and first column called "col_row" when one or more cells are selected with the mouse like this:
I use this code and its working:
Private Sub gdv_PatioAcopio_CellStateChanged(sender As Object, e As DataGridViewCellStateChangedEventArgs) Handles gdv_PatioAcopio.CellStateChanged
If e.Cell.ColumnIndex = 0 Then
e.Cell.Selected = False
Else
If e.Cell.Selected = True Then
Me.gdv_PatioAcopio.Columns(e.Cell.ColumnIndex).HeaderCell.Style.BackColor = Color.LightBlue
Me.gdv_PatioAcopio.Rows(e.Cell.RowIndex).Cells("col_row").Style.BackColor = Color.LightBlue
ElseIf e.Cell.Selected = False Then
Me.gdv_PatioAcopio.Columns(e.Cell.ColumnIndex).HeaderCell.Style.BackColor = Color.Navy
Me.gdv_PatioAcopio.Rows(e.Cell.RowIndex).Cells("col_row").Style.BackColor = Color.Navy
End If
End If
End Sub
but when i deselect, for example, the third column, the first column changes its color to Color.Navy.
How can i prevent this?
Thanks!
I have a problem replicating the following example on my site created with the ZK-framework: http://ift.tt/1lesONx
When submitting the form, I get:
HTTP ERROR 404
Problem accessing /backend/sendEmail.do. Reason:
Not Found
even though I've specified in my my web.xml to map .do files to the dispatcherservlet.
The relevant entries in web.xml are:
<servlet>
<servlet-name>SpringController</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mail.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringController</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
In pom.xml:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.1.2.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.2.RELEASE</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.2.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.2.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.1.2.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>3.1.2.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.1.2.RELEASE</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.1.2.RELEASE</version>
<scope>compile</scope>
</dependency>
In spring-mail.xml:
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/GArMu6
http://ift.tt/GAf8ZW">
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.gmail.com" />
<property name="port" value="587" />
<property name="username" value="username" />
<property name="password" value="password" />
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/" />
<property name="suffix" value=".zul" />
</bean>
<bean
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Exception">Error</prop>
</props>
</property>
</bean>
The form .zul:
<zk xmlns:h="native">
<window title="Recupera password">
<h:form method="post" action="sendEmail.do">
<grid hflex=" 1">
<columns>
<column align="right" hflex="min" />
<column />
</columns>
<rows>
<row>
E-mail :
<hlayout>
<textbox id="email" cols="24" tabindex="1" />
</hlayout>
</row>
<row>
<label />
<button id="invia" type="submit" label="Invia" />
</row>
</rows>
</grid>
</h:form>
</window>
</zk>
and finally, the controller:
@Controller
@RequestMapping("/backend/sendEmail.do")
public class RecuperaPasswordController {
@Autowired
private JavaMailSender mailSender;
@RequestMapping(method = RequestMethod.POST)
public void invia(HttpServletRequest request) throws MessagingException {
}
}
In theory everything should be in place, as far as I see, but it still gives me this error. Judging from similar posts, the problem might be that the .zul is not in the WEB-INF folder, but as far as I've understood, that folder is inaccessible, and for good reasons, since it might contain configuration files with sensitive information, so I'm kind of lost.
Otherwise, if someone knows a good way to integrate maildispatching with ZK, I'm all ears for other alternative solutions!
EDIT: As requested, the whole web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://ift.tt/qzwahU"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/qzwahU http://ift.tt/16hRdKA">
<description><![CDATA[MyEfm]]></description>
<display-name>MyEfm</display-name>
<!-- //// -->
<!-- ZK -->
<listener>
<description>ZK listener for session cleanup</description>
<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
</listener>
<servlet>
<description>ZK loader for ZUML pages</description>
<servlet-name>zkLoader</servlet-name>
<servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
<!-- Must. Specifies URI of the update engine (DHtmlUpdateServlet). It
must be the same as <url-pattern> for the update engine. -->
<init-param>
<param-name>update-uri</param-name>
<param-value>/zkau</param-value>
</init-param>
<!-- Optional. Specifies whether to compress the output of the ZK loader.
It speeds up the transmission over slow Internet. However, if you configure
a filter to post-processing the output, you might have to disable it. Default:
true <init-param> <param-name>compress</param-name> <param-value>true</param-value>
</init-param> -->
<!-- [Optional] Specifies the default log level: OFF, ERROR, WARNING, INFO,
DEBUG and FINER. If not specified, the system default is used. <init-param>
<param-name>log-level</param-name> <param-value>OFF</param-value> </init-param> -->
<load-on-startup>1</load-on-startup><!-- Must -->
</servlet>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zul</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zhtml</url-pattern>
</servlet-mapping>
<!-- [Optional] Uncomment it if you want to use richlets. <servlet-mapping>
<servlet-name>zkLoader</servlet-name> <url-pattern>/zk/*</url-pattern> </servlet-mapping> -->
<servlet>
<description>The asynchronous update engine for ZK</description>
<servlet-name>auEngine</servlet-name>
<servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
<!-- [Optional] Specifies whether to compress the output of the ZK loader.
It speeds up the transmission over slow Internet. However, if your server
will do the compression, you might have to disable it. Default: true <init-param>
<param-name>compress</param-name> <param-value>true</param-value> </init-param> -->
<!-- [Optional] Specifies the AU extension for particular prefix. <init-param>
<param-name>extension0</param-name> <param-value>/upload=com.my.MyUploader</param-value>
</init-param> -->
</servlet>
<servlet-mapping>
<servlet-name>auEngine</servlet-name>
<url-pattern>/zkau/*</url-pattern>
</servlet-mapping>
<!-- [Optional] Uncomment if you want to use the ZK filter to post process
the HTML output generated by other technology, such as JSP and velocity.
<filter> <filter-name>zkFilter</filter-name> <filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class>
<init-param> <param-name>extension</param-name> <param-value>html</param-value>
</init-param> <init-param> <param-name>compress</param-name> <param-value>true</param-value>
</init-param> </filter> <filter-mapping> <filter-name>zkFilter</filter-name>
<url-pattern>your URI pattern</url-pattern> </filter-mapping> -->
<!-- //// -->
<!-- ///////////// -->
<!-- DSP (optional) Uncomment it if you want to use DSP However, it is turned
on since zksandbox uses DSP to generate CSS. -->
<servlet>
<servlet-name>dspLoader</servlet-name>
<servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class>
<init-param>
<param-name>class-resource</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dspLoader</servlet-name>
<url-pattern>*.dsp</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SpringController</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mail.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- <servlet-mapping> -->
<!-- <servlet-name>SpringController</servlet-name> -->
<!-- <url-pattern>*.zul</url-pattern> -->
<!-- </servlet-mapping> -->
<servlet-mapping>
<servlet-name>SpringController</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- Less compiler ZK Less Servlet da commentare in produzione / collaudo -->
<!-- <servlet> -->
<!-- <servlet-name>zkLess</servlet-name> -->
<!-- <servlet-class>org.zkoss.less.ZKLessServlet</servlet-class> -->
<!-- <init-param> -->
<!-- <param-name>org.zkoss.less.LessResource</param-name> -->
<!-- specify to the folder that contains *.less -->
<!-- <param-value>/common/less</param-value> -->
<!-- </init-param> -->
<!-- <init-param> -->
<!-- <param-name>org.zkoss.less.OutputFormat</param-name> -->
<!-- specify output file suffix, default .css.dsp -->
<!-- <param-value>.css.dsp</param-value> -->
<!-- </init-param> -->
<!-- <init-param> -->
<!-- <param-name>org.zkoss.less.CompressOutput</param-name> -->
<!-- compress output, default true -->
<!-- <param-value>true</param-value> -->
<!-- </init-param> -->
<!-- <load-on-startup>1</load-on-startup> -->
<!-- </servlet> -->
<!-- <servlet-mapping> -->
<!-- <servlet-name>zkLess</servlet-name> -->
<!-- specify to folder that contains *.less -->
<!-- <url-pattern>/common/less/*</url-pattern> -->
<!-- </servlet-mapping> -->
<!-- End Less compiler -->
<!-- /////////// -->
<!-- [Optional] Session timeout -->
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<!-- Spring configuration -->
<!-- Initialize spring context -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
/WEB-INF/applicationContext-security.xml
</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>root-pf</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<filter><!-- the filter-name must be preserved, do not change it! -->
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter>
<filter-name>OpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- [Optional] MIME mapping -->
<mime-mapping>
<extension>doc</extension>
<mime-type>application/vnd.ms-word</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gif</extension>
<mime-type>image/gif</mime-type>
</mime-mapping>
<mime-mapping>
<extension>htm</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpeg</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpg</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>text/javascript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pdf</extension>
<mime-type>application/pdf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>
<mime-mapping>
<extension>txt</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xls</extension>
<mime-type>application/vnd.ms-excel</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xml</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zhtml</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>zul</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.zul</welcome-file>
<welcome-file>index.zhtml</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>
I am not sure if I had asked the question correctly in title, but here the proper scenario.
Suppose I have SQL table in which rows are inserted everyday. In these rows there is one column which has one set of values. That means in this column, let's call it Source_system, we receive 20 values each day. Same distinct values everyday. Now is there any way I can get the name of the source system which is not inserted for that day?
EDIT: Sorry for bad English.
I'm using Yii application. In that how to give pagination to a table contents( not using cgridview).
In view,
<table data-provides="rowlink" data-page-size="20" data-filter="#mailbox_search" class="table toggle-square default footable-loaded footable" id="mailbox_table">
<thead>
<tr>
<th></th>
<th data-hide="phone,tablet">To</th>
<th>Subject</th>
<th data-hide="phone" class="footable-last-column">Date</th>
</tr>
</thead>
<tbody>
<?php
foreach ($model as $item) {
if ($item->email_status == 1)
echo '<tr id="' . $item->emailid . '" class="unreaded rowlink" style="display: table-row;">';
else
echo '<tr id="' . $item->emailid . '" class="rowlink" style="display: table-row;">';
echo '<td class="nolink footable-first-column">';
echo '<span class="footable-toggle"></span>';
echo '</span></td>';
echo '<td>' . $item->touser->username . '</td>';
echo '<td>' . $item->email_subject . '</td>';
$originalDate = $item->time;
$newDate = date("Y-M-d H:i:s", strtotime($originalDate));
echo '<td class="footable-last-column">' . $newDate . '</td></tr>';
}
?>
</tbody>
</table>
In Controller,
public function actionOutbox()
{
$criteria = new CDbCriteria;
$criteria->order = 'time DESC';
$model = Email::model()->findAllByAttributes(array(
'from_userid' => Yii::app()->user->id
),
$criteria
);
$this->render('outbox', array(
'model' => $model,
));
}
In this code how to add pagination. I tried following different techniques but found none of them to work. Please help me.
I have a UIImagePickerController with a custom cameraOverlayView.
I create the imagePicker like this:
self.overlay = [self.storyboard instantiateViewControllerWithIdentifier:@"OverlayViewController"];
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
self.picker.showsCameraControls = NO;
// Insert the overlay
self.picker.cameraOverlayView = self.overlay.view;
self.overlay.pickerReference = self.picker;
self.picker.edgesForExtendedLayout = UIRectEdgeAll;
self.picker.extendedLayoutIncludesOpaqueBars = YES;
self.picker.delegate = self.overlay;
[self presentViewController:self.picker animated:NO completion:^{
}];
For some reason, the OverlayViewController's view is misplaced. It seems as if the constraints haven't been calculated. However, if I explicitly call [self.overlay viewWillAppear:NO]; in the completion block, they layout seems to render correctly.
After some investigation it seems as if viewWillAppear and viewDidAppear is not called for the OverlayViewController.
However, these methods are called if I come back to the imagePicker from a modal 'custom gallery viewcontroller'.
I.e: rootVC-> (No calls) -> imagePicker -> customGalleryVc customGalleryVc (dismiss modal) -> (Calls to willAppear) -> imagePicker
What is this? Am I missing something with the fundamentals of the view-hierarchy?
Thank you!
I am trying to add a a couple of authors to a report I am writing. Preferably, the second author would appear on a new line after the first. I know I can modify the template to add a new field or the multiple author example given in the Pandoc readme. However, I wonder if there is any character I can use to insert a new line between authors directly in the metablock. So far I have tried \newline, \\, | with newline and space, <br>, <div></div>, and making the author list a string with newline or double spaces between author names, but nothing has worked. My desired output is pdf.
I am attempting to pass angular's bootstrap modal the url of the image that was clicked in a angular masonry gallery. What I have is very close to the demo in the documentation with only a few changes. I know this is completely an issue with my own understanding of scope.
My modal HTML:
<div class="modal-header">
<h3 class="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body">
<ul>
<li ng-repeat="item in items">
<a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a>
</li>
</ul>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>
And in my Controller:
angular.module('testApp').controller('GalleryCtrl', function ($scope, $modal, $log) {
$scope.animationsEnabled = true;
$scope.items = ['item1', 'item2', 'item3'];
// Temporary Generation of images to replace with about us images
function genBrick() {
var height = ~~(Math.random() * 500) + 100;
var id = ~~(Math.random() * 10000);
return {
src: 'http://placehold.it/' + width + 'x' + height + '?' + id
};
};
this.bricks = [
genBrick(),
genBrick(),
genBrick(),
genBrick(),
genBrick(),
genBrick()
];
this.showImage = function(item){
alert(item.src); // gives me exactly what im trying to pass to the modal
var modalInstance = $modal.open({
animation: $scope.animationsEnabled,
templateUrl: 'views/modal.html',
scope: $scope,
controller: 'GalleryCtrl',
resolve: {
items: function () {
return $scope.items;
}
}
});
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
}
});
Lastly for clarity, this is my masonry code
<div masonry>
<div class="masonry-brick" ng-repeat="brick in gallery.bricks">
<img ng-src="{{ brick.src }}" alt="A masonry brick" ng-click="gallery.showImage(brick)">
</div>
</div>
Right now this works fine to return the items objects 3 values in li tags to the modal just like in the original example. What id really like to pass into the model is the (item.src) but no matter what i change it never seems to get passed in so that i can display it.
My linux (i5 Processor, RAM: 16GB) machine is able to handle 100k users easily however same does not happen with Windows 8 (i7 Processor 2600 @ CPU 3.40GHz, RAM: 32GB) and thread creation stops after specific amount of thread is created somewhere around 20k in JMeter.
Is there any reason as why Windows in not able to handle huge number of users?
I have a table where is some case we are missing the location record for location = 'WHS1'. You will notice the bottom 2 "TCODE's" do not have a location = WHS1 record
I was thinking of doing a select distinct on TCODE InvYear and to get unique records then checking to see if the Location 'WHS1' NOT Exist.
I'm very green at this that you for any help
TCODE InvYear Location StartingInv Adjustments Damages EndingInv
NY530-1 2015 BRX 625 NULL NULL 709
NY530-1 2015 LAN 365 NULL NULL 365
NY530-1 2015 WHS1 432 NULL NULL 442
NY530-2 2015 BRX 309 NULL NULL 413
NY530-2 2015 LAN 94 NULL NULL 96
NY530-2 2015 WHS1 1310 NULL NULL 1344
NY547-1 2015 BRX 0 NULL NULL 0
NY547-2 2015 BRX 0 NULL NULL 0
I'm working on an Android app, which streams live audio from mic to the vlc using native android RTP lib (using AudioStream and AudioGroup) with in the same room on the speaker(it is conference app, so MIC and Speaker both will be in same room) the problem is, it is creating a lot of ECHO, i know the android have native Android API AcousticEchoCanceler and also NoiseSuppressor API but these APIs work with AudioRecord or MediaRecorder... I need some hep, how can i remove Echo using these native APIs with RTP lib OR Anyone can suggest me any 3rd party lib which streams live audio with built-in Echo canceler..
Here is the link you can see, they are streaming live audio in the same room, without any echo, we are working on the same concept of live streaming...
Thanks in advance...!
Hi Please help a Powershell newbie with a seemingly simple task which is doing my head in.
I have a folder containing a large list of hofixes. Each hotfix filename contains the KB number such as KB2993958 similar to Windows8.1-KB2957189-x64.msu
I'm trying to troubleshoot an issue caused by the installation of a particular hotfix. I have narrowed the selection down to about 50 possible hotfixes, far less than how many are contained in the master folder. I want to install 10 hotfixes at a time to try and isolate the issue.
I have the list of 50 hotfixes I need to install either in a get-hotfix object or probably converted to a string in a variable.
So I want to compare the Kb numbers listed in my object / variable against the file names in the master folder and if the file name contains any of the KB number stored in my variable then move this file into a folder, ready for installation. Seems simple. Can't work it out.
Please help. Feeling a bit dumb right now :( Many Thanks!!
I've developed a little mode for emacs which applies enriched format (colors, different fonts, etc) to some pieces of text using regular expressions (as markdown does).
In some of these regular expressions, there's french and spanish characters (like ``), and unicode characters (like ☛). Usually I use emacs in no windows mode (-nw), but to edit files which uses my mode, I open emacs in windowed mode, and I've realized that in windowed mode I can't write non-ascii characters, like ` or ☛. So, I can't use these special patterns (files are utf8).
If I execute describe-input-method in emacs, it says that no input method is specified, both in windowed and nw mode. However, it's not crazy to say the input method is different in windows and nw mode, since in boths modes the characters I'm able to write are different; or have I misunderstood what the meaning of input mode in emacs is?
I started reading more about EF. I believed that entities are tracked as long as the context is in scope. But when I try the code below I get different results. I'm sure I misunderstood what I read. Can you please explain.
Destination canyon;
DbEntityEntry<Destination> entry;
using (var context = new BreakAwayContext())
{
canyon = (from d in context.Destinations.Include(d => d.Lodgings)
where d.Name == "Grand Canyon"
select d).Single();
entry = context.Entry<Destination>(canyon);
}
Console.WriteLine(entry.State); //Unchanged
canyon.TravelWarnings = "Carry enough water!";
Console.WriteLine(entry.State); //Modified
I have the following code that paints 4 points in a canvas3D window
public final class energon extends JPanel {
int s = 0, count = 0;
public energon() {
setLayout(new BorderLayout());
GraphicsConfiguration gc=SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(gc);//See the added gc? this is a preferred config
add("Center", canvas3D);
BranchGroup scene = createSceneGraph();
scene.compile();
// SimpleUniverse is a Convenience Utility class
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
// This moves the ViewPlatform back a bit so the
// objects in the scene can be viewed.
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
}
public BranchGroup createSceneGraph() {
BranchGroup lineGroup = new BranchGroup();
Appearance app = new Appearance();
ColoringAttributes ca = new ColoringAttributes(new Color3f(204.0f, 204.0f, 204.0f), ColoringAttributes.SHADE_FLAT);
app.setColoringAttributes(ca);
Point3f[] plaPts = new Point3f[4];
for (int i = 0; i < 2; i++) {
for (int j = 0; j <2; j++) {
plaPts[count] = new Point3f(i/10.0f,j/10.0f,0);
//Look up line, i and j are divided by 10.0f to be able to
//see the points inside the view screen
count++;
}
}
PointArray pla = new PointArray(4, GeometryArray.COORDINATES);
pla.setCoordinates(0, plaPts);
Shape3D plShape = new Shape3D(pla, app);
TransformGroup objRotate = new TransformGroup();
objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
objRotate.addChild(plShape);
lineGroup.addChild(objRotate);
return lineGroup;
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.add(new JScrollPane(new energon()));
frame.setSize(300, 300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Now i want to add a timertask that regularly updates the position of one of the points in the plaPts Point3f array. However, when i call plaPts[1].setX(2), nothing happens on the screen, they remain in the same position.
Do you have to have each point in a separate TransformGroup (consisting of a shape3D with a Point3f array of size 1) for this to be possible? I'm later going to use 100000 points, is it bad for performance if they all are in separate TransformGroups? Is there an easier way of doing this? Something like shape3D.repaint(), that automatically updates the position of the points based on the new values in plaPTS.
The scala Future class has several methods that are based on functional programming. When called from Java, it looks like using lambdas from Java 8 would be a natural fit.
However, when I try to actually use that, I run into several problems. The following code does not compile
someScalaFuture.map(val -> Math.sqrt(val)).
map(val -> val + 3);
because map takes an ExecutionContext as an implicit argument. In Scala, you can (usually) ignore that, but it needs to be passed in explicitly in Java.
someScalaFuture.map(val -> Math.sqrt(val),
ec).
map(val -> val + 3,
ec);
This fails with this error:
error: method map in interface Future<T> cannot be applied to given types;
[ERROR] val),ExecutionContextExecutor
reason: cannot infer type-variable(s) S
(argument mismatch; Function1 is not a functional interface
multiple non-overriding abstract methods found in interface Function1)
where S,T are type-variables:
S extends Object declared in method <S>map(Function1<T,S>,ExecutionContext)
T extends Object declared in interface Future
If I actually create an anonymous class extending Function1 and implement apply as such:
someScalaFuture.map(new Function1<Double, Double>() {
public double apply(double val) { return Math.sqrt(val); }
},
ec).
map(val -> val + 3,
ec);
I get an error that
error: <anonymous com.example.MyTestClass$1> is not abstract and does not override abstract method apply$mcVJ$sp(long) in Function1
I have not tried implementing that method (and am not sure if you can even implement a method with dollar signs in the middle of the name), but this looks like I am starting to wonder into the details of Scala implementations.
Am I going down a feasible path? Is there a reasonable way to use lambdas in this way? If there is a library that makes this work, that is an acceptable solution. Ideally, something like
import static org.thirdparty.MakeLambdasWork.wrap;
...
wrap(someScalaFuture).map(val -> Math.sqrt(val)).
map(val -> val + 3);
I have a simple situation which probably require a complex way to be solved but I'm unsure of it.
Basically I have this object which encapsulated a member function:
template<class T, typename R, typename... ARGS>
class MemberFunction
{
private:
using function_type = R (T::*)(ARGS...);
function_type function;
public:
MemberFunction(function_type function) : function(function) { }
void call(T* object, ARGS&&... args)
{
(object->*function)(args...);
}
};
This can be used easily
MemberFunction<Foo, int, int, int> function(&Foo::add)
Foo foo;
int res = function.call(&foo, 10,20)
The problem is that I would like to call it by passing through a custom environment which uses a stack of values to operate this method, this translates to the following code:
int arg2 = stack.pop().as<int>();
int arg1 = stack.pop().as<int>();
Foo* object = stack.pop().as<Foo*>();
int ret = function.call(object, arg1, arg2);
stack.push(Value(int));
This is easy to do directly in code but I'd like to find a way to encapsulate this behavior directly into MemberFunction class by exposing a single void call(Stack& stack) method which does the work for me to obtain something like:
MemberFunction<Foo, int, int, int> function(&Foo::add);
Stack stack;
stack.push(Value(new Foo());
stack.push(10);
stack.push(20);
function.call(stack);
assert(stack.pop().as<int>() == Foo{}.add(10,20));
But since I'm new to variadic templates I don't know how could I do in efficiently and elegantly.
We are using Typescript with Intellij Webstorm IDE.
The situation is we use ES6 import syntax and tsc compiler 1.5.3 (set as custom compiler in Webstorm also with flag --module commonjs)
The problem is it is imposible to click through (navigate to) method from module (file)
// app.ts
import * as myModule from 'myModule';
myModule.myFunction();
// myModule.ts
export function myFunction() {
// implementation
}
When I click on .myFunction() in app.ts I expect to navigate to myModule.ts file but this doesn't happen?
I have this simple example of using a functor in C++:
#include <memory>
#include <ostream>
#include <iostream>
template <typename T>
struct Point {
T x, y;
Point(T x, T y) : x(x), y(y){};
Point(){};
Point<T> operator+(const Point<T>& other) {
this->x += other.x;
this->y += other.y;
return *this;
}
};
template <typename T>
struct AddSome {
AddSome(){};
AddSome(T* what) { add_what = (T)*what; };
AddSome(T what) : add_what(what){};
T operator()(T to_what) {
if (ptr) {
return to_what + add_what;
}
return to_what + add_what;
};
private:
std::shared_ptr<T> ptr;
T add_what;
};
int main(int argc, char* argv[]) {
Point<int>* pt = new Point<int>(5, 6);
AddSome<Point<int>> adder5(pt);
Point<int> test = adder5(*pt);
std::cout << test.x << " " << test.y << std::endl;
return 0;
}
In the version above it works very well but it doesn't work at all if I delete the default constructor of the Point class.
What does the compiler need this constructor for?
I would like to develop an android app acting like an indoor positioning system.But I am stuck ,I don't know where to begin.I would like to know what is the best technology to use. I also want to know if there's a way to build this app based on BLE technology with beacons detection. Any information provided will be very helpful and thank you in advance.
I have a numeric string column in oracle with or without leading zeros samples:
00000000056
5755
0123938784579343
00000000333
984454
The issue is that partial Search operations using like are very slow
select account_number from accounts where account_number like %57%
one solution is to restrict the search to exact match only and add an additional integer column that will represent the numeric value for exact matches.
At this point I am not sure we can add an additional column,
Do you guys have any other ideas?
Is it possible to tell Oracle to index the numeric string column as an integer value so we can do exact numeric match on it?
for example query on value :00000000333
will be:
select account_number from accounts where account_number = '333'
While ignoring the leading zeros.
I can use regex_like and ignore them, but i am afraid its going to be slow.
How do I have to configure my SQL Server Express connection string that the server attribute accepts the computername where the SQL Server is running aka the current machine:
<connectionStrings>
<add name="MyDbConn1"
connectionString="Server=.\SQLEXPRESS;Database=MyDb;Trusted_Connection=Yes;"/>
</connectionStrings>
I have seen somewhere a configuration like the above where the server attribute has the .\SQLEXPRESS value.
What does that dot notation mean?
I have this query
SELECT CONVERT(VARCHAR(20),(((currentytd - PreviousYTD) / PreviousYTD) * 100)) + '%' as ytdGrowth from ytd
It is returning: 11.224300%
I would like to return: 11.22%
I am very new SQL so trying to find the correct way to accomplish this.
I have a series of textareas that all follow the same format nested html format but I need to target one specifically. The problem I'm having is that the unique value I can use to identify the specific textarea is a parent's sibling's child.
Given this html
<fieldset>
<legend class="name">
<a href="#" style="" id="element_5014156_showhide" title="Toggle “Standout List”">▼</a>
</legend>
<ul id="element_5014156" class="elements">
<li class="element clearboth">
<h3 class="name">Para:</h3>
<div class="content">
<textarea name="container_prof|15192341" id="container_prof15192341"> TARGET TEXTAREA</textarea>
</div>
::after
</li>
<li class="element clearboth">
<h3 class="name">Para:</h3>
<div class="content">
<input type="text" class="textInput" name="container_prof|15192342" id="container_prof_15192342" value="" size="64">
</div>
::after
</li>
</ul>
</fieldset>
There are many of the <li> elements. I can't use the name or id as they dynamically created.
I want to target the textarea that says TARGET TEXTAREA. The only unqiquess I can find is the title attribute of the <a> element within the element.
I can get that specifically legend.name a[title*='Standout'] In Chrome Console: $$("legend.name a[title*='Standout']");
and I can traverse all the way to up to the <legend> element from the textarea legend.name ~ ul.elements li.element div.content textarea
In Chrome Console: $$("legend.name ~ ul.elements li.element div.content textarea")
That gives me ALL the textareas that have a div with class="content" that has a li with a class=element which has a ul with a class=elements which has a sibling legend with a class=name.
The only thing I can figure out is to add the qualifier that the legend with the class=name has to have the anchor that has 'Standout' in it's title.
I've tried $$("legend.name a[title*='Standout'] ~ ul.elements li.element div.content textarea") but that fails obviously since the anchor is not an adjacent sibling of the ul
Any help would be most appreciated!
Assume you have the following HTML:
<div id="root-component" class="script-component">a0
<div></div>
<div class="component">a2</div>
<div class="script-component">b
<div class="component">b1
<div class="script-component">c
</div>
<div class="component">b2
</div>
</div>
</div>
<div class="component">a3</div>
<div class="component">a4</div>
<div>
<div class="component">a5</div>
</div>
<div class="component"> a6
<div class="component">a7</div>
</div>
<div class="component">a8
<div class="script-component"></div>
</div>
</div>
From the root-component I would like to select all child elements with a component class until and not including the elements with the script-component class. This means at the end only the elements with an a text should be selected.
Edit: Or in Trung's words: The goal is to skip searching for components down the tree once script-component class is encountered.
Edit2: Or in even other words: I would like to select all .component children until a .script-component is encountered.
It can be done using jQuery and CSS.
You can use this jsFiddle http://ift.tt/1gf6Nlb to try it out.
i am working on a project on linux and i need to analyse the performence of an application server .
i need a tools that gives graphs , statistics and system metrics of a single process identified by it PID
i need information like : number of threads created , number of threads actives , memory usage by each thread , the distribution of threads on processor cores etc
i tried TOP and sysstat , but i didn't how to get an CSV file or a graph out of them
Thx
I was working on elixir and suddenly this happened
iex(1)> [9,9,9]
'\t\t\t'
iex(2)> [8,8,8]
'\b\b\b'
iex(3)> [104, 101, 108, 108, 111]
'hello'
List of numbers output as characters. I freaked out, but then checked out the documentation to see that this was normal behavior Can anyone tell me the reason,purpose and any other gotcha's about this if any, Thanks.
I have pagination problem. My api has a model product which contains a field which has 5 choices.
I have already entered 30 entries in product each choices has 6 entries, page size which I've set is 5, my requirement is if at first I call 127.0.0.1:8000/api/product/ I want 1 entry from each choice, no matter whether first page has only entries on choice 1.
I'm not sure this has to be done through pagination or filtering but I'm unable to figure it out.
class Product(models.Model):
item_category_choices = (('MU','Make Up'), ('SC','Skin Care'), ('Fra','Fragrance'), ('PC','Personal Care'),('HC','Hair Care'))
item_category = models.CharField(max_length=20,choices = item_category_choices)
now on hitting url /api/product I need a response something like
{"count":30,"next":"127.0.0:8000/api/product/?page=2","previous":null,"results":[{"id":1,"item_category":'Personal Care',},{"id":2,"item_category":'Hair Care'},{"id":3,"item_category":MakeUp},{"id":4,"item_category":"SkinCare},{"id":5,"item_category":"'Fragrance"}}]}
I am pretty new to rails and ruby and still wrapping my head around the hole concept of rails.
What I want to do: I'm creating a shift-planner with a view of one week and want to create a button that will show the next/last week.
What I did:
I have 3 tables that are relevant. shift, person and test (contains types of shifts) Where both Test and Peson have one to many relations to Shift.
In my controller I did the following:
def index
@todos = Todo.all
@shifts = Shift.all
@people = Person.all
@start_of_week = Date.new(2015,8,7)
@end_of_week = Date.new(2015,8,11)
view:
<% person.shifts.where(:date_of_shift => @start_of_week..@end_of_week).order(:date_of_shift).each do |shift| %>
<td>
<%="#{shift.test.name} #{shift.date_of_shift}"%>
</td>
<%end%>
My Idea was I would make a link where I would increment both Dates and refresh my Page
<a href="/todos/new">
Next Week
<% @start_of_week += 7 %>
<% @end_of_week += 7 %>
</a>
Unfortuately that doesn't work. Cause everytime I call the index function in my controller it sets the date on the default value.
And I'm pretty clueless how to fix this problem in a rails way. My only would be to somehow pass the dates as parameter to the index function or something like that.
the generell structure is: I scaffolded a Todo view/controller/db just for the sake of having a view / controller and my 3 databases.
Thx for the help. PS: I'm using the current version of ruby and rails on lubuntu15(schouldn't be really releveant^^)
I am looking for an algorithm to solve the following problem: Given an integer array of size n, find one (arbitrary) element of this array which occurs exactly once. All numbers which do not fit this requirement occur an even number of times in the array. If the array does not contain any such number, the result is irrelevant.
An example would be the input [1, 2, 2, 4, 4, 2, 2, 3] with both 1 and 3 being a correct output.
Most importantly, the algorithm should run in O(n) time and require only O(1) additional space. I have been told that this is possible but could not come up with a solution myself.
An example of Rails controller which defines a private method:
class ApplicationController < ActionController::Base
private
def authorization_method
# do something
end
end
Then, it's being used in subclass of "ApplicationController":
class CustomerController < ApplicatioController
before_action :authorization_method
# controller actions
end
My question is: how is it possible, that private method be called from subclass? What is meaning of private in Ruby?
Thanks
I am writing the below function in which i am getting an error i think for if/else condition as Error(1360,5): PLS-00103: Encountered the symbol "BUILD_ALERT_EMAIL_BODY" when expecting one of the following: if. I think i am using proper syntax but dont know why the error is coming.
FUNCTION BUILD_ALERT_EMAIL_BODY
(
IN_ALERT_LOGS_TIMESTAMP IN TIMESTAMP
, IN_ALERT_LOGS_LOG_DESC IN VARCHAR2
, IN_KPI_LOG_ID IN NUMBER
) RETURN VARCHAR2 AS
BODY VARCHAR2(4000) := '';
V_KPI_TYPE_ID NUMBER;
V_KPI_THRESHOLD_MIN_VALE NUMBER;
V_KPI_THRESHOLD_MAX_VALE NUMBER;
V_EXPECTED_VALE NUMBER;
V_ACTUAL_VALE NUMBER;
BEGIN
-- ,'yyyy-MM-dd H24 mm ss'
Select KPI_DEF_ID INTO V_KPI_DEF_ID FROM KPI_LOGS WHERE KPI_LOG_ID = IN_KPI_LOG_ID;
Select EXPECTED_VALE INTO V_EXPECTED_VALE FROM KPI_LOGS WHERE KPI_LOG_ID = IN_KPI_LOG_ID;
Select ACTUAL_VALE INTO V_ACTUAL_VALE FROM KPI_LOGS WHERE KPI_LOG_ID = IN_KPI_LOG_ID;
Select KT.KPI_TYPE_ID INTO V_KPI_TYPE_ID FROM RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION KD JOIN RATOR_MONITORING_CONFIGURATION.KPI_TYPE KT ON KD.KPI_TYPE = KT.KPI_TYPE_ID WHERE KD.KPI_DEF_ID = V_KPI_DEF_ID;
Select KPI_THRESHOLD_MIN_VAL INTO V_KPI_THRESHOLD_MIN_VALE FROM RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION WHERE KPI_DEF_ID = V_KPI_DEF_ID;
Select KPI_THRESHOLD_MAX_VAL INTO V_KPI_THRESHOLD_MAX_VALE FROM RATOR_MONITORING_CONFIGURATION.KPI_DEFINITION WHERE KPI_DEF_ID = V_KPI_DEF_ID;
IF ((V_KPI_TYPE_ID = 18) || (V_KPI_TYPE_ID = 19)) THEN
BODY := BODY || 'KPI_THRESHOLD_MIN_VAL:' || V_KPI_THRESHOLD_MIN_VALE || Chr(13) || Chr(10);
BODY := BODY || 'KPI_THRESHOLD_MAX_VAL:' || V_KPI_THRESHOLD_MAX_VALE || Chr(13) || Chr(10);
ELSE IF ((V_KPI_TYPE_ID = 11) || (V_KPI_TYPE_ID = 12) || (V_KPI_TYPE_ID = 13) || (V_KPI_TYPE_ID = 14) || (V_KPI_TYPE_ID = 20)) THEN
BODY := BODY || 'EXPECTED_VALE:' || V_EXPECTED_VALE || Chr(13) || Chr(10);
BODY := BODY || 'ACTUAL_VALE:' || V_ACTUAL_VALE || Chr(13) || Chr(10);
END IF;
RETURN BODY;
END BUILD_ALERT_EMAIL_BODY;
I generated a scatterplot graph.My requirement is to swipe the graph part by part ie,if 10 columns of plot r shown on the screen,on the swipe the next 10 columns need to be shown.
-(BOOL)plotSpace:(CPTXYPlotSpace *)space shouldHandlePointingDeviceDraggedEvent:(id)event atPoint:(CGPoint)point{
NSLog(@"point.x=%lf,point.y=%lf",point.x,point.y);
return YES;
}
This gives the point dragged..how can i achieve my requirement with this method or is their any other way to figure it out?
Anybody please help...
I’m a print designer working on a travel guide that we recently started managing with XML-tagged content and XSLT styling. It mostly works, aside from this one small issue that has driven us to wit’s end! We have some sub-attraction listings that should appear as “child” listings that we can style differently in InDesign layout, and they’re noted in the XML by noting a value for their “parent” attraction in the MainAttraction tag.
My understanding is that we need the .XSL to notice whether there’s a value in the MainAttraction tags, and if there is, then to pull out the elements associated with that attraction to go under a different container tag so we can style them differently. I just haven’t had any luck writing syntax for this that works after doing some basic training and Googling around forums.
Here's what I'm experimenting with, which pulls in everything correctly except for sub-attractions (they're listed within the Attraction tags for their associated parent listing):
XSLT
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://ift.tt/tCZ8VR" version="1.0">
<xsl:template match="/">
<Cities>
<xsl:for-each select="Root/City">
<City>
<City_Name>
<xsl:value-of select="City_Name"/>
</City_Name>
<xsl:text>
</xsl:text>
<City_Stats>
<xsl:text>POP. </xsl:text>
<xsl:value-of select="Population"/>
<xsl:text> ALT. </xsl:text>
<xsl:value-of select="Altitude"/>
<xsl:text> MAP </xsl:text>
<xsl:value-of select="Map_Grid_Location"/>
</City_Stats>
<xsl:text>
</xsl:text>
<Visitor_Info>
<Visitor_Center>
<xsl:value-of select="Visitor_Center"/><xsl:text>: </xsl:text>
</Visitor_Center>
<Visitor_Information>
<xsl:value-of select="Visitor_Information"/><xsl:text> </xsl:text>
<xsl:value-of select="Address"/>
<xsl:text> </xsl:text>
<xsl:value-of select="normalize-space(Phone1)"/>
<xsl:if test="string-length(Phone2) > 0">
<xsl:text> or </xsl:text>
<xsl:value-of select="Phone2"/>
</xsl:if>
<xsl:if test="string-length(Phone1) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(Website1)"/>
<xsl:if test="string-length(Website2) > 0">
<xsl:text> or </xsl:text>
<xsl:value-of select="Website2"/>
</xsl:if>
<xsl:if test="string-length(Website1) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
</Visitor_Information>
</Visitor_Info>
<xsl:text>
</xsl:text>
<Description>
<xsl:value-of select="Description"/>
</Description>
<xsl:text>
</xsl:text>
<Attractions>
<xsl:apply-templates select="Attraction"/>
</Attractions>
</City>
</xsl:for-each>
</Cities>
</xsl:template>
<xsl:template match="Attraction">
<Attraction>
<Attraction_Title>
<xsl:value-of select="normalize-space(Attraction_Title)"/>
</Attraction_Title>
<xsl:text>—</xsl:text>
<xsl:value-of select="Desc"/><xsl:text> </xsl:text>
<xsl:value-of select="normalize-space(Admissions)"/>
<xsl:if test="string-length(Admissions) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(Address)"/>
<xsl:if test="string-length(Address) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(Directions)"/>
<xsl:if test="string-length(Directions) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(Phone)"/>
<xsl:if test="string-length(AltPhone) > 0">
<xsl:text> or </xsl:text>
<xsl:value-of select="normalize-space(AltPhone)"/>
</xsl:if>
<xsl:if test="string-length(Phone) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(WebAddress)"/>
<xsl:if test="string-length(WebAddress2) > 0">
<xsl:text> or </xsl:text>
<xsl:value-of select="normalize-space(WebAddress2)"/>
</xsl:if>
<xsl:if test="string-length(WebAddress) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(Email)"/>
<xsl:if test="string-length(Email) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:if test="string-length(SeeAlso) > 0">
<xsl:text> </xsl:text>
<xsl:text>See </xsl:text>
<xsl:value-of select="normalize-space(SeeAlso)"/>
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:text>
</xsl:text>
</Attraction>
</xsl:template>
<xsl:template match="SubAttraction">
<SubAttraction>
<xsl:if test="string-length(MainAttraction) > 0">
<xsl:text>	</xsl:text>
<SubAttraction_Title>
<xsl:value-of select="normalize-space(Attraction_Title)"/>
</SubAttraction_Title>
<xsl:text>—</xsl:text>
<xsl:value-of select="Desc"/><xsl:text> </xsl:text>
<xsl:value-of select="normalize-space(Admissions)"/>
<xsl:if test="string-length(Admissions) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(Address)"/>
<xsl:if test="string-length(Address) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(Directions)"/>
<xsl:if test="string-length(Directions) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(Phone)"/>
<xsl:if test="string-length(AltPhone) > 0">
<xsl:text> or </xsl:text>
<xsl:value-of select="normalize-space(AltPhone)"/>
</xsl:if>
<xsl:if test="string-length(Phone) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(WebAddress)"/>
<xsl:if test="string-length(WebAddress2) > 0">
<xsl:text> or </xsl:text>
<xsl:value-of select="normalize-space(WebAddress2)"/>
</xsl:if>
<xsl:if test="string-length(WebAddress) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(Email)"/>
<xsl:if test="string-length(Email) > 0">
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:text>
</xsl:text>
</xsl:if>
</SubAttraction>
</xsl:template>
</xsl:stylesheet>
XML INPUT SAMPLE (note that the sub-attraction example, the Fredda Turner Durham Children's Museum, has a value in its Main Attraction tags and is nested within the attraction tags for its parent listing)
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<City>
<City_Name>MIDLAND</City_Name>
<Region>BIG BEND COUNTRY</Region>
<Population>127,598</Population>
<Altitude>2,891</Altitude>
<Map_Grid_Location>L-9/KK-4</Map_Grid_Location>
<Visitor_Center>Midland Visitors Center</Visitor_Center> <Visitor_Information>Midland Convention & Visitors Bureau: Open 8 a.m.-5 p.m. Mon.-Sat. 109 N Main St. 800/624-6435.</Visitor_Information><Address>1406 W. I-20 (Exit 136).</Address><Hours>Open 9 a.m.-5 p.m. Mon.-Sat.</Hours><Phone1>432/683-2882</Phone1><Phone2>800/624-6435</Phone2><Website1><a href="http://ift.tt/ZyZBJr" >http://ift.tt/1Kft3Yo;
<CityId>MIDLAND</CityId>
<Description>Description text goes here.</Description>
<Attraction>
<Attraction_Title>Haley Library & History Center</Attraction_Title>
<Desc>Description text goes here. </Desc>
<Admissions>Donations accepted.</Admissions>
<Hours>Open 9 a.m.-5 p.m. Mon.-Fri.</Hours>
<Address>1805 W. Indiana Ave.</Address>
<Directions></Directions>
<Phone>432/682-5785</Phone>
<AltPhone></AltPhone>
<WebAddress></WebAddress>
<WebAddress2></WebAddress2>
<Email></Email>
<SeeAlso></SeeAlso>
<MainAttraction></MainAttraction>
</Attraction>
<Attraction>
<Attraction_Title>I-20 Wildlife Preserve & Jenna Welch Nature Study Center</Attraction_Title>
<Desc>Description text goes here.</Desc>
<Admissions></Admissions>
<Hours>Open dusk–dawn daily.</Hours>
<Address>2201 S. Midland Dr.</Address>
<Phone>432/853-9453</Phone>
<AltPhone></AltPhone>
<WebAddress>http://ift.tt/1gf6NS9;
<WebAddress2></WebAddress2>
<Email></Email>
<SeeAlso></SeeAlso>
<MainAttraction></MainAttraction>
</Attraction>
<Attraction>
<Attraction_Title>Museum of the Southwest</Attraction_Title>
<Desc>Description text goes here.</Desc>
<Admissions>Admission charged.</Admissions>
<Hours>Open 10 a.m.-5 p.m. Tue.-Sat. and 2-5 p.m. Sun.</Hours>
<Address>1705 W. Missouri.</Address>
<Directions></Directions>
<Phone>432/683-2882</Phone>
<AltPhone></AltPhone>
<WebAddress>http://ift.tt/1Kft2ni;
<WebAddress2></WebAddress2>
<Email></Email>
<SeeAlso></SeeAlso>
<MainAttraction></MainAttraction>
<Attraction>
<Attraction_Title>Fredda Turner Durham Children's Museum</Attraction_Title>
<Desc>Description text goes here.</Desc>
<Admissions>Admission charge.</Admissions>
<Hours>Open 10 a.m.-5 p.m. Tue.-Sat. and 2-5 p.m. Sun. Free admission on Sundays.</Hours>
<Address></Address><Directions></Directions><Phone>432/683-2882</Phone><AltPhone></AltPhone><WebAddress></WebAddress><WebAddress2></WebAddress2><Email></Email><SeeAlso></SeeAlso><MainAttraction>Museum of the Southwest</MainAttraction>
</Attraction>
</Attraction>
</City>
</Root>
CURRENT OUTPUT (the sub-attraction doesn't display)
<?xml version="1.0" encoding="UTF-8"?>
<Cities>
<City>
<City_Name>MIDLAND</City_Name>
<City_Stats>POP. 127,598 ALT. 2,891 MAP L-9/KK-4</City_Stats>
<Visitor_Info>
<Visitor_Center>Midland Visitors Center:</Visitor_Center>
<Visitor_Information>Midland Convention & Visitors Bureau: Open 8 a.m.-5 p.m. Mon.-Sat. 109 N Main St. 800/624-6435. 1406 W. I-20 (Exit 136). 432/683-2882 or 800/624-6435. <a href="http://ift.tt/ZyZBJr" >http://ift.tt/1gf6MO6;
</Visitor_Info>
<Description>Description text goes here.</Description>
<Attractions>
<Attraction>
<Attraction_Title>Haley Library & History Center</Attraction_Title>
—Description text goes here. Donations accepted.. 1805 W. Indiana Ave.. 432/682-5785.
</Attraction>
<Attraction>
<Attraction_Title>I-20 Wildlife Preserve & Jenna Welch Nature Study Center</Attraction_Title>
—Description text goes here. 2201 S. Midland Dr.. 432/853-9453. http://ift.tt/1Kft3Yq.
</Attraction>
<Attraction>
<Attraction_Title>Museum of the Southwest</Attraction_Title>
—Description text goes here. Admission charged.. 1705 W. Missouri.. 432/683-2882. www.museumsw.org.
</Attraction>
</Attractions>
</City>
</Cities>
DESIRED OUTPUT (the sub-attraction displays and had its own container tags)
<?xml version="1.0" encoding="UTF-8"?>
<Cities>
<City>
<City_Name>MIDLAND</City_Name>
<City_Stats>POP. 127,598 ALT. 2,891 MAP L-9/KK-4</City_Stats>
<Visitor_Info>
<Visitor_Center>Midland Visitors Center:</Visitor_Center>
<Visitor_Information>Midland Convention & Visitors Bureau: Open 8 a.m.-5 p.m. Mon.-Sat. 109 N Main St. 800/624-6435. 1406 W. I-20 (Exit 136). 432/683-2882 or 800/624-6435. <a href="http://ift.tt/ZyZBJr" >http://ift.tt/1gf6MO6;
</Visitor_Info>
<Description>Description text goes here.</Description>
<Attractions>
<Attraction>
<Attraction_Title>Haley Library & History Center</Attraction_Title>
—Description text goes here. Donations accepted.. 1805 W. Indiana Ave.. 432/682-5785.
</Attraction>
<Attraction>
<Attraction_Title>I-20 Wildlife Preserve & Jenna Welch Nature Study Center</Attraction_Title>—Description text goes here. 2201 S. Midland Dr.. 432/853-9453. http://ift.tt/1Kft3Yq.
</Attraction>
<Attraction>
<Attraction_Title>Museum of the Southwest</Attraction_Title>—Description text goes here. Admission charged.. 1705 W. Missouri.. 432/683-2882. www.museumsw.org.
</Attraction>
<SubAttraction>
<SubAttraction_Title>Fredda Turner Durham Children's Museum</SubAttraction_Title>—Description text goes here. Admission charge.. 432/683-2882.
</SubAttraction>
</Attractions>
</City>
</Cities>
So what do I do here to make it so sub-attractions (attractions with a value int he MainAttraction field) can get pulled into new container tags? I understand that we want to create a new template for SubAttractions, but I don't know how to get only the desired elements into it. I'd greatly appreciate help in finding something to plug in here if it's not too difficult for someone more experienced.
[Original post has been edited to provide more useful info.]
I am planning to do some utility code for using in other projects, but I am doubting between making it a mostly-headers code, a static library with headers just exposing the interface or something in between. Most of the code will be simple functions that wrap other standard functions but there will be also some bigger functions.
I think I mostly understand the differences between the header approach and the static library approach:
For the headers:
For the static library:
I have been looking at some code and I have seen both approaches, but I don't know which will be better. Any thoughts?
In C, what is the difference between static const and const inside a function?
For instance, take the given code examples:
void print_int(int x) {
assert( x < 5 && x > -5 );
const int i[9] = {
-4, -3, -2, -1, 0, 1, 2, 3, 4
};
printf("%i", i[x + 4]);
}
int main() {
print_int( 1 );
return 0;
}
Versus:
void print_int(int x) {
assert( x < 5 && x > -5 );
static const int i[9] = {
-4, -3, -2, -1, 0, 1, 2, 3, 4
};
printf("%i", i[x + 4]);
}
int main() {
print_int(1);
return 0;
}
Would the generated assembly be optimized better if I used static const instead of const, or would the output be the same for both examples?
I'm trying to understand binary and hexadecimal numbers. I want to know why my program won't launch in eclipse. It gives me this error:
launch has encountered a problem
It was running when i used int. My computer is 64bit. I'm trying to understand hardware. I need to know what I'm doing wrong. What can I improve on? Is it okay to declare buffer as a global variable? Thanks.
My code is here.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char * convertBase(unsigned long int numberToConvert, long int base)
{
char buffer[65];
char *pConvertedNumber;
char allValues[] = "0123456789abcdef";
pConvertedNumber = &buffer[sizeof(buffer)-1];
*pConvertedNumber = '\0';
do {
int value = numberToConvert % base;
pConvertedNumber = pConvertedNumber - 1;
*pConvertedNumber = allValues[value];
numberToConvert /= base;
} while(numberToConvert != 0);
printf("%s", pConvertedNumber);
return pConvertedNumber;
}
int main(void){
unsigned long int numberOne = 1000000000;
printf("\n%ld in Base 16 = ", numberOne);
convertBase(numberOne, 16);
printf("\n");
return 0;
}