Affect on the system after revoking and requesting the certificate from
other system
What will be the affect on the system with the certificate which is being
revoked and requested from the other system.
Thursday, 3 October 2013
Wednesday, 2 October 2013
Zooming with AVCaptureDevice and AVCaptureSession
Zooming with AVCaptureDevice and AVCaptureSession
I have a photo app when I want to support zooming up to 4x without
pixelation. Currently I zoom by transforming the whole view:
previewImageView.transform = CGAffineTransformMakeScale(value, value);
This pixelates my image view, and is especially noticeable at my desired
max zoom (4x). Is there a way to get a higher res preview for zooming?
Currently I'm using AVCaptureSessionPresetHigh, but I want something up to
4x higher resolution. How do I get a high resolution preview?
Maybe I could use AVCaptureSessionPresetInputPriority could work? Any tips?
Or is there an easier, more performant way to do this within GPUImage?
I have a photo app when I want to support zooming up to 4x without
pixelation. Currently I zoom by transforming the whole view:
previewImageView.transform = CGAffineTransformMakeScale(value, value);
This pixelates my image view, and is especially noticeable at my desired
max zoom (4x). Is there a way to get a higher res preview for zooming?
Currently I'm using AVCaptureSessionPresetHigh, but I want something up to
4x higher resolution. How do I get a high resolution preview?
Maybe I could use AVCaptureSessionPresetInputPriority could work? Any tips?
Or is there an easier, more performant way to do this within GPUImage?
Onclick action without onclick event handler
Onclick action without onclick event handler
I try to automate some task, but I don't know how to invoke event that is
used on this span:
<span id="item_mini_111706652_ss_selection" class="item_mini_111706652
miniview rarity1 ss_items ss_group_0 slot_Sworn Sword" style=" "></span>
When I click it, site changes, but I don't know how to invoke that action
with code. Could anyone help me with this? It's invoked on click. So I
tried .click() .onclick() .mouseup() .onmouseup() but noone of them works.
Do you have any idea how could it be invoked or how could I find out?
I try to automate some task, but I don't know how to invoke event that is
used on this span:
<span id="item_mini_111706652_ss_selection" class="item_mini_111706652
miniview rarity1 ss_items ss_group_0 slot_Sworn Sword" style=" "></span>
When I click it, site changes, but I don't know how to invoke that action
with code. Could anyone help me with this? It's invoked on click. So I
tried .click() .onclick() .mouseup() .onmouseup() but noone of them works.
Do you have any idea how could it be invoked or how could I find out?
[solved]Mutithreading and anonymous classes and objects
[solved]Mutithreading and anonymous classes and objects
public class Deadlock {
static class Friend {
private final String name;
public Friend(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public synchronized void bow(Friend bower) {
System.out.format("%s: %s"
+ " has bowed to me!%n",
this.name, bower.getName());
bower.bowBack(this);
}
public synchronized void bowBack(Friend bower) {
System.out.format("%s: %s"
+ " has bowed back to me!%n",
this.name, bower.getName());
}
}
public static void main(String[] args) {
final Friend alphonse =
new Friend("Alphonse");
final Friend gaston =
new Friend("Gaston");
new Thread(new Runnable() {
public void run() { alphonse.bow(gaston); }
}).start();
new Thread(new Runnable() {
public void run() { gaston.bow(alphonse); }
}).start();
}
}
/*
new Thread(new Runnable() {
public void run() { gaston.bow(alphonse); }
}).start();
*/
in the above code , we are creating a new Thread by creating an anonymous
object of an anonymous class ( a subclass of the Runnable interface? )
but what when we pass this new Runnable object, it has ITS OWN run()
method overloaded.so the *new Thread object still does not have its run()
method overloaded.*the call by new Thread(....).start is to the run () of
the thread which is still not overridden!! am i getting it wrong , cause
this code works
public class Deadlock {
static class Friend {
private final String name;
public Friend(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public synchronized void bow(Friend bower) {
System.out.format("%s: %s"
+ " has bowed to me!%n",
this.name, bower.getName());
bower.bowBack(this);
}
public synchronized void bowBack(Friend bower) {
System.out.format("%s: %s"
+ " has bowed back to me!%n",
this.name, bower.getName());
}
}
public static void main(String[] args) {
final Friend alphonse =
new Friend("Alphonse");
final Friend gaston =
new Friend("Gaston");
new Thread(new Runnable() {
public void run() { alphonse.bow(gaston); }
}).start();
new Thread(new Runnable() {
public void run() { gaston.bow(alphonse); }
}).start();
}
}
/*
new Thread(new Runnable() {
public void run() { gaston.bow(alphonse); }
}).start();
*/
in the above code , we are creating a new Thread by creating an anonymous
object of an anonymous class ( a subclass of the Runnable interface? )
but what when we pass this new Runnable object, it has ITS OWN run()
method overloaded.so the *new Thread object still does not have its run()
method overloaded.*the call by new Thread(....).start is to the run () of
the thread which is still not overridden!! am i getting it wrong , cause
this code works
Tuesday, 1 October 2013
could not display image in jsp form but the url is loaded
could not display image in jsp form but the url is loaded
I am using the above code to display photo. but the photo is not diplayed.
when using the firebug image can be seen at that place. Please help me.
Thanks in advance.
" alt=""/>
I am using the above code to display photo. but the photo is not diplayed.
when using the firebug image can be seen at that place. Please help me.
Thanks in advance.
" alt=""/>
How are Static Variables shared in a Web Session
How are Static Variables shared in a Web Session
I have an mvc webapi service setup that pulls and pushes data from an sql
server database.
Within the Web project holding the webapi I have a Static class that just
holds some global variables that are accessed from the webapi methods.
Following is a very cutdown example of the static class:
public static class SystemProperties
{
public static int currentContactID;
}
When the WebApi is accessed I strip the ContactID from the Http Headers of
the call and set the SystemProperties.CurrentContactID to it.
Than in the methods of the webapi I access
SystemProperties.CurrentContactID for data calls.
I have found a problem when there is concurrent webapi calls the
currentContactID is getting mixed up.
My question is, how is the static class members shared between calling
sessions? Is it going to be pretty much last in best dressed and if the
previous person is still in there than they will get screwed over by the
new person who will overwrite the variables with their details?
Should I be using a different method to store these details?
Thanks in advance
I have an mvc webapi service setup that pulls and pushes data from an sql
server database.
Within the Web project holding the webapi I have a Static class that just
holds some global variables that are accessed from the webapi methods.
Following is a very cutdown example of the static class:
public static class SystemProperties
{
public static int currentContactID;
}
When the WebApi is accessed I strip the ContactID from the Http Headers of
the call and set the SystemProperties.CurrentContactID to it.
Than in the methods of the webapi I access
SystemProperties.CurrentContactID for data calls.
I have found a problem when there is concurrent webapi calls the
currentContactID is getting mixed up.
My question is, how is the static class members shared between calling
sessions? Is it going to be pretty much last in best dressed and if the
previous person is still in there than they will get screwed over by the
new person who will overwrite the variables with their details?
Should I be using a different method to store these details?
Thanks in advance
ms sql in ASP (Classic) Parameter error
ms sql in ASP (Classic) Parameter error
I keep getting an error saying the command Parameters is not valid, how
can I fix this problem? Thanks.
' OPEN DATABASE
dim objConn, strQuery
dim strConnection
set objConn = Server.CreateObject("ADODB.Command")
objConn.ConnectionString = "Driver={SQL Server Native Client
11.0};Server=Master-PC\NMSSQL;Trusted_Connection=no;UID=VISITORDB;PWD=testPWD;database=testDB;"
objConn.Open strConnection
dim objDupCheck
set objDupCheck = Server.CreateObject("ADODB.Command")
set objDupCheck.ActiveConnection = objConn
strQuery = "SELECT * from CHECKS where CHECK_NO = ?"
objConn.Parameters(0) = Request.Form("txtCheckNo")
objDupCheck.Open strQuery
if objDupCheck.EOF then
objDupCheck.Close
end if
I keep getting an error saying the command Parameters is not valid, how
can I fix this problem? Thanks.
' OPEN DATABASE
dim objConn, strQuery
dim strConnection
set objConn = Server.CreateObject("ADODB.Command")
objConn.ConnectionString = "Driver={SQL Server Native Client
11.0};Server=Master-PC\NMSSQL;Trusted_Connection=no;UID=VISITORDB;PWD=testPWD;database=testDB;"
objConn.Open strConnection
dim objDupCheck
set objDupCheck = Server.CreateObject("ADODB.Command")
set objDupCheck.ActiveConnection = objConn
strQuery = "SELECT * from CHECKS where CHECK_NO = ?"
objConn.Parameters(0) = Request.Form("txtCheckNo")
objDupCheck.Open strQuery
if objDupCheck.EOF then
objDupCheck.Close
end if
Clash of Kings: Why didn't Arya reveal who she was=?iso-8859-1?Q?=3F_=96_scifi.stackexchange.com?=
Clash of Kings: Why didn't Arya reveal who she was? – scifi.stackexchange.com
I'm still reading A Clash of Kings for the first time, so please don't
answer with anything that would spoil things for me, but I was wondering:
In the chapter where Roose Bolton finally assumes ...
I'm still reading A Clash of Kings for the first time, so please don't
answer with anything that would spoil things for me, but I was wondering:
In the chapter where Roose Bolton finally assumes ...
Can a Windows Server CA separate code-signing keys from keys for other purposes?
Can a Windows Server CA separate code-signing keys from keys for other
purposes?
I am a software developer. My team encrypts the sensitive sections of our
ASP.NET web.config files. aspnet_regiis.exe is used to manage the local
key store, encrypt and decrypt.
I want to build a quick key-manager tool to avoid remembering its location
and syntax, based on a Powershell script I found using A Well Known Search
Engine. This is blocked by a domain policy:
PS H:\> Get-ExecutionPolicy
Restricted
Before I request that this is changed to RemoteSigned...
If all machines on the intranet were set to RemoteSigned, could a
certificate be created in the Domain CS for a hypothetical code-security
team such that the certificate could not be used for SSL or other
certificate-secured processes?
This would allow lowly devs to write scripts and have them signed without
giving each code reviewer excess trust.
purposes?
I am a software developer. My team encrypts the sensitive sections of our
ASP.NET web.config files. aspnet_regiis.exe is used to manage the local
key store, encrypt and decrypt.
I want to build a quick key-manager tool to avoid remembering its location
and syntax, based on a Powershell script I found using A Well Known Search
Engine. This is blocked by a domain policy:
PS H:\> Get-ExecutionPolicy
Restricted
Before I request that this is changed to RemoteSigned...
If all machines on the intranet were set to RemoteSigned, could a
certificate be created in the Domain CS for a hypothetical code-security
team such that the certificate could not be used for SSL or other
certificate-secured processes?
This would allow lowly devs to write scripts and have them signed without
giving each code reviewer excess trust.
Monday, 30 September 2013
Shell command to get server IP [duplicate]
Shell command to get server IP [duplicate]
This question already has an answer here:
Shell Command for Getting IP Address? 15 answers
What command can I run on a linux server to get just the ip address back.
I know I can run ifconfig eth0, but trying to parse the output and grep
just the ip is quite nasty. Is there a command or elegant solution just to
get back the ip address?
This question already has an answer here:
Shell Command for Getting IP Address? 15 answers
What command can I run on a linux server to get just the ip address back.
I know I can run ifconfig eth0, but trying to parse the output and grep
just the ip is quite nasty. Is there a command or elegant solution just to
get back the ip address?
insert row and get generated ID
insert row and get generated ID
I'm trying to use Spring's JdbcTemplate class to insert a row into a MySQL
table named transaction and get the generated ID. The relevant code is:
public Transaction insertTransaction(final Transaction tran) {
// Will hold the ID of the row created by the insert
KeyHolder keyHolder = new GeneratedKeyHolder();
getJdbcTemplate().update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection
connection) throws SQLException {
PreparedStatement ps =
connection.prepareStatement(INSERT_TRAN_SQL);
ps.setString(1, tran.getTransactionType().toString());
Date sqlDate = new Date(tran.getDate().getTime());
ps.setDate(2, sqlDate);
ps.setString(3, tran.getDescription());
return ps;
}
}, keyHolder);
tran.setId(keyHolder.getKey().longValue());
return tran;
}
But the following exception is thrown by the call to getJdbcTemplate().update
java.sql.SQLException: Generated keys not requested. You need to specify
Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or
Connection.prepareStatement().
Can I insert the row and get the generated ID, without abandoning
JdbcTemplate? I'm using Spring 2.5, MySQL 5.5.27 and MySQL Connector
5.1.26.
I'm trying to use Spring's JdbcTemplate class to insert a row into a MySQL
table named transaction and get the generated ID. The relevant code is:
public Transaction insertTransaction(final Transaction tran) {
// Will hold the ID of the row created by the insert
KeyHolder keyHolder = new GeneratedKeyHolder();
getJdbcTemplate().update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection
connection) throws SQLException {
PreparedStatement ps =
connection.prepareStatement(INSERT_TRAN_SQL);
ps.setString(1, tran.getTransactionType().toString());
Date sqlDate = new Date(tran.getDate().getTime());
ps.setDate(2, sqlDate);
ps.setString(3, tran.getDescription());
return ps;
}
}, keyHolder);
tran.setId(keyHolder.getKey().longValue());
return tran;
}
But the following exception is thrown by the call to getJdbcTemplate().update
java.sql.SQLException: Generated keys not requested. You need to specify
Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or
Connection.prepareStatement().
Can I insert the row and get the generated ID, without abandoning
JdbcTemplate? I'm using Spring 2.5, MySQL 5.5.27 and MySQL Connector
5.1.26.
Phonegap: confusing config files
Phonegap: confusing config files
im trying to get a simple app running on my galaxy s3 using Eclipse with
latest Android SDK. First i downloaded the latest phonegap with the npm
command using "npm install -g phonegap". This installed me the phonegap
and cordova commands.
Using cordova, i created my test app with:
cordova create test "com.helloworld.mobile" "test"
cd test
cordova platform add android
cordova build
all of this worked fine. then i created a new android project in eclipse
using the platforms folder inside test/ as source. Then i coded the
deviceready part which gets triggered successfully. But i have no access
to the device variable to access device info, so i guess i forgot to add
the permissions into the XMLs to get access to my hardware.
Now im confused, which one of these i have to change, and each XML looks
different. I have AndroidManifest.xml in my root folder. Then a config.xml
in my assets/www folder and another config.xml in my res/xml/ folder. Both
config.xml look similar, but are not the same.
I tried different changes using uses-permission or feature or plugin. I
even created plugins.xml in res/xml, but it didnt help. Documentation
doesn't help.
How to set up these config files correctly so i get access to my device
via phonegap? I simply tried to print device.cordova or device.model or
whatever, but device remains undefined, even after deviceready fired off.
PS: Deploying this app on my phone works fine, even the debugger runs, so
i can see the error messages from javascript. so it must be a permission
problem i guess.
im trying to get a simple app running on my galaxy s3 using Eclipse with
latest Android SDK. First i downloaded the latest phonegap with the npm
command using "npm install -g phonegap". This installed me the phonegap
and cordova commands.
Using cordova, i created my test app with:
cordova create test "com.helloworld.mobile" "test"
cd test
cordova platform add android
cordova build
all of this worked fine. then i created a new android project in eclipse
using the platforms folder inside test/ as source. Then i coded the
deviceready part which gets triggered successfully. But i have no access
to the device variable to access device info, so i guess i forgot to add
the permissions into the XMLs to get access to my hardware.
Now im confused, which one of these i have to change, and each XML looks
different. I have AndroidManifest.xml in my root folder. Then a config.xml
in my assets/www folder and another config.xml in my res/xml/ folder. Both
config.xml look similar, but are not the same.
I tried different changes using uses-permission or feature or plugin. I
even created plugins.xml in res/xml, but it didnt help. Documentation
doesn't help.
How to set up these config files correctly so i get access to my device
via phonegap? I simply tried to print device.cordova or device.model or
whatever, but device remains undefined, even after deviceready fired off.
PS: Deploying this app on my phone works fine, even the debugger runs, so
i can see the error messages from javascript. so it must be a permission
problem i guess.
Javascript how to use the and/or operator with parenthesis
Javascript how to use the and/or operator with parenthesis
I have an object that contains a string HelloWorld in the attribute hello.
I want to check for two strings, and if it does not match with either one,
then I want to execute certain code.
var item = { hello: "HelloWorld" }
item.hello !== "HelloWorld" && item.hello !== "GoodbyeWorld" // false,
correct
However, I feel this can be optimized and made more readable:
item.hello !== ("GoodbyeWorld" && "HelloWorld") // false, correct
item.hello !== ("HelloWorld" && "GoodbyeWorld") // true WTF?
I expected both checks to be falsy, but surely I'm missing something here.
I think I do not have a correct understanding of the AND/OR operator in
javascript, or I am using the parenthesis in a wrong manner. Can anyone
explain?
JSFiddle example
I have an object that contains a string HelloWorld in the attribute hello.
I want to check for two strings, and if it does not match with either one,
then I want to execute certain code.
var item = { hello: "HelloWorld" }
item.hello !== "HelloWorld" && item.hello !== "GoodbyeWorld" // false,
correct
However, I feel this can be optimized and made more readable:
item.hello !== ("GoodbyeWorld" && "HelloWorld") // false, correct
item.hello !== ("HelloWorld" && "GoodbyeWorld") // true WTF?
I expected both checks to be falsy, but surely I'm missing something here.
I think I do not have a correct understanding of the AND/OR operator in
javascript, or I am using the parenthesis in a wrong manner. Can anyone
explain?
JSFiddle example
Sunday, 29 September 2013
Should my Play services always be asynchronous calls with promises?
Should my Play services always be asynchronous calls with promises?
I just read that it is recommended to use asynchronous method calls on the
server via promises when executing long running requests. The
documentation says this is because the Play server will block on the
request and not be able to handle concurrent requests.
Does this mean all of my web requests should be asynchronous?
I'm just thinking that if I want to to increase my web pages rendering
times that I would make a series of ajax calls to fetch needed page
regions concurrently. Since I would potentially make multiple ajax calls,
my Play controller methods need to be asynchronous.
Am I understanding this correctly? The syntax is quite verbose so I want
to make certain I don't take this concept overboard. It would seem strange
to me that I have to do this given other web severs such as Glassfish or
IIS automatically handle pooling.
I just read that it is recommended to use asynchronous method calls on the
server via promises when executing long running requests. The
documentation says this is because the Play server will block on the
request and not be able to handle concurrent requests.
Does this mean all of my web requests should be asynchronous?
I'm just thinking that if I want to to increase my web pages rendering
times that I would make a series of ajax calls to fetch needed page
regions concurrently. Since I would potentially make multiple ajax calls,
my Play controller methods need to be asynchronous.
Am I understanding this correctly? The syntax is quite verbose so I want
to make certain I don't take this concept overboard. It would seem strange
to me that I have to do this given other web severs such as Glassfish or
IIS automatically handle pooling.
Jersey + HK2 + Grizzly: Proper way to inject EntityManager?
Jersey + HK2 + Grizzly: Proper way to inject EntityManager?
I've managed to set up injection (into resource classes) of my own service
classes in Jersey, HK2 and a plain GrizzlyServer. (Basically followed this
example.)
I'm now curious what the best is to inject JPA EntityManagers into my
resource classes? (I'm currently considering one request as one unit of
work). One option that I'm currently exploring is to use a
Factory<EntityManager> in the following way:
class MyEntityManagerFactory implements Factory<EntityManager> {
EntityManagerFactory emf;
public MyEntityManagerFactory() {
emf = Persistence.createEntityManagerFactory("manager1");
}
@Override
public void dispose(EntityManager em) {
em.close();
}
@Override
public EntityManager provide() {
return emf.createEntityManager();
}
}
and bind it as follows:
bindFactory(new MyEntityManagerFactory())
.to(EntityManager.class)
.in(RequestScoped.class);
The problem is that the dispose-method is never invoked.
My questions:
Is this the right approach to injecting EntityManagers in Jersey+HK2?
If so, how should I make sure my EntityManagers are closed properly?
(I'd rather not depend on heavy weight containers or an extra
dependency-injection library just to cover this use case.)
I've managed to set up injection (into resource classes) of my own service
classes in Jersey, HK2 and a plain GrizzlyServer. (Basically followed this
example.)
I'm now curious what the best is to inject JPA EntityManagers into my
resource classes? (I'm currently considering one request as one unit of
work). One option that I'm currently exploring is to use a
Factory<EntityManager> in the following way:
class MyEntityManagerFactory implements Factory<EntityManager> {
EntityManagerFactory emf;
public MyEntityManagerFactory() {
emf = Persistence.createEntityManagerFactory("manager1");
}
@Override
public void dispose(EntityManager em) {
em.close();
}
@Override
public EntityManager provide() {
return emf.createEntityManager();
}
}
and bind it as follows:
bindFactory(new MyEntityManagerFactory())
.to(EntityManager.class)
.in(RequestScoped.class);
The problem is that the dispose-method is never invoked.
My questions:
Is this the right approach to injecting EntityManagers in Jersey+HK2?
If so, how should I make sure my EntityManagers are closed properly?
(I'd rather not depend on heavy weight containers or an extra
dependency-injection library just to cover this use case.)
asp.net mvc4 admin enviroment seperate from public
asp.net mvc4 admin enviroment seperate from public
I am writing a new asp.net mvc4 web application which consist of a public
environment and separate an admin environment, now I'm wondering what is
the best practice to do this.
I would like the the admins to login at mysite.com/admin.
I am writing a new asp.net mvc4 web application which consist of a public
environment and separate an admin environment, now I'm wondering what is
the best practice to do this.
I would like the the admins to login at mysite.com/admin.
getting an unexpected behavior when calling a php function from javascript
getting an unexpected behavior when calling a php function from javascript
i'm using ajax to call a php function from javascript, but i got confused
with the results, i have this on my php functions file :
<?php
if(isset($_GET['function']) && isset($_GET['value']) ){
if($_GET['function'] == "hey"){
echo user_exists($_GET['value']) ? "true": "false";
}
}
function user_exists($username){
$username = sanitize($username);
$query = mysql_query("SELECT COUNT('user_id') FROM users WHERE
username = '$username'");
return (mysql_result($query, 0) == 1) ? true : false;
}
and on my registration file, where i'm writing my javascript :
<script>
//some code here
var x;
the_user_exist(element.value);
//element is just a variable containing the getElementById... stuff
console.log(x);
if( x == "true" ){
document.getElementById('err'+id).innerHTML ="<img
src=\"css/images/cross.png\"></img>";
fields_state[ctrl] = 0;
}else {
document.getElementById('err'+id).innerHTML ="<img
src=\"css/images/tick.png\"></img>";
fields_state[ctrl] = 1;
}
//ajax funct
function the_user_exist(str){
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
console.log('1');
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
console.log('3');
x = xmlhttp.responseText;
}
}
xmlhttp.open("GET","core/functions/users.php?function=hey&value="+str,true);
xmlhttp.send();
console.log('2');
}
//some code here
</script>
if you follow the console.log(1) ,2 and 3 and x, the result of logging on
chrome was: 1 2 undefined 3 true like if javascript tests are running
before the ajax work is finished, when i changed the true to false in :
xmlhttp.open("GET","core/functions/users.php?function=hey&value="+str,false);
it worked fine in Chrome not in Firefox,
i need some explanation of what is wrong with what i am doing more than
giving me a code.
i'm using ajax to call a php function from javascript, but i got confused
with the results, i have this on my php functions file :
<?php
if(isset($_GET['function']) && isset($_GET['value']) ){
if($_GET['function'] == "hey"){
echo user_exists($_GET['value']) ? "true": "false";
}
}
function user_exists($username){
$username = sanitize($username);
$query = mysql_query("SELECT COUNT('user_id') FROM users WHERE
username = '$username'");
return (mysql_result($query, 0) == 1) ? true : false;
}
and on my registration file, where i'm writing my javascript :
<script>
//some code here
var x;
the_user_exist(element.value);
//element is just a variable containing the getElementById... stuff
console.log(x);
if( x == "true" ){
document.getElementById('err'+id).innerHTML ="<img
src=\"css/images/cross.png\"></img>";
fields_state[ctrl] = 0;
}else {
document.getElementById('err'+id).innerHTML ="<img
src=\"css/images/tick.png\"></img>";
fields_state[ctrl] = 1;
}
//ajax funct
function the_user_exist(str){
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
console.log('1');
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
console.log('3');
x = xmlhttp.responseText;
}
}
xmlhttp.open("GET","core/functions/users.php?function=hey&value="+str,true);
xmlhttp.send();
console.log('2');
}
//some code here
</script>
if you follow the console.log(1) ,2 and 3 and x, the result of logging on
chrome was: 1 2 undefined 3 true like if javascript tests are running
before the ajax work is finished, when i changed the true to false in :
xmlhttp.open("GET","core/functions/users.php?function=hey&value="+str,false);
it worked fine in Chrome not in Firefox,
i need some explanation of what is wrong with what i am doing more than
giving me a code.
Saturday, 28 September 2013
AVR usart communcation with arduino
AVR usart communcation with arduino
I am trying to setup up a basic serial communcation link between an
ATMEGA8515 and an Arduino Uno. I am Putty connection to the correct com
port I can see the Arudino print "got:got:" in burst of two going with the
delay. So the problem is that the Arduino is recognizing that something is
being transmitted but not getting any characters.
I've been trying to use the transmit code on page 143 of the datasheet in
my main loop:
int main(void)
{
//Baud is 9600
USART_Init(USART_BAUDRATE);
//init interrupt
sei();
DDRA |= _BV(DDA6);
while(1)
{
USART_Transmit("a\n");
_delay_ms(5000);
}
}
And trying to recieve the serial using this code taken from here:
char val; // variable to receive data from the serial port
void setup() {
Serial.begin(9600); // start serial communication at 9600bps
}
void loop() {
if( Serial.available() ) // if data is available to read
{
val = Serial.read(); // read it and store it in 'val'
Serial.print("got:"+val);
}
delay(100); // wait 100ms for next reading
}
This results in "got:" being printed twice every 5 seconds:
I hooked up an LED to the TX line of the AVR and can see when its
tranmitting. The TX line of the AVR is hooked into the RX line of the
arduino and the same fasion for AVR RX.
Any ideas why I can't see the char that i'm trying to transmit?
I am trying to setup up a basic serial communcation link between an
ATMEGA8515 and an Arduino Uno. I am Putty connection to the correct com
port I can see the Arudino print "got:got:" in burst of two going with the
delay. So the problem is that the Arduino is recognizing that something is
being transmitted but not getting any characters.
I've been trying to use the transmit code on page 143 of the datasheet in
my main loop:
int main(void)
{
//Baud is 9600
USART_Init(USART_BAUDRATE);
//init interrupt
sei();
DDRA |= _BV(DDA6);
while(1)
{
USART_Transmit("a\n");
_delay_ms(5000);
}
}
And trying to recieve the serial using this code taken from here:
char val; // variable to receive data from the serial port
void setup() {
Serial.begin(9600); // start serial communication at 9600bps
}
void loop() {
if( Serial.available() ) // if data is available to read
{
val = Serial.read(); // read it and store it in 'val'
Serial.print("got:"+val);
}
delay(100); // wait 100ms for next reading
}
This results in "got:" being printed twice every 5 seconds:
I hooked up an LED to the TX line of the AVR and can see when its
tranmitting. The TX line of the AVR is hooked into the RX line of the
arduino and the same fasion for AVR RX.
Any ideas why I can't see the char that i'm trying to transmit?
Bootstrap 3 and Sticky Footer
Bootstrap 3 and Sticky Footer
for the past hour I've been trying to figure out what exactly is wrong
with my sticky footer not working. I have the exact same structure as the
example given on the getboostrap site, but it doesn't seem to work. Any
ideas what is exactly wrong?
All the bootstrap css files are loaded correctly.
<body style="">
<div id="wrap">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle"
data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Application name</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
<li><a href="/Home/About">About</a></li>
<li><a href="/Home/Contact">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/Account/Register" id="registerLink">Register</a></li>
<li><a href="/Account/Login" id="loginLink">Log in</a></li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="jumbotron">
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web
sites and Web applications using HTML, CSS and JavaScript.</p>
<p><a href="http://asp.net" class="btn btn-primary btn-large">Learn
more »</a></p>
</div>
<div class="row">
<div class="col-md-4">
<h2>Getting started</h2>
<p>
ASP.NET MVC gives you a powerful, patterns-based way to build
dynamic websites that
enables a clean separation of concerns and gives you full
control over markup
for enjoyable, agile development.
</p>
<p><a class="btn btn-default"
href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more
»</a></p>
</div>
<div class="col-md-4">
<h2>Get more libraries</h2>
<p>NuGet is a free Visual Studio extension that makes it easy to
add, remove, and update libraries and tools in Visual Studio
projects.</p>
<p><a class="btn btn-default"
href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more
»</a></p>
</div>
<div class="col-md-4">
<h2>Web Hosting</h2>
<p>You can easily find a web hosting company that offers the right
mix of features and price for your applications.</p>
<p><a class="btn btn-default"
href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more
»</a></p>
</div>
</div>
</div>
</div>
<div id="footer">
<div class="container">
<p class="text-muted credit">Example courtesy <a
href="http://martinbean.co.uk">Martin Bean</a> and <a
href="http://ryanfait.com/sticky-footer/">Ryan Fait</a>.</p>
</div>
</div>
</body>
for the past hour I've been trying to figure out what exactly is wrong
with my sticky footer not working. I have the exact same structure as the
example given on the getboostrap site, but it doesn't seem to work. Any
ideas what is exactly wrong?
All the bootstrap css files are loaded correctly.
<body style="">
<div id="wrap">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle"
data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Application name</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
<li><a href="/Home/About">About</a></li>
<li><a href="/Home/Contact">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/Account/Register" id="registerLink">Register</a></li>
<li><a href="/Account/Login" id="loginLink">Log in</a></li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="jumbotron">
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web
sites and Web applications using HTML, CSS and JavaScript.</p>
<p><a href="http://asp.net" class="btn btn-primary btn-large">Learn
more »</a></p>
</div>
<div class="row">
<div class="col-md-4">
<h2>Getting started</h2>
<p>
ASP.NET MVC gives you a powerful, patterns-based way to build
dynamic websites that
enables a clean separation of concerns and gives you full
control over markup
for enjoyable, agile development.
</p>
<p><a class="btn btn-default"
href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more
»</a></p>
</div>
<div class="col-md-4">
<h2>Get more libraries</h2>
<p>NuGet is a free Visual Studio extension that makes it easy to
add, remove, and update libraries and tools in Visual Studio
projects.</p>
<p><a class="btn btn-default"
href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more
»</a></p>
</div>
<div class="col-md-4">
<h2>Web Hosting</h2>
<p>You can easily find a web hosting company that offers the right
mix of features and price for your applications.</p>
<p><a class="btn btn-default"
href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more
»</a></p>
</div>
</div>
</div>
</div>
<div id="footer">
<div class="container">
<p class="text-muted credit">Example courtesy <a
href="http://martinbean.co.uk">Martin Bean</a> and <a
href="http://ryanfait.com/sticky-footer/">Ryan Fait</a>.</p>
</div>
</div>
</body>
Out parameter in c#
Out parameter in c#
I am new to C#. I've tried this with out parameter in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class First
{
public void fun(out int m)
{
m *= 10;
Console.WriteLine("value of m = " + m);
}
}
class Program
{
static void Main(string[] args)
{
First f = new First();
int x = 30;
f.fun(out x);
}
}
but i get some errors like "Use of unassigned out parameter 'm'" and
The out parameter 'm' must be assigned to before control leaves the
current method.
So what is the meaning of these errors and why it is compulsory to assign
'm' when i'm already assigned a value to x.
I am new to C#. I've tried this with out parameter in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class First
{
public void fun(out int m)
{
m *= 10;
Console.WriteLine("value of m = " + m);
}
}
class Program
{
static void Main(string[] args)
{
First f = new First();
int x = 30;
f.fun(out x);
}
}
but i get some errors like "Use of unassigned out parameter 'm'" and
The out parameter 'm' must be assigned to before control leaves the
current method.
So what is the meaning of these errors and why it is compulsory to assign
'm' when i'm already assigned a value to x.
Subscribe to:
Posts (Atom)