I found this code snippet:
<?php
$view = views_get_current_view();
$arg0 = $view->args[0];
?>
but i don't know where to begin inserting this php code snippet.
I am coding in Visual Basic. I am using a checkbox control. Now depending on its checked property I need to set/unset a bit column in a SQL Server database. Here's the code:
Try
conSQL.Open()
Dim cmd As New SqlCommand("update Student set send_mail = " + _
sendemailCheckBox.Checked.ToString + " where student_id = '" _
+ sidnolabel.Text + "'", conSQL)
cmd.ExecuteNonQuery()
Finally
conSQL.Close()
End Try
The send_mail attribute is of bit datatype. This code is not working.
How do I go about it?
Like many other developers I have been very excited at the new Swift language from Apple. Apple has boasted its speed is faster than Objective C and can be used to write operating system. And from what I learned so far, it's a very type-safe language and able to have precisely control over the exact data type (like integer length). So it does look like having good potential handling performance critical tasks, like image processing, right?
That's what I thought before I carried out a quick test. The result really surprised me.
Here is a much simplified image alpha blending code snippet in C:
test.c:
#include <stdio.h>
#include <stdint.h>
#include <string.h>
uint8_t pixels[640*480];
uint8_t alpha[640*480];
uint8_t blended[640*480];
void blend(uint8_t* px, uint8_t* al, uint8_t* result, int size)
{
for(int i=0; i<size; i++) {
result[i] = (uint8_t)(((uint16_t)px[i]) *al[i] /255);
}
}
int main(void)
{
memset(pixels, 128, 640*480);
memset(alpha, 128, 640*480);
memset(blended, 255, 640*480);
// Test 10 frames
for(int i=0; i<10; i++) {
blend(pixels, alpha, blended, 640*480);
}
return 0;
}
I compiled it on my Macbook Air 2011 with the following command:
gcc -O3 test.c -o test
The 10 frame processing time is about 0.01s. In other words, it takes the C code 1ms to process one frame:
$ time ./test
real 0m0.010s
user 0m0.006s
sys 0m0.003s
Then I have a Swift version of the same code:
test.swift:
let pixels = UInt8[](count: 640*480, repeatedValue: 128)
let alpha = UInt8[](count: 640*480, repeatedValue: 128)
let blended = UInt8[](count: 640*480, repeatedValue: 255)
func blend(px: UInt8[], al: UInt8[], result: UInt8[], size: Int)
{
for(var i=0; i<size; i++) {
var b = (UInt16)(px[i]) * (UInt16)(al[i])
result[i] = (UInt8)(b/255)
}
}
for i in 0..10 {
blend(pixels, alpha, blended, 640*480)
}
The build command line is:
xcrun swift -O3 test.swift -o test
Here I use the same O3 level optimization flag to make the comparison hopefully fair. However, the resulting speed is 100 time slower:
$ time ./test
real 0m1.172s
user 0m1.146s
sys 0m0.006s
In other words, it takes Swift ~120ms to processing one frame which takes C just 1 ms. I also verified the memory initialization time in both test code are very small compared to the blend processing function time.
What happened?
Hi All,
I am using two frames to display pages. The page url is given in codebehind. But it is not reflecting. If i click f5 its grtting reflected.
Needs:
How to refresh a frame after setting the src value in the code behind.
code: topFrame.Attributes["src"] = "MainPage.aspx";
Geetha.
As a beginner, I finally noticed the issue with making changes to the live server I've been working on, now that I have a couple users on it, since I bring it down so often.
I created an EC2 image of my live server and set up a separate instance on EC2, so now I have 2 EC2 instances, Stage and Production. I set up GitHub and push changes to stage and test my code there, and when it's all done and working, I push it to the production branch, and everything is good. And there is a slight issue here since I name my files config_stage.js and config_production.js and set up .gitignore on each server, and in my code, I would have it read the ENV flags and set up the appropriate configs, is this the correct approach?
And my main question is: how do you keep track of non-code changes to the server? For example, I installed HAProxy, Stunnel, Redis, MongoDB and several other things onto the Stage server for testing and now that it's all working and good, how do I deploy them to production? Right now, I'm just keeping track of everything I installed and copying configuration files over, which is very tedious and I'm afraid I may have missed a step somewhere.
Is there a better way to port these changes over from my test server to my live server?
My current code:
wp_enqueue_style( 'script-css', plugins_url( 'script/myscript.js', FILE ));
My goal:
Instead of loading the file from the plugins directory, I want to load above script file from http://mycloudfronturl.net/myscript.js
But somehow I am messing with either the quotes or while replacing the plugins_url. I am not a hard code php coder, so can someone tell me what to do please?
Thanks and Regards,
Amod
A very poor style to code but sometimes unavoidable. It is an extreme example. So
is there some limit for nesting classes?
are they equivalent?
how do you deal with such situations? Create library?
Code
new FileObject().new Format().new Words().new Some().new Continue someThing;
((((new FileObject()).new Format()).new Words()).new Some()).new Continue someThing;
I'm trying to write a simple/small Windows Communication Foundation service application in Visual Basic (but I am very novice in VB) and all the good examples I've found on the net are written in C#. So far I've gotten my WCF service application working but now I'm trying to add callback functionality and the program has gotten more complicated. In the C# example code I understand how everything works but I am having trouble translating into VB the portion of code that uses a delegate. Can someone please show the VB equivalent?
Here is the C# code sample I'm using for reference:
namespace WCFCallbacks
{
using System;
using System.ServiceModel;
[ServiceContract(CallbackContract = typeof(IMessageCallback))]
public interface IMessage
{
[OperationContract]
void AddMessage(string message);
[OperationContract]
bool Subscribe();
[OperationContract]
bool Unsubscribe();
}
interface IMessageCallback
{
[OperationContract(IsOneWay = true)]
void OnMessageAdded(string message, DateTime timestamp);
}
}
namespace WCFCallbacks
{
using System;
using System.Collections.Generic;
using System.ServiceModel;
public class MessageService : IMessage
{
private static readonly List<IMessageCallback> subscribers = new List<IMessageCallback>();
//The code in this AddMessage method is what I'd like to see re-written in VB...
public void AddMessage(string message)
{
subscribers.ForEach(delegate(IMessageCallback callback)
{
if (((ICommunicationObject)callback).State == CommunicationState.Opened)
{
callback.OnMessageAdded(message, DateTime.Now);
}
else
{
subscribers.Remove(callback);
}
});
}
public bool Subscribe()
{
try
{
IMessageCallback callback = OperationContext.Current.GetCallbackChannel<IMessageCallback>();
if (!subscribers.Contains(callback))
subscribers.Add(callback);
return true;
}
catch
{
return false;
}
}
public bool Unsubscribe()
{
try
{
IMessageCallback callback = OperationContext.Current.GetCallbackChannel<IMessageCallback>();
if (!subscribers.Contains(callback))
subscribers.Remove(callback);
return true;
}
catch
{
return false;
}
}
}
}
I was thinking I could do something like this but I don't know how to pass the message string from AddMessage to DoSomething...
Dim subscribers As New List(Of IMessageCallback)
Public Sub AddMessage(ByVal message As String) Implements IMessage.AddMessage
Dim action As Action(Of IMessageCallback)
action = AddressOf DoSomething
subscribers.ForEach(action)
'Or this instead of the above three lines:
'subscribers.ForEach(AddressOf DoSomething)
End Sub
Public Sub DoSomething(ByVal callback As IMessageCallback)
'I am also confused by:
'((ICommunicationObject)callback).State
'Is that casting the callback object as type ICommunicationObject?
'How is that done in VB?
End Sub
I would like to do the following in php :
setcookie('name', $value, $Cookie_Expiration,'/');
then some action
header("location:http://www.example.com")
the problem is that I get :
warning: Cannot modify header information - headers already sent by (...etc )
could you please let me know what i am doing wrong and if there is a way to do this?
by the way , this code is before any output is made ...the cookie setting part works fine on its own and so does the redirection code....the combination fails
thank you
I had VS 11 beta and the following code was working without problem:
let rec fac x y =
if (x = y) then y
elif (x % y = 0I) then fac (x / y) y
else fac x / (y + 1I);;
Now I installed VS 2012 RC and I get the following error:
The type 'System.Numerics.BigInteger -> System.Numerics.BigInteger' is not compatible with the type 'System.Numerics.BigInteger'
Is code not correct or F# interactive? It's F# 3.0.
Click the header section(or whatever it calls) will unfold the relative subcells,and the left triangle get rotated.
I have no idea how to code this.Is there anyone help me? Any code snippets would be great help.Thanks a lot.
Hello Friends I am using a list box control in aspx page
i have set multiple selection property to true, but when i try to select more than one item
it does not select multiple items, it selects one only do i have to do something programatically here is my code
on code behind nothing ...i want why it is not selecting more than one item's ..
i am using namespace using System.Web.UI.WebControls; as well but of no avail..
One of the downsides of web.config/app.config is that it's just Magic Strings everywhere, since it's just an XML file.
Interpreted languages like PHP or Ruby have the advantage that the configuration is just code that is executed. In .net, doing stuff in code requires a redeployment, which defeats the purpose.
Now, before I build my own web.config replacement based on Boo or PowerShell I wanted to know if there is an existing one?
I have a script that has a GET variable: $_GET['percentage']
I have a MySQL table of data.
Now lets say that there are 100 rows of data in this table.
In pseudo-code:
SELECT data FROM table
Now would it be possible to select $_GET['percentage'] of random data from table?
For example (again in pseudo-code):
$_GET['percentage'] = 10;
SELECT 10% of data from table order by rand()
If this IS possible, how could I do it?
I have a ocnnection to SQL Server set up in my vba code.
The format is:
strConn = "ODBC;Driver=SQL;Server=SQL1;Database=DB1;Uid=1;Pwd=1"
I have this in 4 sheets, but there will be times when I will want to change it to call from SQL2 or SQL3, and instead of changing the code on each sheet 4 times, I want to change it only once.
Is there a way to set up that line to run by calling it from somewhere else or by passing in a string into the ""?
This is related to this
Anyway what I need is actually something slightly different I need some way of doing this:
function run(arg) {
this.ran = this.ran || false;
if (!this.ran) init;
/* code */
this.ran = true;
}
This works fine, I just want to make sure that this code works even when this in case it was called with call() or apply()
Check this out for what I'm talking about, All of the calls after the first one should all be true, no matter the context
In a naive implementation of a thread pool, can a piece of code that is being executed read the data left by some previous code on the stack (if it was running on the same thread instance)? Also, are there any other inherent security issues connected to thread pools?
I'm trying to implement unit testing for my code and I'm having a hard time doing it.
Ideally I would like to test some classes not only for good functionality but also for proper memory allocation/deallocation. I wonder if this check can be done using a unit testing framework. I am using Visual Assert btw. I would love to see some sample code , if possible !
I am trying to fire the asp.net button click event from javascript. Its working fine in IE, but the same code is not working on Chrome, please help me. Here is the js code,
var btnSave = document.getElementById('btnSave');
btnSave.click();
alert("The changes are saved sucessfully!!");
Please help me
I need to convert the below date into the output as shown. I can get the date part using the code 101 but for the time I could not find any code that translates the time to HH:MM:SS AM/PM? Any ideas please? Thank you!
declare @adddate datetime
Set @adddate = 2011-07-06T22:30:07.5205649-04:00
Convert(varchar, @adddate, 101) + ' ' +
Convert(varchar, @adddate, 108)
The output should be 06/07/2011 10:30:07 PM
I'm able to get two videos to play sequentially, (and without pause!) with this code from Apple, (see section 2-4)...
http://developer.apple.com/safari/library/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/ControllingMediaWithJavaScript/ControllingMediaWithJavaScript.html
...Yet completely lost as to how to play a 3rd or 5th video. Trouble is I'm a Javascript noob :-(, so if you figure this out please share as much of your code as possible.
Thanks much!
I am busy working on a java app to run on blackberries but on some devices i am testing on, the code does not seem to be working and im having a hard time pinpointing where the problem lies.
My question is: Could the problem with some phones working and not working have t odo with the type of network they are running on such GSM vs CDMA and would the code that stops working on some devices be in one of the following areas:
1) Listeners - such as MessageListener and Phone Listener
2) UI Objects - simple test labels and buttons
3) Connection to a web service using ksoap2
How would I figure out what type of sql code such as procs, functions, views etc. are interacting with my table called TABLE1 through out a given database. Sample code would be very helpful for me.
thanks
I can not figure out why my code does not filter out lists from a predefined list.
I am trying to remove specific list using the following code.
data = [[1,1,1],[1,1,2],[1,2,1],[1,2,2],[2,1,1],[2,1,2],[2,2,1],[2,2,2]]
data = [x for x in data if x[0] != 1 and x[1] != 1]
print data
My result:
data = [[2, 2, 1], [2, 2, 2]]
Expected result:
data = [[1,2,1],[1,2,2],[2,1,1],[2,1,2],[2,2,1],[2,2,2]]