If given subnet address e.g. 192.168.10.0/24
How to determine mask length ? (/24)
How to determine mask address ? (255.255.255.0)
How to determine network address ? (192.168.10.0)
I would like to do is to know if a user has been created in the system in the last 10 second.
so i would do:
def new_user
if(DateTime.now - User.created_at < 10)
return true
else
return false
end
end
IT is just an idea , how can i do it correctly?
thank you
I have an HSV color A at 3/10 of a line and HSV color B at 9/10 of a line. I'm making multistep gradients and for example if I wanted to find the color at 6/10ths of a line, how could I interpolate these HSV colors? I'm firmiliar with the technique for rgb but not HSV. I should also add that my HSV's are integers H(0,360) S(0,100) V(0,100). Thanks
Dear community I have the follow instruction on SQL ORACLE:
SELECT COUNT(FE_DAY)
FROM TI_DATE
WHERE (FE_MO = 02 AND FE_YEAR in ('2011', '2012'))
GROUP BY FE_DAY
In this instruction effectively obtain like SQL Answer a list of number that they sum=10 .But How can I don't show rows .I need only show the row's sum=10
I tried to apply the follow SQL instruction also:
SELECT SUM(COUNT(FE_DAY))
FROM TI_DATE
WHERE (FE_MO = 02 AND FE_YEAR in ('2011', '2012'))
GROUP BY FE_DAY
But the answer was 57, different of the number of rows, that I need.
Hi all,
First try the test case please:
http://lemon-factory.net/test/font-face-and-canvas.html
I'm not good at English, so I made the test case to be self-explanatory.
On the first click to the DRAW button, it will not draw text, or will draw with an incorrect typeface instead of the specified "PressStart", according to your browser. After then it works as expected.
At the first time the text does not appear correctly in all browsers I've tested (Firefox, Google Chrome, Safari, Opera).
Is it the standard behavior or something?
Thank you.
PS: Following is the code of the test case
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=Content-Type content="text/html;charset=utf-8">
<title>@font-face and canvas</title>
<style>
@font-face {
font-family: 'PressStart';
src: url('http://lemon-factory.net/css/fonts/prstart.ttf');
}
canvas, pre {
border: 1px solid #666;
}
pre {
float: left;
margin: .5em;
padding: .5em;
}
</style>
</head>
<body>
<div>
<canvas id=canvas width=250 height=250>
Your browser does not support the CANVAS element.
Try the latest Firefox, Google Chrome, Safari or Opera.
</canvas>
<button>DRAW</button>
</div>
<pre id=style></pre>
<pre id=script></pre>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
var canvas = document.getElementById('canvas')
var ctx = canvas.getContext('2d')
var x = 30
var y = 10
function draw() {
ctx.font = '12px PressStart'
ctx.fillStyle = '#000'
ctx.fillText('Hello, world!', x, y += 20)
ctx.fillRect(x - 20, y - 10, 10, 10)
}
$('button').click(draw)
$('pre#style').text($('style').text())
$('pre#script').text($('script').text())
</script>
</body>
</html>
i have been trying to create a vertical bar chart with a d3 fisheye cartesian distortion with only the x-axis being distorted.
I have succeeded in distorting the x position of the vertical bars on mouseover with the following code:
var maxMag = d3.max(dataset, function(d) { return d.value[10]; });
var minDate = d3.min(dataset, function(d) { return new Date(d.value[1], d.value[2]-1, d.value[3]).getTime(); });
var maxDate = d3.max(dataset, function(d) { return new Date(d.value[1], d.value[2]-1, d.value[3]).getTime(); });
var yScale = d3.scale.linear().domain([0, maxMag]).range([0, h]);
var xScale = d3.fisheye.scale(d3.scale.linear).domain([minDate, maxDate]).range([0, w]).focus(w/2);
var bar = svg.append("g")
.attr("class", "bars")
.selectAll(".bar")
.data(dataset)
.enter().append("rect")
.attr("class", "bar")
.attr("y", function(d) {
return h - yScale(d.value[10]);
})
.attr("width", w/dataset.length)
.attr("height", function(d) {
return yScale(d.value[10]);
})
.attr("fill", function(d) {
return (d.value[10] <= 6? "yellow" : "orange" );
})
.call(position);
// Positions the bars based on data.
function position(bar) {
bar.attr("x", function(d) {
var date = null;
if (d.date != null) {
date = d.date;
} else {
date = new Date(d.value[1],0,1);
if (d.value[2] != null) date.setMonth(d.value[2]-1);
if (d.value[3] != null) date.setMonth(d.value[3]);
d.date = date;
}
return xScale(date.getTime());
});
}
svg.on("mousemove", function() {
var mouse = d3.mouse(this);
xScale.distortion(2.5).focus(mouse[0]);
bar.call(position);
});
However at this point, applying fisheye on the width remains a mystery to me. I have tried several methods like using a fisheye scale for width however it does not work as expected.
What i wish to do is to have the width of a bar expand on mouseover, the same way a single vertical bar is singled out on mouseover with the cartesian distortion.
Any clues or help will be much appreciated!
edit: http://dexter.xumx.me to view the visualisation i am talking about for easier understanding!
What is the best way to get formatted Int32 numbers?
Let say I have this o function:
string o(int x);
This is the value that o need to return according to x
x = 0 => o = 00
x = 1 => o = 01
x = 5 => o = 05
x = 10 => o = 10
x = 31 => o = 31
x = 106 => o = 106
Why does this script return a pair of nulls? I'm using SQL Server 2008, script run in MSSMS.
CREATE PROCEDURE proc_Test
(
@Input int,
@Out1 int OUTPUT,
@Out2 varchar(10) OUTPUT
)
AS
BEGIN
SET NOCOUNT OFF
SET @Out1 = 100 + @Input
SET @Out2 = 'result=' + CONVERT(varchar,@Out1)
RETURN
END
GO
DECLARE @Out1 int, @Out2 varchar(10)
exec proc_Test @Input=1, @Out1=@Out1, @Out2=@Out2
select @Out1, @Out2
I have the following serialized XML:
DataDescriptor
<d5p1:TimePastToInitializeData >
<d5p1:Hours>2</d5p1:Hours>
<d5p1:Minutes>10</d5p1:Minutes>
<d5p1:Seconds>5</d5p1:Seconds>
</d5p1:TimePastToInitializeData>
<d5p1:PollRate >
<d5p1:Hours>2</d5p1:Hours>
<d5p1:Minutes>10</d5p1:Minutes>
<d5p1:Seconds>5</d5p1:Seconds>
</d5p1:PollRate>
</Value>
</KeyValueOfstringanyType>
With this order, the PollRate property is not constructed and the resulting deserialized object has a null value for this field.
If, however, I change the order as follows:
DataDescriptor
<d5p1:PollRate >
<d5p1:Hours>2</d5p1:Hours>
<d5p1:Minutes>10</d5p1:Minutes>
<d5p1:Seconds>5</d5p1:Seconds>
</d5p1:PollRate>
<d5p1:TimePastToInitializeData >
<d5p1:Hours>2</d5p1:Hours>
<d5p1:Minutes>10</d5p1:Minutes>
<d5p1:Seconds>5</d5p1:Seconds> </d5p1:TimePastToInitializeData>
</Value>
</KeyValueOfstringanyType>
both properties PollRate and TimePastToInitializeData are constructed and initialized properly.
public class DataDescriptor
{
RefreshRate pastTime;
[DataMember]
public RefreshRate TimePastToInitializeData
{
get; set;
}
RefreshRate pollRate;
[DataMember]
public RefreshRate PollRate
{
get; set;
}
[OnDeserializing]
void Initialize(StreamingContext c)
{
// should I do this??
}
}
And RefreshRate:
[DataContract( Namespace = "http//www.emssatcom.com/occ600")]
[Serializable]
public class RefreshRate : Observable
{
public RefreshRate()
{ }
int hours;
[DataMember]
public int Hours
{
get; set;
}
int mins;
[DataMember]
public int Minutes
{
get; set;
}
int secs;
[DataMember]
public int Seconds
{
get; set;
}
int ms;
[DataMember]
public int MilliSeconds
{
get; set;
}
}
I have a list called cols with column names in it:
cols <- c('Column1','Column2','Column3')
I'd like to reproduce this command, but with a call to the list:
data.frame(Column1=rnorm(10))
Here's what happens when I try it:
> data.frame(cols[1]=rnorm(10))
Error: unexpected '=' in "data.frame(I(cols[1])="
The same thing happens if I wrap cols[1] in I() or eval().
How can I feed that item from the vector into the data.frame() command?
Good afternoon, I wrote a project to Get Park Queue Info from the IBM MQ, it has producing an error when attempting to close the connection though. It is written in java.
Under application in Event Viewer on the MQ machine it displays two errors. They are:
“Channel program ended abnormally.
Channel program ‘system.def.surconn’ ended abnormally. Look at previous error messages for channel program ‘system.def.surconn’ in the error files to determine the cause of the failure.
The other message states:
“Error on receive from host rnanaj (10.10.12.34)
An error occurred receiving data from rnanaj (10.10.12.34) over tcp/ip. This may be due to a communications failure. The return code from tcp/ip recv() call was 10054 (X’2746’). Record these values.”
This must be something how I try to connect or close the connection, below I have my code to connect and close, any ideas??
Connect:
_logger.info("Start");
File outputFile = new File(System.getProperty("PROJECT_HOME"), "run/" + this.getClass().getSimpleName() + "." + System.getProperty("qmgr") + ".txt");
FileUtils.mkdirs(outputFile.getParentFile());
Connection jmsConn = null;
Session jmsSession = null;
QueueBrowser queueBrowser = null;
BufferedWriter commandsBw = null;
try {
// get queue connection
MQConnectionFactory MQConn = new MQConnectionFactory();
MQConn.setHostName(System.getProperty("host"));
MQConn.setPort(Integer.valueOf(System.getProperty("port")));
MQConn.setQueueManager(System.getProperty("qmgr"));
MQConn.setChannel("SYSTEM.DEF.SVRCONN");
MQConn.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
jmsConn = (Connection) MQConn.createConnection();
jmsSession = jmsConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue jmsQueue = jmsSession.createQueue("PARK");
// browse thru messages
queueBrowser = jmsSession.createBrowser(jmsQueue);
Enumeration msgEnum = queueBrowser.getEnumeration();
commandsBw = new BufferedWriter(new FileWriter(outputFile));
//
String line = "DateTime\tMsgID\tOrigMsgID\tCorrelationID\tComputerName\tSubsystem\tDispatcherName\tProcessor\tJobID\tErrorMsg";
commandsBw.write(line);
commandsBw.newLine();
while (msgEnum.hasMoreElements()) {
Message message = (Message) msgEnum.nextElement();
line = dateFormatter.format(new Date(message.getJMSTimestamp()))
+ "\t" + message.getJMSMessageID()
+ "\t" + message.getStringProperty("pkd_orig_jms_msg_id")
+ "\t" + message.getJMSCorrelationID()
+ "\t" + message.getStringProperty("pkd_computer_name")
+ "\t" + message.getStringProperty("pkd_subsystem")
+ "\t" + message.getStringProperty("pkd_dispatcher_name")
+ "\t" + message.getStringProperty("pkd_processor")
+ "\t" + message.getStringProperty("pkd_job_id")
+ "\t" + message.getStringProperty("pkd_sysex_msg");
_logger.info(line);
commandsBw.write(line);
commandsBw.newLine();
}
}
Close:
finally {
IO.close(commandsBw);
if (queueBrowser != null) { try { queueBrowser.close();} catch (Exception ignore) {}}
if (jmsSession != null) { try { jmsSession.close();} catch (Exception ignore) {}}
if (jmsConn != null) { try { jmsConn.stop();} catch (Exception ignore) {}}
}
Just a little confused here...
I have a function in postgres, and when I'm at the pg prompt, I just do:
SELECT zp('zc',10,20,90);
FETCH ALL FROM zc;
I'm wondering how to do this from php?
I thought I could just do:
$q = pg_query("SELECT zp('zc',10,20,90)");
But, how do I "fetch" from that query?
How to handle the case where the token 'for' is used in two different situations in the language to parse? Such as statement and as a "parameter" as the following example:
echo for print example
for i in {0..10..2}
do
echo "Welcome $i times"
done
Output:
for print example
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times
Thanks.
In VB6 there are local static variables that keep their values after the exit of procedure. It's like using public vars but on local block. For example:
sub count()
static x as integer
x = x + 1
end sub
After 10 calls, x will be 10. I tried to search the same thing in .NET (and even Java) but there was none. Why? Does it break the OOP model in some way, and is there a way to emulate that.
I can't figure out why this query would be so slow with variables versus without them. I read some where that I need to enable "Dynamic Parameters" but I cannot find where to do this.
DECLARE
@BeginDate AS DATETIME
,@EndDate AS DATETIME
SELECT
@BeginDate = '2010-05-20'
,@EndDate = '2010-05-25'
-- Fix date range to include time values
SET @BeginDate = CONVERT(VARCHAR(10), ISNULL(@BeginDate, '01/01/1990'), 101) + ' 00:00'
SET @EndDate = CONVERT(VARCHAR(10), ISNULL(@EndDate, '12/31/2099'), 101) + ' 23:59'
SELECT
*
FROM
claim c
WHERE
(c.Received_Date BETWEEN @BeginDate AND @EndDate) --this is much slower
--(c.Received_Date BETWEEN '2010-05-20' AND '2010-05-25') --this is much faster
I have a query to a database that returns a number X of results. I am looking to return a maximum of 10 results. Is there a way to do this without using LIMIT 0,9? I'll use LIMIT if I have to, but I'd rather use something else that will literally stop the searching, rather than look at all rows and then only return the top 10.
What happens in mysql multiple records insert during an error. I have a table:
id | value
2 | 100
UNIQUE(id)
Now i try to execute the query:
INSERT INTO table(id, value) VALUES (1,10),(2,20),(3,30)
I will get a duplicate-key error for the (2,20) BUT... Will the (1,10) get into the database? Will the (3,30) get into the database?
I have a table with a composite primary key using four columns.
mysql> describe leaguesummary;
+------------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+------------------+------+-----+---------+----------------+
| leagueid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| leaguetype | enum('I','T') | NO | PRI | NULL | |
| leagueparticipantid | int(10) unsigned | NO | PRI | NULL | |
| leaguestandard | int(10) unsigned | NO | | NULL | |
| leaguedivision | varchar(5) | NO | PRI | NULL | |
| leagueposition | int(10) unsigned | NO | | NULL | |
I have the league object modelled as so (all plain enough mappings)
<?php
class Model_DbTable_League extends Zend_Db_Table_Abstract
{
protected $_name = 'league';
protected $_primary = 'id';
protected $_dependentTables = array('Model_DbTable_LeagueSummary');
And I've started like this on the new model class. I've mapped a simple reference map which returns all rows linked to the league id.
// http://files.zend.com/help/Zend-Framework/zend.db.table.relationships.html
// http://naneau.nl/2007/04/21/a-zend-framework-tutorial-part-one/
class Model_DbTable_LeagueSummary extends Zend_Db_Table_Abstract {
protected $_name = "leaguesummary";
protected $_primary = array('leagueid', 'leaguetype','leagueparticipantid','leaguedivision');
protected $_referenceMap = array(
'Summary' => array(
'columns' => array('leagueid'),
'refTableClass' => 'Model_DbTable_League',
'refColumns' => array('id')
),
.....
);
}
?>
The simple case works when called from my controller
public function listAction()
{
// action body
$leagueTable = new Model_DbTable_League();
$this->view->leagues = $leagueTable->getLeagues();
$league = $leagueTable->getLeague(6);
// work
$summary = $league->findDependentRowset('Model_DbTable_LeagueSummary','Summary');
Zend_Debug::dump($summary,"",true);
I'm not sure how i can define extra _referenceMap keys which will take extra contraint ket values. I would like to be able to define a set called 'MenA' in which the type and division values are hardcoded, and the league id is taken from the initial rowset.
'MenA' =>array(
'columns' => array('leagueid','leaguetype','leaguedivision'),
'refTableClass' => 'Model_DbTable_League',
'refColumns' => array("id","I","A")
)
Is this style of mapping possible ie hardcoding the values into the 'refColumns'. The second crazy idea i had was to pass the variable values in as part of the third param of the findDependentRowset() method.
$menA = $league->findDependentRowset('Model_DbTable_LeagueSummary','MenA',array("I","A"));
Any suggestions on how I might use the Zend DB Table Relationship mapping correctly to do this would be appreciated. I'm not interested in the plain, old and ugly $db-select(a,b,c)-where(..) style solution.
Hi,
I am trying to break away from using tables in my formatting, and am trying out using userlist html tags <ul>
Say I have a panel with 10 controls, and I want a 3 columns display, therefore 3 controls in each row, and a total of 4 rows for 10 controls.
Should I use 4 different <ul> or should I just stack them inside one <ul>
Please tell me the advantages and disadvantages
Thanks
Hi,
When using something like: ab -n 1000 -c 10 h t t p : / / localhost / ci
I get about 380 requests/sec.
When using: ab -n 1000 -c 10 h t t p : / / localhost / ci /
I get about 12 requests/sec.
Does anyone knows what's going on?
Thanks
Is it possible to update the same view with new data? Using UPDATE after CREATE didn't seem to work.
Create view ID 1-10 if it does not exist.
.
. //
. //
.
Update view **ID** 2-10
Any help is appreciated.
Hello,
I need to create a script file with the Insert statements for the records I select in the mysql table.
For Instance, when i do Select * from emp where empid = 5, and say i get 10 records as result.
Now I should create a script file with the insert statements of that 10 records to emp table.
I am using C# as code behind...
How?
Hello. How can I remove the first number in a string? Say if I had these 48 numbers seperated with a ',' (comma):
8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35,8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35
How would I remove the "8," from the string? Thanks.