How to insert multiselect in CodeIgniter
i want the multiselect value insert in database with increment of table id
with divided selected value .
view:-
echo form_multiselect('cat_name', $options, $Award->cat_name);
controller
$data = $this->list_m->array_from_post(array('con_id'));
$this->award_m->save($data, $id);
what is the model code with increment id and with single value
Bruski
Sunday, 1 September 2013
Sharing URL On Facebook using Addthis
Sharing URL On Facebook using Addthis
we have a news website and using AddThis plugin to share news on Facebook
, sometimes when we try to share news on Facebook it doesn't detect the
page info (title ,desc , image ) and when we put the same URL on Facebook
debugger every thing running correctly and page info detected , and when
return to the web site and use the same URL we can share it normally .
the web site created using asp.net 4.0 + SQL server 2008 + iis 6 and the
website behind a firewall
thanks
we have a news website and using AddThis plugin to share news on Facebook
, sometimes when we try to share news on Facebook it doesn't detect the
page info (title ,desc , image ) and when we put the same URL on Facebook
debugger every thing running correctly and page info detected , and when
return to the web site and use the same URL we can share it normally .
the web site created using asp.net 4.0 + SQL server 2008 + iis 6 and the
website behind a firewall
thanks
Push footer to bottom
Push footer to bottom
I'm using twitter bootstarp for my site.
and using this thread to push my footer to bottom.
Flushing footer to bottom of the page, twitter bootstrap
you can see my page here.
http://khanawal.com/MYListings.aspx
Please let me know where i'm going wrong or what css modifications I need
to do.
I'm using twitter bootstarp for my site.
and using this thread to push my footer to bottom.
Flushing footer to bottom of the page, twitter bootstrap
you can see my page here.
http://khanawal.com/MYListings.aspx
Please let me know where i'm going wrong or what css modifications I need
to do.
Saturday, 31 August 2013
Unix: How to sort a dat file and keep original line numbers
Unix: How to sort a dat file and keep original line numbers
I have a large data file containing over a thousand entries. I would like
to sort them but maintain the original line numbers. For instance,
1:100
2:120
3:10
4:59
Where the first number is the line number, not saved in the data file,
separated by a colon from the real number. I would like to sort it and
keep the line numbers bound to their original lines, with an output of:
2:120
1:100
4:59
3:10
If possible, I would like to do this without creating another file, and
numbering them by hand is not an option for the data size I'm using.
I have a large data file containing over a thousand entries. I would like
to sort them but maintain the original line numbers. For instance,
1:100
2:120
3:10
4:59
Where the first number is the line number, not saved in the data file,
separated by a colon from the real number. I would like to sort it and
keep the line numbers bound to their original lines, with an output of:
2:120
1:100
4:59
3:10
If possible, I would like to do this without creating another file, and
numbering them by hand is not an option for the data size I'm using.
Update if variables exist else echo an error message?
Update if variables exist else echo an error message?
How can I make this script to where if it finds that the fname and lname
do not exist that it will pop up a message saying that they never signed
in.
<?php
session_start();
include_once("connect.php");
date_default_timezone_set("America/Winnipeg");
$date = ("m-d-Y");
$timeout = date("g:i:s a");
if ("SELECT EXISTS(SELECT * FROM signin_out WHERE
lname='".$_POST['lastname']."' AND
fname='".$_POST['firstname']."'
AND date='".$date."')") {
mysql_query("UPDATE signin_out SET timeout='" . $timeout . "'
WHERE lname='" . $_POST['lastname'] . "' AND fname='" .
$_POST['firstname'] . "' AND timeout='' ");
header("Location: ../index.html");
} else {
echo "<script type='text/javascript>'";
echo "alert('<p>Oops! You never signed in!</p><br><p>Please contact a
Librarian</p>');'";
echo "</script>'";
header('Location: ../index.php?notsignedin');
}
?>
This is an intranet site for a highschool.
How can I make this script to where if it finds that the fname and lname
do not exist that it will pop up a message saying that they never signed
in.
<?php
session_start();
include_once("connect.php");
date_default_timezone_set("America/Winnipeg");
$date = ("m-d-Y");
$timeout = date("g:i:s a");
if ("SELECT EXISTS(SELECT * FROM signin_out WHERE
lname='".$_POST['lastname']."' AND
fname='".$_POST['firstname']."'
AND date='".$date."')") {
mysql_query("UPDATE signin_out SET timeout='" . $timeout . "'
WHERE lname='" . $_POST['lastname'] . "' AND fname='" .
$_POST['firstname'] . "' AND timeout='' ");
header("Location: ../index.html");
} else {
echo "<script type='text/javascript>'";
echo "alert('<p>Oops! You never signed in!</p><br><p>Please contact a
Librarian</p>');'";
echo "</script>'";
header('Location: ../index.php?notsignedin');
}
?>
This is an intranet site for a highschool.
how to handle 10 webrequests with Task.Any when the bandwhich is too slow
how to handle 10 webrequests with Task.Any when the bandwhich is too slow
I'm querying asynchronously 10 webrequests using httpClient.GetAsync and
I'm using Task.Any to process data as soon as one of the 10 request
finished downloading
the thing is, each 10 request takes around 2-3 seconds to download and
using Task.Any means my app is downloading in the same time the 10
webrequests
if my connection bandwidth is slow the processing of the data is delayed
the solution would be to download a few requests, for example 2 out of the
10 requests and sleep the other 8 requests. Then keep waking up the rest
of the webrequest while process the first webrequests.
I don't know how I would do it for now, my code looks like this
private async void OnLaunchClick(object sender, RoutedEventArgs e)
{
var quotesTask = new List<Task<IEnumerable<Symbol>>>();
for (int i = 0; i < userInput.Symbols.Count(); i = i +
SYMBOLS_PAGINATION_PER_REQUEST)
{
var input = new
UserInput(userInput.Symbols.Skip(i).Take(SYMBOLS_PAGINATION_PER_REQUEST),
userInput.StartDate, userInput.EndDate,
userInput.Interval);
quotesTask.Add(quotesQuery.GetSymbolsInternal(input,
_cts.Token));
}
while (quotesTask.Count > 0)
{
Task<IEnumerable<Symbol>> quotesFinishedTask = await
Task.WhenAny(quotesTask);
quotesTask.Remove(quotesFinishedTask);
// Update UI
}
}
public async Task<IEnumerable<Symbol>> GetSymbolsInternal(UserInput
filteredInput, CancellationToken token)
{
if (filteredInput == null) throw new
ArgumentNullException("filteredInput");
string url = BuildUrl(filteredInput);
logger.Debug(string.Format("Start downloading quotes: {0}\n{1}",
filteredInput.Symbols.Select(a =>
a.Name).Join(","),
url));
string content = await _webRequest.GetData(url,
token).ConfigureAwait(false);
logger.Debug(string.Format("End downloading quotes: {0}",
filteredInput.Symbols.Select(a => a.Name).Join(",")));
var symbols = Parse(filteredInput.Symbols, content);
return symbols;
}
public class WebRequest
{
private static readonly Logger logger =
LogManager.GetCurrentClassLogger();
public virtual async Task<string> GetData(string uri,
CancellationToken token)
{
string result = string.Empty;
using (var client = new HttpClient())
using (var response = await client.GetAsync(uri,
token).ConfigureAwait(false))
{
if (response.IsSuccessStatusCode)
result = await
response.Content.ReadAsStringAsync().ConfigureAwait(false);
else
logger.Error("Unable to retrieve data from the following
url: {0} - StatusCode: {1}", uri, response.StatusCode);
}
return result;
}
}
The goal is to speed up the download of 1 of the 10 webrequests in order
to process the data and to update UI as soon as possible instead of
downloading 10 webrequests in the same time with a limited bandwidth and
have to update the UI several seconds later.
I'm querying asynchronously 10 webrequests using httpClient.GetAsync and
I'm using Task.Any to process data as soon as one of the 10 request
finished downloading
the thing is, each 10 request takes around 2-3 seconds to download and
using Task.Any means my app is downloading in the same time the 10
webrequests
if my connection bandwidth is slow the processing of the data is delayed
the solution would be to download a few requests, for example 2 out of the
10 requests and sleep the other 8 requests. Then keep waking up the rest
of the webrequest while process the first webrequests.
I don't know how I would do it for now, my code looks like this
private async void OnLaunchClick(object sender, RoutedEventArgs e)
{
var quotesTask = new List<Task<IEnumerable<Symbol>>>();
for (int i = 0; i < userInput.Symbols.Count(); i = i +
SYMBOLS_PAGINATION_PER_REQUEST)
{
var input = new
UserInput(userInput.Symbols.Skip(i).Take(SYMBOLS_PAGINATION_PER_REQUEST),
userInput.StartDate, userInput.EndDate,
userInput.Interval);
quotesTask.Add(quotesQuery.GetSymbolsInternal(input,
_cts.Token));
}
while (quotesTask.Count > 0)
{
Task<IEnumerable<Symbol>> quotesFinishedTask = await
Task.WhenAny(quotesTask);
quotesTask.Remove(quotesFinishedTask);
// Update UI
}
}
public async Task<IEnumerable<Symbol>> GetSymbolsInternal(UserInput
filteredInput, CancellationToken token)
{
if (filteredInput == null) throw new
ArgumentNullException("filteredInput");
string url = BuildUrl(filteredInput);
logger.Debug(string.Format("Start downloading quotes: {0}\n{1}",
filteredInput.Symbols.Select(a =>
a.Name).Join(","),
url));
string content = await _webRequest.GetData(url,
token).ConfigureAwait(false);
logger.Debug(string.Format("End downloading quotes: {0}",
filteredInput.Symbols.Select(a => a.Name).Join(",")));
var symbols = Parse(filteredInput.Symbols, content);
return symbols;
}
public class WebRequest
{
private static readonly Logger logger =
LogManager.GetCurrentClassLogger();
public virtual async Task<string> GetData(string uri,
CancellationToken token)
{
string result = string.Empty;
using (var client = new HttpClient())
using (var response = await client.GetAsync(uri,
token).ConfigureAwait(false))
{
if (response.IsSuccessStatusCode)
result = await
response.Content.ReadAsStringAsync().ConfigureAwait(false);
else
logger.Error("Unable to retrieve data from the following
url: {0} - StatusCode: {1}", uri, response.StatusCode);
}
return result;
}
}
The goal is to speed up the download of 1 of the 10 webrequests in order
to process the data and to update UI as soon as possible instead of
downloading 10 webrequests in the same time with a limited bandwidth and
have to update the UI several seconds later.
How do HTTP servers handle very large HTTP requests?
How do HTTP servers handle very large HTTP requests?
As I understand, the body size of HTTP POST request is unlimited. Thus a
client may send gigabytes of data in one HTTP request. Now I wonder how an
HTTP server should handle such requests. How do Tomcat and Jetty handle
them ?
As I understand, the body size of HTTP POST request is unlimited. Thus a
client may send gigabytes of data in one HTTP request. Now I wonder how an
HTTP server should handle such requests. How do Tomcat and Jetty handle
them ?
Subscribe to:
Posts (Atom)