Javascript return enclosing function
I have a simple scenario in which I check if something exists before
adding it, if it does, I return the function (hence exiting). I use this
pattern many times and I would like to decouple it in another simple
function.
function onEvent(e){
if( this.has(e) )
return
this.add(e);
// More logic different on an event-basis
}
I would like to decouple it like so:
function safeAdd(e){
if( this.has(e) )
return
this.add(e);
}
function onEvent(e){
safeAdd(e);
// More logic
}
But obviously doing so just returns safeAdd and doesn't exit from onEvent,
and the rest of the logic gets executed anyways.
I know I could do something like:
function safeAdd(e){
if( this.has(e) )
return false
this.add(e);
return true
}
function onEvent(e){
if( !safeAdd(e) )
return
// More logic
}
But, since I repeat this a lot, I would like to be as concise as possible.
Saturday, 31 August 2013
Undefined local variable in a partial
Undefined local variable in a partial
I'm new to rails and am having a bit of trouble. I am getting an
undefined local variable or method `answer'
error in my _answer.html.erb partial.
Here is my answers_controller.rb:
class AnswersController < ApplicationController
before_action :set_answer, only: [:show, :edit, :update, :destroy]
def index
@question = Question.find params[:question_id]
@question.answers
end
def show
end
def new
@question = Question.find params[:question_id]
end
def edit
end
def create
@question = Question.find(params[:question_id])
@answer = @question.answers.create(answer_params)
respond_to do |format|
if @answer.save
format.html { redirect_to @comment, notice: 'Answer was successfully
created.' }
format.json { render action: 'show', status: :created, location:
@answer }
else
format.html { render action: 'new' }
format.json { render json: @answer.errors, status:
:unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @answer.update(answer_params)
format.html { redirect_to @answer, notice: 'Answer was successfully
updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @answer.errors, status:
:unprocessable_entity }
end
end
end
def destroy
@answer.destroy
respond_to do |format|
format.html { redirect_to answers_url }
format.json { head :no_content }
end
end
and my _answer.html.erb file:
<%=div_for(answer) do %>
<div class="questioncontainer">
<p>
<%= answer.body %>
</p>
</div>
<% end %>
If it matters, my resources :answers is nested in resources :questions.
I appreciate any help!
I'm new to rails and am having a bit of trouble. I am getting an
undefined local variable or method `answer'
error in my _answer.html.erb partial.
Here is my answers_controller.rb:
class AnswersController < ApplicationController
before_action :set_answer, only: [:show, :edit, :update, :destroy]
def index
@question = Question.find params[:question_id]
@question.answers
end
def show
end
def new
@question = Question.find params[:question_id]
end
def edit
end
def create
@question = Question.find(params[:question_id])
@answer = @question.answers.create(answer_params)
respond_to do |format|
if @answer.save
format.html { redirect_to @comment, notice: 'Answer was successfully
created.' }
format.json { render action: 'show', status: :created, location:
@answer }
else
format.html { render action: 'new' }
format.json { render json: @answer.errors, status:
:unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @answer.update(answer_params)
format.html { redirect_to @answer, notice: 'Answer was successfully
updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @answer.errors, status:
:unprocessable_entity }
end
end
end
def destroy
@answer.destroy
respond_to do |format|
format.html { redirect_to answers_url }
format.json { head :no_content }
end
end
and my _answer.html.erb file:
<%=div_for(answer) do %>
<div class="questioncontainer">
<p>
<%= answer.body %>
</p>
</div>
<% end %>
If it matters, my resources :answers is nested in resources :questions.
I appreciate any help!
How To Upgrade A Deprecated Ember Method
How To Upgrade A Deprecated Ember Method
Just upgraded from the ember rc6 to rc8. I am getting a
Ember.ControllerMixin.Ember.Mixin.create.deprecatedSend in the console.
It is telling me
DEPRECATION: Action handlers implemented directly on controllers are
deprecated in favor of action handlers on an actions object
Just wondering what the correct way to handle this in Ember. I am calling
controller.send from inside of the setupController function on one of my
routes.
Just upgraded from the ember rc6 to rc8. I am getting a
Ember.ControllerMixin.Ember.Mixin.create.deprecatedSend in the console.
It is telling me
DEPRECATION: Action handlers implemented directly on controllers are
deprecated in favor of action handlers on an actions object
Just wondering what the correct way to handle this in Ember. I am calling
controller.send from inside of the setupController function on one of my
routes.
Smooth text scaling in Android
Smooth text scaling in Android
I am trying to scale text smoothly in Android, but I've got the following
problem:
I have a separate thread in my application that is drawing text on a
bitmap. I am drawing that bitmap on the View object during onDraw event.
However, it seems that Android is ignoring small changes in text size. For
example:
The text that I draw using drawText command with text size 10.49f is drawn
of the same size as text that I draw using text size 10.00f (I assumed
text drawn with text size 10.00f should be slightly smaller than text
drawn with text size 10.49f). It seems as if Android is ignoring the
fractional parts of the float text size.
Here it is a simplified sample code where one can demonstrate the problem:
@Override
public void onDraw(Canvas c) {
try {
if (mBitmap == null)
mBitmap = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);
mBitmap.eraseColor(Color.argb(0, 0, 0, 0));
Canvas cnv = new Canvas(mBitmap);
// !!! mPaint.setTextSize(10.00f);
mPaint.setTextSize(10.49f);
mPaint.setSubpixelText(true);
mPaint.setAntiAlias(true);
mPaint.setDither(true);
cnv.drawText("This is a very long text, hopefully the scaling will
work normally.", 10.0f, 100.0f, mPaint);
c.drawBitmap(mBitmap, 0, 0, null);
} catch (Throwable t) {
t.printStackTrace();
}
}
How can I scale texts using drawText command smoothly, so that fractional
parts of the text size will also be taken in account?
I am trying to scale text smoothly in Android, but I've got the following
problem:
I have a separate thread in my application that is drawing text on a
bitmap. I am drawing that bitmap on the View object during onDraw event.
However, it seems that Android is ignoring small changes in text size. For
example:
The text that I draw using drawText command with text size 10.49f is drawn
of the same size as text that I draw using text size 10.00f (I assumed
text drawn with text size 10.00f should be slightly smaller than text
drawn with text size 10.49f). It seems as if Android is ignoring the
fractional parts of the float text size.
Here it is a simplified sample code where one can demonstrate the problem:
@Override
public void onDraw(Canvas c) {
try {
if (mBitmap == null)
mBitmap = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);
mBitmap.eraseColor(Color.argb(0, 0, 0, 0));
Canvas cnv = new Canvas(mBitmap);
// !!! mPaint.setTextSize(10.00f);
mPaint.setTextSize(10.49f);
mPaint.setSubpixelText(true);
mPaint.setAntiAlias(true);
mPaint.setDither(true);
cnv.drawText("This is a very long text, hopefully the scaling will
work normally.", 10.0f, 100.0f, mPaint);
c.drawBitmap(mBitmap, 0, 0, null);
} catch (Throwable t) {
t.printStackTrace();
}
}
How can I scale texts using drawText command smoothly, so that fractional
parts of the text size will also be taken in account?
How can I calculate the recursive calls to this function and what will be the correct answer to it?
How can I calculate the recursive calls to this function and what will be
the correct answer to it?
How can I calculate the recursive calls to this function and what will be
the correct answer to it??????
int func(x,y)
{
if (n % m == 0) return m;
n = n % m;
return func(y,x);
}
I need a formula for it or an explanation or general expression for it
really confused here?????
the correct answer to it?
How can I calculate the recursive calls to this function and what will be
the correct answer to it??????
int func(x,y)
{
if (n % m == 0) return m;
n = n % m;
return func(y,x);
}
I need a formula for it or an explanation or general expression for it
really confused here?????
using .htaccess to overtire my URL
using .htaccess to overtire my URL
i need to make this url
http://yadoniaclients.com/yadonia/services/our-services/mobile-application-development
(any page)
to look like this
http://yadoniaclients.com/yadonia/services/ (any page)
this my current .htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^yadonia/(.*)$ yadonia/index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
thanks for your help.
i need to make this url
http://yadoniaclients.com/yadonia/services/our-services/mobile-application-development
(any page)
to look like this
http://yadoniaclients.com/yadonia/services/ (any page)
this my current .htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^yadonia/(.*)$ yadonia/index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
thanks for your help.
why calling apply on Math.max works and without it doens't
why calling apply on Math.max works and without it doens't
If you asked me to get the max of an array, I would just do:
var nums = [66,3,8,213,965,1,453];
Math.max.apply(Math, nums);
of course, I could also do: nums.sort(function(a, b){ return a -
b}.pop(nums.length);
but I have to be honest. I need to know WHY that works - using
.apply(Math,nums). If I just did this:
Math.max(nums);
that would not work.
by using apply, I pass in Math as this - and nums for the array. But I
want to know the intricacies of "why" that the first works and the latter
doesn't. What magic is happening?
There is something fundamental I am not wrapping my brains around. I have
read a bunch about "call and apply", but many times some cool tricks can
be had like the one above, and I feel I am missing something deeper here.
If you asked me to get the max of an array, I would just do:
var nums = [66,3,8,213,965,1,453];
Math.max.apply(Math, nums);
of course, I could also do: nums.sort(function(a, b){ return a -
b}.pop(nums.length);
but I have to be honest. I need to know WHY that works - using
.apply(Math,nums). If I just did this:
Math.max(nums);
that would not work.
by using apply, I pass in Math as this - and nums for the array. But I
want to know the intricacies of "why" that the first works and the latter
doesn't. What magic is happening?
There is something fundamental I am not wrapping my brains around. I have
read a bunch about "call and apply", but many times some cool tricks can
be had like the one above, and I feel I am missing something deeper here.
Friday, 30 August 2013
My WPF Application use too much memory
My WPF Application use too much memory
I have a WPF application that contains 20 user control in Main Window.it
uses too much memory, about 400 Mb. I use story board to change the
position of text in all user control. and they give their content from a
web service. I wrote one story board in Cs instead of Xaml and my
application gets better but not very good!
I have a WPF application that contains 20 user control in Main Window.it
uses too much memory, about 400 Mb. I use story board to change the
position of text in all user control. and they give their content from a
web service. I wrote one story board in Cs instead of Xaml and my
application gets better but not very good!
Thursday, 29 August 2013
which programing language and how
which programing language and how
i want write an app that 1. work like a Newsletter show my users last news
2.its icon should be in system tray 3.users can chat for users Membership
they have to fill information like name fname country city etc i mean an
app that work Under the Web and also have an icon in the os.
i want write an app that 1. work like a Newsletter show my users last news
2.its icon should be in system tray 3.users can chat for users Membership
they have to fill information like name fname country city etc i mean an
app that work Under the Web and also have an icon in the os.
Check if multiline textbox has only newline characters
Check if multiline textbox has only newline characters
How can i check if a multi line text box has only newline characters?
No text at all, but only \n, \r, etc..?
How can i check if a multi line text box has only newline characters?
No text at all, but only \n, \r, etc..?
SQL Concatenate ids into a specific order
SQL Concatenate ids into a specific order
I have the following query which works great, it puts all my ids in a
comma separated list.
DECLARE @tmp nvarchar(max)
SET @tmp = ''
SELECT @tmp = @tmp + cast(id as nvarchar(max)) + ', '
FROM dbo.property
I want to put my ids in alphabetical order but when I add order by p.Name
it only gives my the top one result.
How can I adapt my query to accomplish this?
I have the following query which works great, it puts all my ids in a
comma separated list.
DECLARE @tmp nvarchar(max)
SET @tmp = ''
SELECT @tmp = @tmp + cast(id as nvarchar(max)) + ', '
FROM dbo.property
I want to put my ids in alphabetical order but when I add order by p.Name
it only gives my the top one result.
How can I adapt my query to accomplish this?
Wednesday, 28 August 2013
What are my xAxis labels misaligned?
What are my xAxis labels misaligned?
pI'm new to highcharts and I'm just trying to get a basic line chart up
and running. When I set xaxis label step my labels become misaligned.
Anyone know why?/p pimg src=http://i.stack.imgur.com/VwBhO.png alt=enter
image description here/p precode $(elementSelector).highcharts({ title:{
text:'' }, tooltip: { enabled:false }, chart: { type: chartType }, xAxis:
{ title: { text: sectionData.XAxisLabel }, labels: { step:
sectionData.XAxisLabelSkip }, categories: xpoints }, yAxis: { title: {
text: sectionData.YAxisLabel }, min: 0, }, plotOptions: { line: {
dataLabels: { enabled: true } } }, series: [{ title:'', data: ypoints,
showInLegend: false }] }); /code/pre
pI'm new to highcharts and I'm just trying to get a basic line chart up
and running. When I set xaxis label step my labels become misaligned.
Anyone know why?/p pimg src=http://i.stack.imgur.com/VwBhO.png alt=enter
image description here/p precode $(elementSelector).highcharts({ title:{
text:'' }, tooltip: { enabled:false }, chart: { type: chartType }, xAxis:
{ title: { text: sectionData.XAxisLabel }, labels: { step:
sectionData.XAxisLabelSkip }, categories: xpoints }, yAxis: { title: {
text: sectionData.YAxisLabel }, min: 0, }, plotOptions: { line: {
dataLabels: { enabled: true } } }, series: [{ title:'', data: ypoints,
showInLegend: false }] }); /code/pre
Span inside td does not override td style
Span inside td does not override td style
I have a span tag inside a td. The td has a class with CSS to set the
text-decoration to underline, while the span sets the text-decoration to
none. I expect the text inside the span to not be underlined, but for some
reason it is. Why?
Example at http://jsfiddle.net/mfV5V/2/
<table>
<tr>
<td class="u">
<span class="no-u" style="text-decoration: none
!important;">My Text</span>
</td>
</tr>
</table>
I have a span tag inside a td. The td has a class with CSS to set the
text-decoration to underline, while the span sets the text-decoration to
none. I expect the text inside the span to not be underlined, but for some
reason it is. Why?
Example at http://jsfiddle.net/mfV5V/2/
<table>
<tr>
<td class="u">
<span class="no-u" style="text-decoration: none
!important;">My Text</span>
</td>
</tr>
</table>
facebook messaging, re-reading deleted friends messages
facebook messaging, re-reading deleted friends messages
is there any way to recall a facebook message after the friendship has
ended. I have a friend who is threatening to take me to court and my only
defence is within our personal messaging.
is there any way to recall a facebook message after the friendship has
ended. I have a friend who is threatening to take me to court and my only
defence is within our personal messaging.
Durandal issue with Breeze and Q
Durandal issue with Breeze and Q
Hi i'm new to building web pages applications, i started with HotTowel
videos from John Papa and used initially the HotTowel VSIX Template.
When i decided to update to Durandal 2.0 i faced the issue that the
application would not proceed from the activate method in the shell
module.
After some Google search's i found out that the problem has to due with
durandal using jquery promises, i have tried the fix announced in
http://durandaljs.com/documentation/Q/ but its not working, can someone
provide me with some light on the issue.
PS: im new to js and web in general so i'm sorry if the question isn't
clear enough
in my shell.js i have:
function activate() {
app.title = config.appTitle;
return datacontext.primeData()
.then(boot)
.fail(failedInitialization);
}
function boot() {
logger.log('CodeCamper Backend Loaded!', null,
system.getModuleId(shell), true);
router.map(config.routes).buildNavigationModel();
return router.activate();
}
function addSession(item) {
router.navigateTo(item.hash);
}
function failedInitialization(error) {
var msg = 'App initialization failed: ' + error.message;
logger.logError(msg, error, system.getModuleId(shell), true);
}
and in my datacontext:
var primeData = function () {
var promise = Q.all([
getLookups(),
getSpeakerPartials(null, true)])
.then(applyValidators)
return promise
.then(success);
function success() {
datacontext.lookups = {
rooms: getLocal('Rooms', 'name', true),
tracks: getLocal('Tracks', 'name', true),
timeslots: getLocal('TimeSlots', 'start', true),
speakers: getLocal('Persons', orderBy.speaker, true)
};
log('Primed data', datacontext.lookups);
}
function applyValidators() {
model.applySessionValidators(manager.metadataStore);
}
};
Hi i'm new to building web pages applications, i started with HotTowel
videos from John Papa and used initially the HotTowel VSIX Template.
When i decided to update to Durandal 2.0 i faced the issue that the
application would not proceed from the activate method in the shell
module.
After some Google search's i found out that the problem has to due with
durandal using jquery promises, i have tried the fix announced in
http://durandaljs.com/documentation/Q/ but its not working, can someone
provide me with some light on the issue.
PS: im new to js and web in general so i'm sorry if the question isn't
clear enough
in my shell.js i have:
function activate() {
app.title = config.appTitle;
return datacontext.primeData()
.then(boot)
.fail(failedInitialization);
}
function boot() {
logger.log('CodeCamper Backend Loaded!', null,
system.getModuleId(shell), true);
router.map(config.routes).buildNavigationModel();
return router.activate();
}
function addSession(item) {
router.navigateTo(item.hash);
}
function failedInitialization(error) {
var msg = 'App initialization failed: ' + error.message;
logger.logError(msg, error, system.getModuleId(shell), true);
}
and in my datacontext:
var primeData = function () {
var promise = Q.all([
getLookups(),
getSpeakerPartials(null, true)])
.then(applyValidators)
return promise
.then(success);
function success() {
datacontext.lookups = {
rooms: getLocal('Rooms', 'name', true),
tracks: getLocal('Tracks', 'name', true),
timeslots: getLocal('TimeSlots', 'start', true),
speakers: getLocal('Persons', orderBy.speaker, true)
};
log('Primed data', datacontext.lookups);
}
function applyValidators() {
model.applySessionValidators(manager.metadataStore);
}
};
url action in javascript
url action in javascript
How can write this on javascript. Sorry. I'm new in javascript. This is on
html form.
<form action="@Url.Action("NewPage")" >
....
</form>
Now I have javascript function.
function validateForm() {
//var x = document.forms["form"]["fname"].value;
var x = document.getElementById('id').value;
if (x == null || x == 0 || x == "0") {
alert("stop");
return false;
}
else {
document.form.submit();
}
}
What should be in the html form action.
How can write this on javascript. Sorry. I'm new in javascript. This is on
html form.
<form action="@Url.Action("NewPage")" >
....
</form>
Now I have javascript function.
function validateForm() {
//var x = document.forms["form"]["fname"].value;
var x = document.getElementById('id').value;
if (x == null || x == 0 || x == "0") {
alert("stop");
return false;
}
else {
document.form.submit();
}
}
What should be in the html form action.
Tuesday, 27 August 2013
Get c# classes after a program is compiled
Get c# classes after a program is compiled
I have a program that I am making for a friend and I don't want him to see
the whole code, but I want him to be able to add classes that have
attributes on the classes so he can add his own stuff to it, how would I
be able to get classes using a compiled program and add them to the
dictionary of methods to be called upon later?
I have a program that I am making for a friend and I don't want him to see
the whole code, but I want him to be able to add classes that have
attributes on the classes so he can add his own stuff to it, how would I
be able to get classes using a compiled program and add them to the
dictionary of methods to be called upon later?
Physics Editor .plist file not being loaded by cache? Box2d application
Physics Editor .plist file not being loaded by cache? Box2d application
Okay I am making a Box2d app and have been getting a multitude of errors
in the same class/method and I have FINALLY figured out that it is
because, for some reason, my plist file isn't being loaded/registered to
the console and I am not sure why.
In my init method of my main class I have:
if((self = [super init]))
{
CGSize winSize = [CCDirector sharedDirector].winSize;
self.isTouchEnabled = YES;
[self setupWorld];
[self setupDebugDraw];
[self setupShapeCache];
}
My setupShapeCache method is:
- (void)setupShapeCache
{
[[ShapeCache sharedShapeCache] addShapesWithFile:@"shapes.plist"];
}
This method loads my Physics Editor shapes into the cache. However, it
isn't implemented.... I know that because when I run my application I get
errors in the ShapeCache class.
These errors are inside my ShapeCache class and occur because I do not
think that "shapes.plist" is ever loaded.
Does anyone have any ideas as to why my shapes.plist wasn't loaded?
Here is the screenshot of my error inside Shapecache. Once I comment out
this method I get another error in ShapeCache too (plist file never
loaded)
Please try and help! :) I hope this is enough bg info.... if there's
anything missing/ would be helpful PLEASE let me know.
Okay I am making a Box2d app and have been getting a multitude of errors
in the same class/method and I have FINALLY figured out that it is
because, for some reason, my plist file isn't being loaded/registered to
the console and I am not sure why.
In my init method of my main class I have:
if((self = [super init]))
{
CGSize winSize = [CCDirector sharedDirector].winSize;
self.isTouchEnabled = YES;
[self setupWorld];
[self setupDebugDraw];
[self setupShapeCache];
}
My setupShapeCache method is:
- (void)setupShapeCache
{
[[ShapeCache sharedShapeCache] addShapesWithFile:@"shapes.plist"];
}
This method loads my Physics Editor shapes into the cache. However, it
isn't implemented.... I know that because when I run my application I get
errors in the ShapeCache class.
These errors are inside my ShapeCache class and occur because I do not
think that "shapes.plist" is ever loaded.
Does anyone have any ideas as to why my shapes.plist wasn't loaded?
Here is the screenshot of my error inside Shapecache. Once I comment out
this method I get another error in ShapeCache too (plist file never
loaded)
Please try and help! :) I hope this is enough bg info.... if there's
anything missing/ would be helpful PLEASE let me know.
Repeated Pseudo-Class Selectors
Repeated Pseudo-Class Selectors
I noticed in the Bootstrap CSS file:
input:focus:invalid:focus,
textarea:focus:invalid:focus,
select:focus:invalid:focus {
border-color: #e9322d;
-webkit-box-shadow: 0 0 6px #f8b9b7;
-moz-box-shadow: 0 0 6px #f8b9b7;
box-shadow: 0 0 6px #f8b9b7;
s}
It appears that :focus is specified twice for input, textarea, and select;
does this have a particular function?
I noticed in the Bootstrap CSS file:
input:focus:invalid:focus,
textarea:focus:invalid:focus,
select:focus:invalid:focus {
border-color: #e9322d;
-webkit-box-shadow: 0 0 6px #f8b9b7;
-moz-box-shadow: 0 0 6px #f8b9b7;
box-shadow: 0 0 6px #f8b9b7;
s}
It appears that :focus is specified twice for input, textarea, and select;
does this have a particular function?
Google Calendar - Populating website table with next 8 events
Google Calendar - Populating website table with next 8 events
I have imbedded the Google Calendar (in its own web page) in my website
and desire to have my home page list the next 8 events (from the Google
Calendar) in a table at the bottom of my web page (above the header). The
problem is that I have no experience working with Google API's.
I am only looking for direction, not the solution. I have a lot to learn
and the only way to go about it is to DO it!
Thank you for your time and response in advance.
S
I have imbedded the Google Calendar (in its own web page) in my website
and desire to have my home page list the next 8 events (from the Google
Calendar) in a table at the bottom of my web page (above the header). The
problem is that I have no experience working with Google API's.
I am only looking for direction, not the solution. I have a lot to learn
and the only way to go about it is to DO it!
Thank you for your time and response in advance.
S
Update Recordset in one column if exsist
Update Recordset in one column if exsist
First I should apologise for my lack of knowledge with Visual Basic.
I have managed to get a function working that updates all fields in a
database if they exist in the current database. It checks to see firstly
if the "Product Reference" field exists and if it does it updates all the
values from the current database.
What I am trying to achieve is to have it only update the field
"nStockOnHand" and leave all the others as is, however I am really not to
great at coding in Visual Basic so any help greatly appreciated.
This is my script so far:
Option Compare Database
Option Explicit
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Function update1()
'Temp field
Dim fField As Field
Dim bCopy As Boolean
'Open source database
Dim dSource As Database
Set dSource = CurrentDb
'Open dest database
Dim dDest As Database
Set dDest = DAO.OpenDatabase("C:\Users\simon\Documents\SellerDeck
2013\Sites\BGH dest\ActinicCatalog.mdb")
'Open source recordset
Dim rSource As Recordset
Set rSource = dSource.OpenRecordset("Product", dbOpenForwardOnly)
'Open dest recordset
Dim rDest As Recordset
Set rDest = dDest.OpenRecordset("Product", dbOpenDynaset)
'Loop through source recordset
While Not rSource.EOF
'Reset copy flag
bCopy = False
'Look for record in dest recordset
rDest.FindFirst "Product Reference = " & rSource.Fields("Product
Reference") & ""
If rDest.NoMatch Then
Else
'If found, check for differences
For Each fField In rSource.Fields
If rDest2.Fields(fField.Name) <>
rSource.Fields(fField.Name) Then
rDest.Edit
bCopy = True
Exit For
End If
Next fField
Set fField = Nothing
End If
'If copy flag is set, copy record
If bCopy Then
For Each fField In rSource.Fields
rDest.Fields(fField.Name) = rSource.Fields(fField.Name)
Next fField
Set fField = Nothing
rDest.Update
End If
'Next source record
rSource.MoveNext
Wend
'Close dest recordset
rDest.Close
Set rDest = Nothing
'Close source recordset
rSource.Close
Set rSource = Nothing
'Close dest database
dDest.Close
Set dDest = Nothing
'Close source database
dSource.Close
Set dSource = Nothing
End Function
Public Function finish()
Dim x As Integer
For x = 1 To 10
Sleep 2000
DoEvents
Next x
Application.Quit
End Function
Thanks, Simon
First I should apologise for my lack of knowledge with Visual Basic.
I have managed to get a function working that updates all fields in a
database if they exist in the current database. It checks to see firstly
if the "Product Reference" field exists and if it does it updates all the
values from the current database.
What I am trying to achieve is to have it only update the field
"nStockOnHand" and leave all the others as is, however I am really not to
great at coding in Visual Basic so any help greatly appreciated.
This is my script so far:
Option Compare Database
Option Explicit
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Function update1()
'Temp field
Dim fField As Field
Dim bCopy As Boolean
'Open source database
Dim dSource As Database
Set dSource = CurrentDb
'Open dest database
Dim dDest As Database
Set dDest = DAO.OpenDatabase("C:\Users\simon\Documents\SellerDeck
2013\Sites\BGH dest\ActinicCatalog.mdb")
'Open source recordset
Dim rSource As Recordset
Set rSource = dSource.OpenRecordset("Product", dbOpenForwardOnly)
'Open dest recordset
Dim rDest As Recordset
Set rDest = dDest.OpenRecordset("Product", dbOpenDynaset)
'Loop through source recordset
While Not rSource.EOF
'Reset copy flag
bCopy = False
'Look for record in dest recordset
rDest.FindFirst "Product Reference = " & rSource.Fields("Product
Reference") & ""
If rDest.NoMatch Then
Else
'If found, check for differences
For Each fField In rSource.Fields
If rDest2.Fields(fField.Name) <>
rSource.Fields(fField.Name) Then
rDest.Edit
bCopy = True
Exit For
End If
Next fField
Set fField = Nothing
End If
'If copy flag is set, copy record
If bCopy Then
For Each fField In rSource.Fields
rDest.Fields(fField.Name) = rSource.Fields(fField.Name)
Next fField
Set fField = Nothing
rDest.Update
End If
'Next source record
rSource.MoveNext
Wend
'Close dest recordset
rDest.Close
Set rDest = Nothing
'Close source recordset
rSource.Close
Set rSource = Nothing
'Close dest database
dDest.Close
Set dDest = Nothing
'Close source database
dSource.Close
Set dSource = Nothing
End Function
Public Function finish()
Dim x As Integer
For x = 1 To 10
Sleep 2000
DoEvents
Next x
Application.Quit
End Function
Thanks, Simon
How to email with emacs with MS Exchange Server
How to email with emacs with MS Exchange Server
I'm using emacs 23.1.x on centos 6.0. I'd like to be able to read/send
emails on the corporate MS Exchange server. What is the procedure for
doing the same ?
thank you.
I'm using emacs 23.1.x on centos 6.0. I'd like to be able to read/send
emails on the corporate MS Exchange server. What is the procedure for
doing the same ?
thank you.
Monday, 26 August 2013
What are the differences between following two javascript code?
What are the differences between following two javascript code?
In some Javascript codes which uses immediate function, it has argument
window or document like the following:
(function (window, document) {
...
)(window, document);
However, window and document are global objects and can be directly
accessed as follow:
(function () {
var userAgent = window.navigator.userAgent;
...
var el = document.getElementById(...)
...
})();
What are the differences between the above two codes. Which is better way
and why?
In some Javascript codes which uses immediate function, it has argument
window or document like the following:
(function (window, document) {
...
)(window, document);
However, window and document are global objects and can be directly
accessed as follow:
(function () {
var userAgent = window.navigator.userAgent;
...
var el = document.getElementById(...)
...
})();
What are the differences between the above two codes. Which is better way
and why?
tikz problem (non-continuous function) tex.stackexchange.com
tikz problem (non-continuous function) – tex.stackexchange.com
I want to plot a function x^3/(x^2-1) but it doesn't work.
\documentclass{article} \usepackage{tikz} \begin{document}
\begin{tikzpicture}[domain=-5:5,smooth] \draw[->] (-5,0) -- (5,0) …
I want to plot a function x^3/(x^2-1) but it doesn't work.
\documentclass{article} \usepackage{tikz} \begin{document}
\begin{tikzpicture}[domain=-5:5,smooth] \draw[->] (-5,0) -- (5,0) …
C++ Disambiguation: subobject and subclass object
C++ Disambiguation: subobject and subclass object
Basically what the title says. I have been referring to Base objects as
subobjects. Is that correct and would it also be correct that subobject ==
superclass object?
The subclass means the derived class and the subclass object means the
derived class' object, right?
The confusion for me is that subclass object != subobject.
If any of this is right, anyway..
Thanks
Basically what the title says. I have been referring to Base objects as
subobjects. Is that correct and would it also be correct that subobject ==
superclass object?
The subclass means the derived class and the subclass object means the
derived class' object, right?
The confusion for me is that subclass object != subobject.
If any of this is right, anyway..
Thanks
How check if succesfull cmd ping in php
How check if succesfull cmd ping in php
how can I check if a php ping returned succesfull or failed using php
exec, I have in mind something with a while loop but I'm not sure if ts
the best approach, I tried:
exec('ping www.google.com', $output)
but I would have to do a var_dump($output); to see the results, I want for
each line the ping command returns to check it
$i = 2;
while(exec('ping www.google.com', $output)) {
if($output) {
echo 'True';
} else {
echo 'False';
}
}
I know this code is WRONG but its kind of what I need, if any of you could
give me a head start on how to do it or suggestions I would really
appreciate it....THANKS!!
how can I check if a php ping returned succesfull or failed using php
exec, I have in mind something with a while loop but I'm not sure if ts
the best approach, I tried:
exec('ping www.google.com', $output)
but I would have to do a var_dump($output); to see the results, I want for
each line the ping command returns to check it
$i = 2;
while(exec('ping www.google.com', $output)) {
if($output) {
echo 'True';
} else {
echo 'False';
}
}
I know this code is WRONG but its kind of what I need, if any of you could
give me a head start on how to do it or suggestions I would really
appreciate it....THANKS!!
Query migration Oracle to Mssql
Query migration Oracle to Mssql
SELECT to_char(TO_DATE(TO_CHAR(ADD_MONTHS(SYSDATE,
0),'YYYYMM'),'YYYYMM'),'DD-MON-YYYY'),
to_char(TO_DATE(TO_CHAR(ADD_MONTHS(SYSDATE, + 1),'YYYYMM'),'YYYYMM') -
1,'DD-MON-YYYY') from dual
can any one help to convert this oracle query into ms sql query ??? plz!!!!!
SELECT to_char(TO_DATE(TO_CHAR(ADD_MONTHS(SYSDATE,
0),'YYYYMM'),'YYYYMM'),'DD-MON-YYYY'),
to_char(TO_DATE(TO_CHAR(ADD_MONTHS(SYSDATE, + 1),'YYYYMM'),'YYYYMM') -
1,'DD-MON-YYYY') from dual
can any one help to convert this oracle query into ms sql query ??? plz!!!!!
Format data as a table in bash
Format data as a table in bash
I have an array of JSON data being printed to the terminal (OS X) and I
want the properties of that to be displayed in a table in the terminal.
Sample query:
aws ec2 describe-instances
| jq '[ .[] | .[] | .Instances[] as $ins \
| { groups: $ins.SecurityGroups[].GroupName, \
addresses: [ $ins.PrivateIpAddress, $ins.PublicIpAddress ], \
dns: $ins.PrivateDnsName, \
name: ($ins.Tags[] as $ts | $ts.Key == "Name" | $ts.Value ) } \
| select(.name | contains("prod")) ]'
Stated another way: I want to take the resulting data structure (array of
object that contains properties 'addresses', 'groups', 'dns', 'name') and
shove each object into a line of a table, inside the terminal/bash.
I don't mind to let the data be EOF-ed before the table starts drawing.
I have an array of JSON data being printed to the terminal (OS X) and I
want the properties of that to be displayed in a table in the terminal.
Sample query:
aws ec2 describe-instances
| jq '[ .[] | .[] | .Instances[] as $ins \
| { groups: $ins.SecurityGroups[].GroupName, \
addresses: [ $ins.PrivateIpAddress, $ins.PublicIpAddress ], \
dns: $ins.PrivateDnsName, \
name: ($ins.Tags[] as $ts | $ts.Key == "Name" | $ts.Value ) } \
| select(.name | contains("prod")) ]'
Stated another way: I want to take the resulting data structure (array of
object that contains properties 'addresses', 'groups', 'dns', 'name') and
shove each object into a line of a table, inside the terminal/bash.
I don't mind to let the data be EOF-ed before the table starts drawing.
Sunday, 25 August 2013
Toshiba Laptop Startup Error
Toshiba Laptop Startup Error
I've a Toshiba Satellite L305s which my dad bought me 4 years ago. It was
working fine until past two months when it started to give random restarts
and colored screens (single but random color each time) and going to
hanged state. I googled and concluded that it had some overheating
problem. So, being a student of engineering in CS, I troubled to open it
up on my own. So, some time ago, I had opened it, cleaned it a bit without
touching it's heat sink and other such delicate areas. Luckily, the
performance had improved. But for the past some time, the problem arose
again and now it was giving restarts in minutes of its startup. So,
yesterday, I opened it up and this time, I cleaned the heat sink too,
including vent fan, etc. But when I assembled back the cover, the laptop
didn't switch on. I thought may be it was out of power so I plugged in the
charging. It was showing charging but still, it wasn't giving start, nor I
found any of the accessories giving any signs of life. I'm confused on
what did I actually screw?
I've a Toshiba Satellite L305s which my dad bought me 4 years ago. It was
working fine until past two months when it started to give random restarts
and colored screens (single but random color each time) and going to
hanged state. I googled and concluded that it had some overheating
problem. So, being a student of engineering in CS, I troubled to open it
up on my own. So, some time ago, I had opened it, cleaned it a bit without
touching it's heat sink and other such delicate areas. Luckily, the
performance had improved. But for the past some time, the problem arose
again and now it was giving restarts in minutes of its startup. So,
yesterday, I opened it up and this time, I cleaned the heat sink too,
including vent fan, etc. But when I assembled back the cover, the laptop
didn't switch on. I thought may be it was out of power so I plugged in the
charging. It was showing charging but still, it wasn't giving start, nor I
found any of the accessories giving any signs of life. I'm confused on
what did I actually screw?
Python __hash__ for equal value objects
Python __hash__ for equal value objects
Say I have some Person entities and I want to know if one is in a list:
person in people?
I don't care what the 'object's ID' is, just that their properties are the
same. So I put this in my base class:
# value comparison only
def __eq__(self, other):
return (isinstance(other, self.__class__) and self.__dict__ ==
other.__dict__)
def __ne__(self, other):
return not self.__eq__(other)
But to be able to test for equality in sets, I also need to define hash So...
# sets use __hash__ for equality comparison
def __hash__(self):
return (
self.PersonID,
self.FirstName,
self.LastName,
self.etc_etc...
).__hash__()
The problem is I don't want to list every property, and I don't want to
modify the hash function every time the properties change.
So is it okay to do this?
# sets use __hash__ for equality comparison
def __hash__(self):
values = tuple(self.__dict__.values())
return hash(values)
Is this sane, and not toooo much of a performance penalty? In a web-app
situation.
Thanks muchly.
Say I have some Person entities and I want to know if one is in a list:
person in people?
I don't care what the 'object's ID' is, just that their properties are the
same. So I put this in my base class:
# value comparison only
def __eq__(self, other):
return (isinstance(other, self.__class__) and self.__dict__ ==
other.__dict__)
def __ne__(self, other):
return not self.__eq__(other)
But to be able to test for equality in sets, I also need to define hash So...
# sets use __hash__ for equality comparison
def __hash__(self):
return (
self.PersonID,
self.FirstName,
self.LastName,
self.etc_etc...
).__hash__()
The problem is I don't want to list every property, and I don't want to
modify the hash function every time the properties change.
So is it okay to do this?
# sets use __hash__ for equality comparison
def __hash__(self):
values = tuple(self.__dict__.values())
return hash(values)
Is this sane, and not toooo much of a performance penalty? In a web-app
situation.
Thanks muchly.
How best to store web hit counter data
How best to store web hit counter data
I have a web hit counter script that currently runs fine. The counter
store its data on a .txt file on public_html and creates a new file for
every month so as to differentiate the number of visits per month in each
year (e.g 8-13.txt), where 8 in August and 13 is 2013.
I am thinking of using a database to store the web hit record but am also
thinking the records to be stored will be much and might cause database
problem because the pages on the site where the web counter will be
implemented will be more than 500. Then there is this problem of creating
a .txt files all over the places.
I can write a script to store the web hit counter data in a database but I
am not clearly sure if it is the best. My question is, if I store these
data on the database, won't it hinder performance when some pages can be
visited more than 3000+ times per month?
Criticism, Ideas are appreciated.
I have a web hit counter script that currently runs fine. The counter
store its data on a .txt file on public_html and creates a new file for
every month so as to differentiate the number of visits per month in each
year (e.g 8-13.txt), where 8 in August and 13 is 2013.
I am thinking of using a database to store the web hit record but am also
thinking the records to be stored will be much and might cause database
problem because the pages on the site where the web counter will be
implemented will be more than 500. Then there is this problem of creating
a .txt files all over the places.
I can write a script to store the web hit counter data in a database but I
am not clearly sure if it is the best. My question is, if I store these
data on the database, won't it hinder performance when some pages can be
visited more than 3000+ times per month?
Criticism, Ideas are appreciated.
@JoinColumn as query param
@JoinColumn as query param
I used jpa, mysql, eclipselink, spring 3. I have two tables in one-to-many
bidirectional relationship. I want to create qurey for @JoinColumn param
but I have an error:
No property save found for type foo.domain.Catalog
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
in my etities:
//bi-directional many-to-one association to Category
@ManyToOne()
@JoinColumn(name="cname", referencedColumnName="name")
private Category category;
//bi-directional many-to-one association to Catalog
@OneToMany(targetEntity=Catalog.class, mappedBy="category",
cascade={CascadeType.ALL}, fetch = FetchType.EAGER)
private List<Catalog> catalog;
query in repository:
@Query("select c from Catalog c where c.category = :cname")
public List<Catalog> takeByCategoryName(Category cname);
I don't know what is going on? Thanks for help.
I used jpa, mysql, eclipselink, spring 3. I have two tables in one-to-many
bidirectional relationship. I want to create qurey for @JoinColumn param
but I have an error:
No property save found for type foo.domain.Catalog
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
in my etities:
//bi-directional many-to-one association to Category
@ManyToOne()
@JoinColumn(name="cname", referencedColumnName="name")
private Category category;
//bi-directional many-to-one association to Catalog
@OneToMany(targetEntity=Catalog.class, mappedBy="category",
cascade={CascadeType.ALL}, fetch = FetchType.EAGER)
private List<Catalog> catalog;
query in repository:
@Query("select c from Catalog c where c.category = :cname")
public List<Catalog> takeByCategoryName(Category cname);
I don't know what is going on? Thanks for help.
Long press (press & hold) gesture in iOS app
Long press (press & hold) gesture in iOS app
I was wondering if this gesture is as commonly found in iPhone and iPad as
in Android apps, or if it is more used in iPad than in iPhone or vice
versa. I personally don't use this gesture very frequently, but I'd like
to have more experienced iOS users' point of view. I think I only found
long press gesture in Calendar app, could somebody give more examples of
using that gesture?
If I decide to use the long press gesture in my own app, for example in a
table row to display further details of the selected item, how could I
make the user aware of the availability of this gesture?
I was wondering if this gesture is as commonly found in iPhone and iPad as
in Android apps, or if it is more used in iPad than in iPhone or vice
versa. I personally don't use this gesture very frequently, but I'd like
to have more experienced iOS users' point of view. I think I only found
long press gesture in Calendar app, could somebody give more examples of
using that gesture?
If I decide to use the long press gesture in my own app, for example in a
table row to display further details of the selected item, how could I
make the user aware of the availability of this gesture?
Saturday, 24 August 2013
Hide pages from google indexing [migrated]
Hide pages from google indexing [migrated]
I am a newbee to website development and SEO. My wordpress site, is
currently using JSON API plugin for getting the json feed for my website.
So far it works fine. Below is one of the sample url form json feed. You
may check the link for results.
http://javatechig.com/api/get_category_posts/?dev=1&slug=android
But It appears in Google sitemap in google search, which is annoying.
Screenshot attached.
Below is my robots.txt file
User-agent: *
Disallow: /wp-content/plugins/
Disallow: /api/
Please help me to fix this. I want to take out form my sitemap
I am a newbee to website development and SEO. My wordpress site, is
currently using JSON API plugin for getting the json feed for my website.
So far it works fine. Below is one of the sample url form json feed. You
may check the link for results.
http://javatechig.com/api/get_category_posts/?dev=1&slug=android
But It appears in Google sitemap in google search, which is annoying.
Screenshot attached.
Below is my robots.txt file
User-agent: *
Disallow: /wp-content/plugins/
Disallow: /api/
Please help me to fix this. I want to take out form my sitemap
"this.collection.each is not a function". Shouldn't it simply say "each"?
"this.collection.each is not a function". Shouldn't it simply say "each"?
I really have a two part question.
The console is telling me: "TypeError: this.collection.each is not a
function"
In the short-term I would love to know why my code isn't working.
In the long term I am more interested in knowing why it is not telling me
that "each" is not a function, since that is the method I am trying to
call.
P.S. I have confirmed that JQuery is loading correctly, and before this
code loads, so that is not the problem.
The pertinent javascript is:
$(function(){
var items = [
{ name: 'Abe Lincoln', details: 'Is he that guy from that new
reality show?'},
{ name: 'Captain Planet', details: 'He is our hero'},
{ name: 'Karthus', details: 'Press R'},
{ name: 'Your Mom', details: 'She misses me'},
{ name: 'Teddy Roosevelt', details: 'Makes the most interesting
man in the world look boring'}
];
var itemsCollectionView = new ListView({collection: items});
Backbone.history.start();
});
var ListView = Backbone.View.extend({
el: '#the-list',
initialize: function(){
this.render();
},
render: function(){
this.collection.each(function(model){
this.addOne(model);
}, this);
},
//create an itemview for a model, and add it to the list view
addOne:function(model){
var itemView = new ItemView({model: model});
this.$el.append(itemView.render().el);
}
});
I really have a two part question.
The console is telling me: "TypeError: this.collection.each is not a
function"
In the short-term I would love to know why my code isn't working.
In the long term I am more interested in knowing why it is not telling me
that "each" is not a function, since that is the method I am trying to
call.
P.S. I have confirmed that JQuery is loading correctly, and before this
code loads, so that is not the problem.
The pertinent javascript is:
$(function(){
var items = [
{ name: 'Abe Lincoln', details: 'Is he that guy from that new
reality show?'},
{ name: 'Captain Planet', details: 'He is our hero'},
{ name: 'Karthus', details: 'Press R'},
{ name: 'Your Mom', details: 'She misses me'},
{ name: 'Teddy Roosevelt', details: 'Makes the most interesting
man in the world look boring'}
];
var itemsCollectionView = new ListView({collection: items});
Backbone.history.start();
});
var ListView = Backbone.View.extend({
el: '#the-list',
initialize: function(){
this.render();
},
render: function(){
this.collection.each(function(model){
this.addOne(model);
}, this);
},
//create an itemview for a model, and add it to the list view
addOne:function(model){
var itemView = new ItemView({model: model});
this.$el.append(itemView.render().el);
}
});
Histogram and Boxplots in Same Panel
Histogram and Boxplots in Same Panel
I have a dataframe with 8 columns (8 variables) and 1000's of
observations. I would like to plot a histogram and a boxplot for each
variable in the same panel.
For example
h1 h2 h3 h4
b1 b2 b3 b4
h5 h6 h7 h8
b5 b6 b7 b8
where hn= histogram of variable n. and bn= boxplot of variable n.
I tried boxplot(dataframe)
hist(dataframe)
But the boxplots are located in the same chart and I get the following
error for the histogram:
Error in hist.default(dataframe) = 'x' must be numeric
Thanks in advance!
pd. is it possible to add a color palette to this panel?
I have a dataframe with 8 columns (8 variables) and 1000's of
observations. I would like to plot a histogram and a boxplot for each
variable in the same panel.
For example
h1 h2 h3 h4
b1 b2 b3 b4
h5 h6 h7 h8
b5 b6 b7 b8
where hn= histogram of variable n. and bn= boxplot of variable n.
I tried boxplot(dataframe)
hist(dataframe)
But the boxplots are located in the same chart and I get the following
error for the histogram:
Error in hist.default(dataframe) = 'x' must be numeric
Thanks in advance!
pd. is it possible to add a color palette to this panel?
iOS User Login Session via Devise but Auth_token not kept
iOS User Login Session via Devise but Auth_token not kept
I am building an iphone app with a rails-backed server. I am using the
devise gem. I am having trouble with user logins on the client-side
(everything works on the web side, and even in the terminal with CURL). On
Xcode I can create a user and I can login. After logging in
(and recieving this in the log: "User logged in!")
I am then pushed to the indexViewController- and here I receive an error
that the posts don't load. The reason is because on the post_controller.rb
I have a
before_filter :authenticate_user!
preventing the posts from loading. The problem is, that the auth_token
which was generated upon a successful login, is not being stored and
passed along to the different views. So then, in the log I get:
'You need to sign in before continuing.'
As if the first part of what I just explained never happened..
In the indexViewController viewDidLoad method I have:
if (![[APIClient sharedClient] isAuthorized]) {
LoginViewController *loginViewController = [[LoginViewController
alloc] init];
[self.navigationController pushViewController:loginViewController
animated:YES];
}
isAuthorized is a BOOL in the APIClient that checks if userID>0
In the user model this is the code that creates a login session
+ (void)loginUser:(NSString *)signature
email:(NSString *)email
password:(NSString *)password
block:(void (^)(User *user))block
{
NSDictionary *parameters = @{ @"user": @{
// @"signature": signature,
@"email": email,
@"password": password
}
};
[[APIClient sharedClient] postPath:@"/users/sign_in"
parameters:parameters success:^(AFHTTPRequestOperation *operation, id
responseObject) {
User *user = [[User alloc] initWithDictionary:responseObject];
if (block) {
block(user);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
if (block) {
block(nil);
}
}];
}
I am guessing it is here that I am missing some auth_token implementation?
Since it is generated automatically by devise- I am not sure how to tell
xcode to remember it. The auth_token is a string that has a column in the
user table on the db. Should I add auth_token as param to the dictionary
that holds the user's email and username? Or how do I get the token to
persist? Any ideas would be helpful.
I am building an iphone app with a rails-backed server. I am using the
devise gem. I am having trouble with user logins on the client-side
(everything works on the web side, and even in the terminal with CURL). On
Xcode I can create a user and I can login. After logging in
(and recieving this in the log: "User logged in!")
I am then pushed to the indexViewController- and here I receive an error
that the posts don't load. The reason is because on the post_controller.rb
I have a
before_filter :authenticate_user!
preventing the posts from loading. The problem is, that the auth_token
which was generated upon a successful login, is not being stored and
passed along to the different views. So then, in the log I get:
'You need to sign in before continuing.'
As if the first part of what I just explained never happened..
In the indexViewController viewDidLoad method I have:
if (![[APIClient sharedClient] isAuthorized]) {
LoginViewController *loginViewController = [[LoginViewController
alloc] init];
[self.navigationController pushViewController:loginViewController
animated:YES];
}
isAuthorized is a BOOL in the APIClient that checks if userID>0
In the user model this is the code that creates a login session
+ (void)loginUser:(NSString *)signature
email:(NSString *)email
password:(NSString *)password
block:(void (^)(User *user))block
{
NSDictionary *parameters = @{ @"user": @{
// @"signature": signature,
@"email": email,
@"password": password
}
};
[[APIClient sharedClient] postPath:@"/users/sign_in"
parameters:parameters success:^(AFHTTPRequestOperation *operation, id
responseObject) {
User *user = [[User alloc] initWithDictionary:responseObject];
if (block) {
block(user);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
if (block) {
block(nil);
}
}];
}
I am guessing it is here that I am missing some auth_token implementation?
Since it is generated automatically by devise- I am not sure how to tell
xcode to remember it. The auth_token is a string that has a column in the
user table on the db. Should I add auth_token as param to the dictionary
that holds the user's email and username? Or how do I get the token to
persist? Any ideas would be helpful.
VS2010 Ultimate Profiler failing
VS2010 Ultimate Profiler failing
I'm trying to profile (via the Instrumentation setting) a large and
complicated program, but the profiler kept failing. I tried again with a
tiny main-only program and got the same error File contains no data
buffers. What's going on?
The full templatized and sanitized output follows:
Setting linker /PROFILE switch (required for instrumentation) on project
[Filename and Path to .vcxproj].
Project will be rebuilt.
Profiling started.
Instrumenting [Filename and path to .exe] in place
Info VSP3049: Small functions will be excluded from instrumentation.
Microsoft (R) VSInstr Post-Link Instrumentation 10.0.40219 x86
Copyright (C) Microsoft Corp. All rights reserved.
Warning VSP2005: Internal instrumentation warning: The object
'\Users\[UserFolder]\AppData\Local\Temp\lnk9E8B.tmp' must be rebuilt with
approved tools.
File to Process:
[Filename and path to .exe] --> [Filename and path to .exe]
Original file backed up to [Filename and path to .exe].orig
Warning VSP2005: Internal instrumentation warning: The object
'\Users\[UserFolder]\AppData\Local\Temp\lnk9E8B.tmp' must be rebuilt with
approved tools.
Successfully instrumented file [Filename and path to .exe].
Data written to [Project Path]\[Project Name]130824.vsp.
Profiling finished.
File contains no data buffers
File contains no data buffers
Analysis failed
Profiling complete.
I'm trying to profile (via the Instrumentation setting) a large and
complicated program, but the profiler kept failing. I tried again with a
tiny main-only program and got the same error File contains no data
buffers. What's going on?
The full templatized and sanitized output follows:
Setting linker /PROFILE switch (required for instrumentation) on project
[Filename and Path to .vcxproj].
Project will be rebuilt.
Profiling started.
Instrumenting [Filename and path to .exe] in place
Info VSP3049: Small functions will be excluded from instrumentation.
Microsoft (R) VSInstr Post-Link Instrumentation 10.0.40219 x86
Copyright (C) Microsoft Corp. All rights reserved.
Warning VSP2005: Internal instrumentation warning: The object
'\Users\[UserFolder]\AppData\Local\Temp\lnk9E8B.tmp' must be rebuilt with
approved tools.
File to Process:
[Filename and path to .exe] --> [Filename and path to .exe]
Original file backed up to [Filename and path to .exe].orig
Warning VSP2005: Internal instrumentation warning: The object
'\Users\[UserFolder]\AppData\Local\Temp\lnk9E8B.tmp' must be rebuilt with
approved tools.
Successfully instrumented file [Filename and path to .exe].
Data written to [Project Path]\[Project Name]130824.vsp.
Profiling finished.
File contains no data buffers
File contains no data buffers
Analysis failed
Profiling complete.
How to implement parallel jags on Windows with foreach?
How to implement parallel jags on Windows with foreach?
I would like to run jags models in parallel on my windows computer with 4
cores, but have not been able to figure out why my model will not run. I
have searched the web extensively including these posts:
http://andrewgelman.com/2011/07/23/parallel-jags-rngs/
http://users.soe.ucsc.edu/~draper/eBay-Google-2013-parallel-rjags-example.txt
When I run a simple example (see code below) with %do%, the model runs
fine (serially of course). When I use %dopar%, I receive the error: Error
in { : task 1 failed - "Symbol table is empty"
Any suggestions would be greatly appreciated.
Jesse
library(rjags)
library(coda)
library(foreach)
library(doParallel)
library(random)
load.module("lecuyer")
### Data generation
y <- rnorm(100)
n <- length(y)
win.data <- list(y=y, n=n)
# Define model
sink("model.txt")
cat("
model {
# Priors
mu ~ dnorm(0, 0.001)
tau <- 1 / (sigma * sigma)
sigma ~ dunif(0, 10)
# Likelihood
for (i in 1:n) {
y[i] ~ dnorm(mu, tau)
}
}
",fill=TRUE)
sink()
inits <- function(){ list(mu=rnorm(1), sigma=runif(1, 0, 10),
.RNG.name = "lecuyer::RngStream",
.RNG.seed = as.numeric(randomNumbers( n = 1, min = 1, max
= 1e+06, col = 1 )) ) }
params <- c('mu','sigma')
cl <- makePSOCKcluster(3)
clusterSetRNGStream(cl)
registerDoParallel()
model.wd <- paste(getwd(), '/model.txt', sep='') # I wondered if the
cores were having trouble finding the model.
m <- foreach(i=1:3, .packages=c('rjags','random','coda'),
.multicombine=TRUE) %dopar% {
load.module( "lecuyer" )
model.jags <- jags.model(model.wd, win.data, inits=inits,
n.chain=1, n.adapt=1000, quiet=TRUE)
result <- coda.samples(model.jags, params, 1000, thin=5)
return(result)
}
stopCluster(cl)
# Error in { : task 1 failed - "Symbol table is empty
sessionInfo()
# R version 3.0.1 (2013-05-16)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
#
# locale:
# [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
LC_MONETARY=English_Canada.1252
# [4] LC_NUMERIC=C LC_TIME=English_Canada.1252
#
# attached base packages:
# [1] parallel stats graphics grDevices utils datasets
methods base
#
# other attached packages:
# [1] random_0.2.1 doParallel_1.0.3 iterators_1.0.6 foreach_1.4.1
rjags_3-10 coda_0.16-1
# [7] lattice_0.20-21
#
# loaded via a namespace (and not attached):
# [1] codetools_0.2-8 compiler_3.0.1 grid_3.0.1 tools_3.0.1
I would like to run jags models in parallel on my windows computer with 4
cores, but have not been able to figure out why my model will not run. I
have searched the web extensively including these posts:
http://andrewgelman.com/2011/07/23/parallel-jags-rngs/
http://users.soe.ucsc.edu/~draper/eBay-Google-2013-parallel-rjags-example.txt
When I run a simple example (see code below) with %do%, the model runs
fine (serially of course). When I use %dopar%, I receive the error: Error
in { : task 1 failed - "Symbol table is empty"
Any suggestions would be greatly appreciated.
Jesse
library(rjags)
library(coda)
library(foreach)
library(doParallel)
library(random)
load.module("lecuyer")
### Data generation
y <- rnorm(100)
n <- length(y)
win.data <- list(y=y, n=n)
# Define model
sink("model.txt")
cat("
model {
# Priors
mu ~ dnorm(0, 0.001)
tau <- 1 / (sigma * sigma)
sigma ~ dunif(0, 10)
# Likelihood
for (i in 1:n) {
y[i] ~ dnorm(mu, tau)
}
}
",fill=TRUE)
sink()
inits <- function(){ list(mu=rnorm(1), sigma=runif(1, 0, 10),
.RNG.name = "lecuyer::RngStream",
.RNG.seed = as.numeric(randomNumbers( n = 1, min = 1, max
= 1e+06, col = 1 )) ) }
params <- c('mu','sigma')
cl <- makePSOCKcluster(3)
clusterSetRNGStream(cl)
registerDoParallel()
model.wd <- paste(getwd(), '/model.txt', sep='') # I wondered if the
cores were having trouble finding the model.
m <- foreach(i=1:3, .packages=c('rjags','random','coda'),
.multicombine=TRUE) %dopar% {
load.module( "lecuyer" )
model.jags <- jags.model(model.wd, win.data, inits=inits,
n.chain=1, n.adapt=1000, quiet=TRUE)
result <- coda.samples(model.jags, params, 1000, thin=5)
return(result)
}
stopCluster(cl)
# Error in { : task 1 failed - "Symbol table is empty
sessionInfo()
# R version 3.0.1 (2013-05-16)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
#
# locale:
# [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
LC_MONETARY=English_Canada.1252
# [4] LC_NUMERIC=C LC_TIME=English_Canada.1252
#
# attached base packages:
# [1] parallel stats graphics grDevices utils datasets
methods base
#
# other attached packages:
# [1] random_0.2.1 doParallel_1.0.3 iterators_1.0.6 foreach_1.4.1
rjags_3-10 coda_0.16-1
# [7] lattice_0.20-21
#
# loaded via a namespace (and not attached):
# [1] codetools_0.2-8 compiler_3.0.1 grid_3.0.1 tools_3.0.1
Substitute for egg yolk in chocolate truffles?
Substitute for egg yolk in chocolate truffles?
I have a recipe for chocolate truffles (basically butter and chocolate)
that also includes an egg yolk; presumably to help smooth it and increase
the richness.
I know that the recipe would probably work just omitting it, but,
Is there a non-perishable, and preferably vegetable based, substitution
that could be used?
I have a recipe for chocolate truffles (basically butter and chocolate)
that also includes an egg yolk; presumably to help smooth it and increase
the richness.
I know that the recipe would probably work just omitting it, but,
Is there a non-perishable, and preferably vegetable based, substitution
that could be used?
how to change position in response apache
how to change position in response apache
I want to change position in response apache for example the following line
HTTP/1.1 200 OK
Date: Sat, 24 Aug 2013 05:10:06 GMT
Content-Length: 0
Server: apache
Pragma: no-cache
X-Powered-By: PHP5
convert to :
HTTP/1.1 200 OK
Pragma: no-cache
Content-Length: 0
Server: apache
X-Powered-By: PHP5
Date: Sat, 24 Aug 2013 05:10:06 GMT
with mod_headers apache
I want to change position in response apache for example the following line
HTTP/1.1 200 OK
Date: Sat, 24 Aug 2013 05:10:06 GMT
Content-Length: 0
Server: apache
Pragma: no-cache
X-Powered-By: PHP5
convert to :
HTTP/1.1 200 OK
Pragma: no-cache
Content-Length: 0
Server: apache
X-Powered-By: PHP5
Date: Sat, 24 Aug 2013 05:10:06 GMT
with mod_headers apache
Friday, 23 August 2013
What build flags are available for brew install of gcc?
What build flags are available for brew install of gcc?
I'm curious as to what build flags are available to me when installing gcc
4.8 using brew.
This question explains how to install gcc 4.8 using brew, but only
specifies two possible flags i.e (--enable-cxx and --enable-fortran).
Is there a list of what's available or can someone iterate them for me?
If it matters I am running OS X 10.7.5 on the Intel i5 dual core.
I'm curious as to what build flags are available to me when installing gcc
4.8 using brew.
This question explains how to install gcc 4.8 using brew, but only
specifies two possible flags i.e (--enable-cxx and --enable-fortran).
Is there a list of what's available or can someone iterate them for me?
If it matters I am running OS X 10.7.5 on the Intel i5 dual core.
Jtree inside JScrollPanel not working
Jtree inside JScrollPanel not working
DefaultMutableTreeNode myComputer = new DefaultMutableTreeNode("My
Computer");
DefaultMutableTreeNode c = new DefaultMutableTreeNode("Local Disk(C:)");
DefaultMutableTreeNode vinod = new DefaultMutableTreeNode("Vinod");
DefaultMutableTreeNode swing = new DefaultMutableTreeNode("Swing");
DefaultMutableTreeNode tr = new DefaultMutableTreeNode("Tree");
DefaultMutableTreeNode a = new DefaultMutableTreeNode("3½ Floppy(A:)");
DefaultMutableTreeNode e = new DefaultMutableTreeNode("New Volume(E:)");
c.add(vinod);
vinod.add(swing);
swing.add(tr);
myComputer.add(c);
myComputer.add(a);
myComputer.add(e);
JTree tree = new JTree(myComputer);
JScrollPane scrollPane = new JScrollPane(tree);
jPanel1.add(scrollPane);
tree.setVisible(true);
I got the new tree example from the web, but when I try to show it, it
does not appear! I dont know why. Any ideas? Thank you!
DefaultMutableTreeNode myComputer = new DefaultMutableTreeNode("My
Computer");
DefaultMutableTreeNode c = new DefaultMutableTreeNode("Local Disk(C:)");
DefaultMutableTreeNode vinod = new DefaultMutableTreeNode("Vinod");
DefaultMutableTreeNode swing = new DefaultMutableTreeNode("Swing");
DefaultMutableTreeNode tr = new DefaultMutableTreeNode("Tree");
DefaultMutableTreeNode a = new DefaultMutableTreeNode("3½ Floppy(A:)");
DefaultMutableTreeNode e = new DefaultMutableTreeNode("New Volume(E:)");
c.add(vinod);
vinod.add(swing);
swing.add(tr);
myComputer.add(c);
myComputer.add(a);
myComputer.add(e);
JTree tree = new JTree(myComputer);
JScrollPane scrollPane = new JScrollPane(tree);
jPanel1.add(scrollPane);
tree.setVisible(true);
I got the new tree example from the web, but when I try to show it, it
does not appear! I dont know why. Any ideas? Thank you!
display:table not working on div in Chrome
display:table not working on div in Chrome
I have been messing around with trying to get a sidebar to stay fixed to a
center div, and I have it mostly working in Firefox and IE, but for some
reason it is not working in Chrome. My issue is that when I resize the
window the left sidebar no longer extends to the bottom of the page in
chrome. All the code is included below, so you can see what I am seeing in
your own browsers.
My question is: why is Chrome acting this way and is there a way for me to
fix this? My Chrome version is 28.0.1500.95.
Thanks.
<html>
<header></header>
<body style="margin:0;">
<div syle="width:100%; height:auto; padding:0;">
<div style="background-color:blue;
width:33%;margin:auto;display:table; height:100%;">
<div style="background-color:green; height:inherit; width:0px;
float:left">
<div style="position:relative; float:left; top:0;
right:45px; background-color:yellow; width: 30px;display:
table; height:100%;">
--Some lorem ipsum here--
<br style="clear: both; " />
</div>
</div>
<div style="position:relative; float:left; width: 95%;
background-color: orange; margin-left: 10px">
--Some lorem ipsum here--
</div>
<br style="clear: both; " />
</div>
</div>
</body>
I have been messing around with trying to get a sidebar to stay fixed to a
center div, and I have it mostly working in Firefox and IE, but for some
reason it is not working in Chrome. My issue is that when I resize the
window the left sidebar no longer extends to the bottom of the page in
chrome. All the code is included below, so you can see what I am seeing in
your own browsers.
My question is: why is Chrome acting this way and is there a way for me to
fix this? My Chrome version is 28.0.1500.95.
Thanks.
<html>
<header></header>
<body style="margin:0;">
<div syle="width:100%; height:auto; padding:0;">
<div style="background-color:blue;
width:33%;margin:auto;display:table; height:100%;">
<div style="background-color:green; height:inherit; width:0px;
float:left">
<div style="position:relative; float:left; top:0;
right:45px; background-color:yellow; width: 30px;display:
table; height:100%;">
--Some lorem ipsum here--
<br style="clear: both; " />
</div>
</div>
<div style="position:relative; float:left; width: 95%;
background-color: orange; margin-left: 10px">
--Some lorem ipsum here--
</div>
<br style="clear: both; " />
</div>
</div>
</body>
Is there an API to determine if a phone has a lock screen set up?
Is there an API to determine if a phone has a lock screen set up?
Is there a way to know if a user has a lock screen set up for their phone
from an application?
Thanks!
Is there a way to know if a user has a lock screen set up for their phone
from an application?
Thanks!
is the next function countnius at (0,0) ? + teoratical question
is the next function countnius at (0,0) ? + teoratical question
Hi I have problem to decide if
is continuous at (0,0).
I have tried to slove this by polar cordinates
but from here the only thing I can tell is , that for every teta, the
limit will be 0.
Is it Enough? because it seems to me that in this case I am only showing
that for every linear path to (0,0) the limit will be 0 ? and is this
function really continuous?
one more thing I heard about a Rule of thumb that if the sum of the powers
in the numerator is lower then the denominator the limit doesn't exist. is
it allways true? thanks,
Hi I have problem to decide if
is continuous at (0,0).
I have tried to slove this by polar cordinates
but from here the only thing I can tell is , that for every teta, the
limit will be 0.
Is it Enough? because it seems to me that in this case I am only showing
that for every linear path to (0,0) the limit will be 0 ? and is this
function really continuous?
one more thing I heard about a Rule of thumb that if the sum of the powers
in the numerator is lower then the denominator the limit doesn't exist. is
it allways true? thanks,
How do I set the default system properties for SBT in Windows?
How do I set the default system properties for SBT in Windows?
I am running sbt version 0.12.4 from command line on Windows and by
default I need to use several system properties each time I do it, for
example:
C:\example>sbt -Dsbt.ivy.home=c:\dev\.ivy2
-Dhttp.proxyHost=proxy.mydomain.net -Dhttp.proxyPort=1234
-Dsbt.global.base=c:\dev\.sbt -Dsbt.boot.directory=c:\dev\.sbt\boot
sbt-version
How do I set those system properties to be the default ones?
The Configuration section of the documentation does not say anything about
default sbt.boot.propeties.
I am running sbt version 0.12.4 from command line on Windows and by
default I need to use several system properties each time I do it, for
example:
C:\example>sbt -Dsbt.ivy.home=c:\dev\.ivy2
-Dhttp.proxyHost=proxy.mydomain.net -Dhttp.proxyPort=1234
-Dsbt.global.base=c:\dev\.sbt -Dsbt.boot.directory=c:\dev\.sbt\boot
sbt-version
How do I set those system properties to be the default ones?
The Configuration section of the documentation does not say anything about
default sbt.boot.propeties.
Thursday, 22 August 2013
Java 7 OCJP from Kathy Sierra, Bert Bates - what's going on? [on hold]
Java 7 OCJP from Kathy Sierra, Bert Bates - what's going on? [on hold]
Does anyone know what's going on with this book
(http://rads.stackoverflow.com/amzn/click/0071772006) ?
It's been scheduled for release in 2011, has been postponed at least 2
times and is now scheduled to be released in December 2014, no less.
Should we wait for the book before trying the OCJP 7 or are there any
literature of comparable quality in existence?
Does anyone know what's going on with this book
(http://rads.stackoverflow.com/amzn/click/0071772006) ?
It's been scheduled for release in 2011, has been postponed at least 2
times and is now scheduled to be released in December 2014, no less.
Should we wait for the book before trying the OCJP 7 or are there any
literature of comparable quality in existence?
VBA Error Handling Multiple times
VBA Error Handling Multiple times
I have an issue. I have values in a workbook that are getting read into an
array. The values come from an XML list so sometimes can be numbers or
text, and if they are numbers in text format ("1" for example), they need
to be converted to number format, so I multiply them by 1. If the value is
text "LS" for example, I am trying to use an error handler to keep the
value as "LS".
I have developed the code below: It works once, but the next time I use a
similar method (with 'Dummy2') the code it produces a 'Type Mismatch'
error.
On Error GoTo Dummy1
For i = 1 To nrows1 - 1
If (Worksheets("Import").Cells(i + 1, 26) * 1 = "") Then
Dummy1:
Table1(i, 1) = Worksheets("Import").Cells(i + 1, 26)
Else
Table1(i, 1) = Worksheets("Import").Cells(i + 1, 26) * 1
End If
Next
On Error GoTo 0
I also tried Clearing Err after the above code with no success.
Please help!
I have an issue. I have values in a workbook that are getting read into an
array. The values come from an XML list so sometimes can be numbers or
text, and if they are numbers in text format ("1" for example), they need
to be converted to number format, so I multiply them by 1. If the value is
text "LS" for example, I am trying to use an error handler to keep the
value as "LS".
I have developed the code below: It works once, but the next time I use a
similar method (with 'Dummy2') the code it produces a 'Type Mismatch'
error.
On Error GoTo Dummy1
For i = 1 To nrows1 - 1
If (Worksheets("Import").Cells(i + 1, 26) * 1 = "") Then
Dummy1:
Table1(i, 1) = Worksheets("Import").Cells(i + 1, 26)
Else
Table1(i, 1) = Worksheets("Import").Cells(i + 1, 26) * 1
End If
Next
On Error GoTo 0
I also tried Clearing Err after the above code with no success.
Please help!
Export to excel opening it
Export to excel opening it
I currently have an option in my app to export to Excel. It saves the data
to a file in disk.
I would like to open Excel instead and show the data. Do any of you know
if this is possible and how to accomplish it?
I guess I can just open the file I'm already saving to disk, but it would
be just better to not save a file to disk at all.
I currently have an option in my app to export to Excel. It saves the data
to a file in disk.
I would like to open Excel instead and show the data. Do any of you know
if this is possible and how to accomplish it?
I guess I can just open the file I'm already saving to disk, but it would
be just better to not save a file to disk at all.
How long are MQTT messages held by broker in QoS 1 or 2?
How long are MQTT messages held by broker in QoS 1 or 2?
So, if I send a MQTT message with QoS 1 or 2 and one of the receivers to
the topic that the message belongs to is offline, how long will the broker
keep it in queue and try to keep resending?
Is this a implementation specific detail for the message broker and the
MQTT Protocol itself has no rules regarding this?
So, if I send a MQTT message with QoS 1 or 2 and one of the receivers to
the topic that the message belongs to is offline, how long will the broker
keep it in queue and try to keep resending?
Is this a implementation specific detail for the message broker and the
MQTT Protocol itself has no rules regarding this?
How to build webrtc with ios objective c
How to build webrtc with ios objective c
I' m trying to build AppRTCDemom example from google webrtc source code,
I'm following the readme file, but after trying this "gclient runhooks" I
get:
"key_id gyp variable needs to be set explicitly because there are multiple
codesigning keys, or none"
Can someone say what happend? what is missing here?
tks
I' m trying to build AppRTCDemom example from google webrtc source code,
I'm following the readme file, but after trying this "gclient runhooks" I
get:
"key_id gyp variable needs to be set explicitly because there are multiple
codesigning keys, or none"
Can someone say what happend? what is missing here?
tks
How to fetch information from this link http://api.discogs.com/artist/ac/dc?
How to fetch information from this link http://api.discogs.com/artist/ac/dc?
before giving me negative votes for this post please consider this
fact.... some say that the link above is in json which is made to look
like xml,some say its in xml... i don't know myself in what format it
is,but looks like xml to me.. i don't remeber how but i was able to fetch
json like information from this page
{"resp": {"status": true, "version": "2.0", "artist": {"profile": "An
Australian rock band, formed in 1973 by Angus and Malcolm Young, they
teamed up with Dave Evans (vocals), Larry Van Kriedt (bass) and Colin
Burgess (drums). In 1974 both Larry Van Kriedt and Colin Burgess left and
were replaced by Rob Bailey (bass) and Peter Clack (drums), a further
change in 1974 saw Peter Clack leave and Tony Currenti (drums) join the
band. In June 1974 they were signed by Harry Vanda & George Young (Malcolm
& Angus's brother) to Albert Productions. In November 1974, Dave Evans
left the band and was replaced by Bon Scott (vocals & bagpipes). Rob
Bailey also left in 1974 and was replaced by George Young (bass). In 1975
Phil Rudd (drums) replaced Tony Currenti and Mark Evans (bass) replaced
George Young. In June 1977 Mark Evans left and is replaced by Cliff
Williams (bass) for their first tour of the USA. On the 19 Feb 1980 Bon
Scott died at the age of 33. Brian Johnson (ex Geordie) joined the band to
replace him on vocals and the album \"Back In Black\" was released, a
tribute to Bon Scott, this album became the 2nd largest selling album of
all time with over 40 million copies sold worldwide. In May 1983, Phil
Rudd had a parting of the ways and was replaced by Simon Wright (drums),
aged 20 then. November 1989 Simon Wright left and is replaced by Chris
Slade (ex Manfred Mann's Earth Band, Uriah Heep & The Firm). In summer
1994 Phil Rudd \"quietly\" rejoined the band.\r\n\r\nAC/DC are Australia's
most successful rock band ever, and are popular around the world.\r\nThe
band was inducted into Rock And Roll Hall Of Fame in 2003 as a
performer.\r\n\r\nCurrent line-up:\r\nAngus Young (lead guitar)\r\nMalcolm
Young (rhythm guitar)\r\nBrian Johnson (vocals)\r\nCliff Williams (bass
guitar)\r\nPhil Rudd (drums)\n", "releases_url":
"http://api.discogs.com/artists/84752/releases", "name": "AC/DC", "uri":
"http://www.discogs.com/artist/AC%2FDC", "members": ["Angus Young", "Bon
Scott", "Brian Johnson", "Chris Slade", "Cliff Williams", "Colin Burgess",
"Dave Evans", "Larry Van Kriedt", "Malcolm Young", "Mark Evans (3)", "Phil
Rudd", "Simon Wright (4)"], "urls": ["http://www.acdcrocks.com/",
"http://www.acdc.com/", "http://www.acdcpower.net/",
"http://www.myspace.com/acdc", "http://en.wikipedia.org/wiki/AC/DC"],
"images": [{"uri": "http://api.discogs.com/image/A-84752-1233004620.jpeg",
"height": 309, "width": 418, "resource_url":
"http://api.discogs.com/image/A-84752-1233004620.jpeg", "type": "primary",
"uri150": "http://api.discogs.com/image/A-150-84752-1233004620.jpeg"},
{"uri": "http://api.discogs.com/image/A-84752-1094915280.jpg", "height":
313, "width": 300, "resource_url":
"http://api.discogs.com/image/A-84752-1094915280.jpg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1094915280.jpg"}, {"uri":
"http://api.discogs.com/image/A-84752-1105107816.jpg", "height": 129,
"width": 180, "resource_url":
"http://api.discogs.com/image/A-84752-1105107816.jpg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1105107816.jpg"}, {"uri":
"http://api.discogs.com/image/A-84752-1107645658.jpg", "height": 199,
"width": 200, "resource_url":
"http://api.discogs.com/image/A-84752-1107645658.jpg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1107645658.jpg"}, {"uri":
"http://api.discogs.com/image/A-84752-1182165014.jpeg", "height": 335,
"width": 498, "resource_url":
"http://api.discogs.com/image/A-84752-1182165014.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1182165014.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1233004627.jpeg", "height": 360,
"width": 480, "resource_url":
"http://api.discogs.com/image/A-84752-1233004627.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1233004627.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1233004633.jpeg", "height": 247,
"width": 457, "resource_url":
"http://api.discogs.com/image/A-84752-1233004633.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1233004633.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1233004641.jpeg", "height": 376,
"width": 400, "resource_url":
"http://api.discogs.com/image/A-84752-1233004641.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1233004641.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1233004648.jpeg", "height": 389,
"width": 572, "resource_url":
"http://api.discogs.com/image/A-84752-1233004648.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1233004648.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1297548279.jpeg", "height": 414,
"width": 600, "resource_url":
"http://api.discogs.com/image/A-84752-1297548279.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1297548279.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1294786426.jpeg", "height": 450,
"width": 450, "resource_url":
"http://api.discogs.com/image/A-84752-1294786426.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1294786426.jpeg"}],
"resource_url": "http://api.discogs.com/artists/84752", "id": 84752,
"data_quality": "Correct", "namevariations": ["AC / DC", "AC DC", "AC-DC",
"AC//DC", "ACDC", "DC/AC", "\u042d\u0439 \u0421\u0438 \u0414\u0438
\u0421\u0438"]}}}
but when you simply try to click on the link it looks like an xml file....
be it whatever be ...i saved both the formats of it and once tried to
fetch xml information and once tried to fetch json information....xml
worked for me ..i used the following code,which worked...put the thing
is....when i try to fetch the information directly from the link....i
don't get anything,please can someone fetch anything from that link?i am
totally confused what should i be fetching json or xml?
Document doc = builder.parse("D:/workspace1/dd.xml");
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression expr = xpath.compile("//resp/artist/images/image[@uri]");
NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
for (int zzz = 0; zzz < nl.getLength(); zzz++)
{
Node currentItem = nl.item(zzz);
String key =
currentItem.getAttributes().getNamedItem("uri").getNodeValue();
System.out.println(key);
}
before giving me negative votes for this post please consider this
fact.... some say that the link above is in json which is made to look
like xml,some say its in xml... i don't know myself in what format it
is,but looks like xml to me.. i don't remeber how but i was able to fetch
json like information from this page
{"resp": {"status": true, "version": "2.0", "artist": {"profile": "An
Australian rock band, formed in 1973 by Angus and Malcolm Young, they
teamed up with Dave Evans (vocals), Larry Van Kriedt (bass) and Colin
Burgess (drums). In 1974 both Larry Van Kriedt and Colin Burgess left and
were replaced by Rob Bailey (bass) and Peter Clack (drums), a further
change in 1974 saw Peter Clack leave and Tony Currenti (drums) join the
band. In June 1974 they were signed by Harry Vanda & George Young (Malcolm
& Angus's brother) to Albert Productions. In November 1974, Dave Evans
left the band and was replaced by Bon Scott (vocals & bagpipes). Rob
Bailey also left in 1974 and was replaced by George Young (bass). In 1975
Phil Rudd (drums) replaced Tony Currenti and Mark Evans (bass) replaced
George Young. In June 1977 Mark Evans left and is replaced by Cliff
Williams (bass) for their first tour of the USA. On the 19 Feb 1980 Bon
Scott died at the age of 33. Brian Johnson (ex Geordie) joined the band to
replace him on vocals and the album \"Back In Black\" was released, a
tribute to Bon Scott, this album became the 2nd largest selling album of
all time with over 40 million copies sold worldwide. In May 1983, Phil
Rudd had a parting of the ways and was replaced by Simon Wright (drums),
aged 20 then. November 1989 Simon Wright left and is replaced by Chris
Slade (ex Manfred Mann's Earth Band, Uriah Heep & The Firm). In summer
1994 Phil Rudd \"quietly\" rejoined the band.\r\n\r\nAC/DC are Australia's
most successful rock band ever, and are popular around the world.\r\nThe
band was inducted into Rock And Roll Hall Of Fame in 2003 as a
performer.\r\n\r\nCurrent line-up:\r\nAngus Young (lead guitar)\r\nMalcolm
Young (rhythm guitar)\r\nBrian Johnson (vocals)\r\nCliff Williams (bass
guitar)\r\nPhil Rudd (drums)\n", "releases_url":
"http://api.discogs.com/artists/84752/releases", "name": "AC/DC", "uri":
"http://www.discogs.com/artist/AC%2FDC", "members": ["Angus Young", "Bon
Scott", "Brian Johnson", "Chris Slade", "Cliff Williams", "Colin Burgess",
"Dave Evans", "Larry Van Kriedt", "Malcolm Young", "Mark Evans (3)", "Phil
Rudd", "Simon Wright (4)"], "urls": ["http://www.acdcrocks.com/",
"http://www.acdc.com/", "http://www.acdcpower.net/",
"http://www.myspace.com/acdc", "http://en.wikipedia.org/wiki/AC/DC"],
"images": [{"uri": "http://api.discogs.com/image/A-84752-1233004620.jpeg",
"height": 309, "width": 418, "resource_url":
"http://api.discogs.com/image/A-84752-1233004620.jpeg", "type": "primary",
"uri150": "http://api.discogs.com/image/A-150-84752-1233004620.jpeg"},
{"uri": "http://api.discogs.com/image/A-84752-1094915280.jpg", "height":
313, "width": 300, "resource_url":
"http://api.discogs.com/image/A-84752-1094915280.jpg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1094915280.jpg"}, {"uri":
"http://api.discogs.com/image/A-84752-1105107816.jpg", "height": 129,
"width": 180, "resource_url":
"http://api.discogs.com/image/A-84752-1105107816.jpg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1105107816.jpg"}, {"uri":
"http://api.discogs.com/image/A-84752-1107645658.jpg", "height": 199,
"width": 200, "resource_url":
"http://api.discogs.com/image/A-84752-1107645658.jpg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1107645658.jpg"}, {"uri":
"http://api.discogs.com/image/A-84752-1182165014.jpeg", "height": 335,
"width": 498, "resource_url":
"http://api.discogs.com/image/A-84752-1182165014.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1182165014.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1233004627.jpeg", "height": 360,
"width": 480, "resource_url":
"http://api.discogs.com/image/A-84752-1233004627.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1233004627.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1233004633.jpeg", "height": 247,
"width": 457, "resource_url":
"http://api.discogs.com/image/A-84752-1233004633.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1233004633.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1233004641.jpeg", "height": 376,
"width": 400, "resource_url":
"http://api.discogs.com/image/A-84752-1233004641.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1233004641.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1233004648.jpeg", "height": 389,
"width": 572, "resource_url":
"http://api.discogs.com/image/A-84752-1233004648.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1233004648.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1297548279.jpeg", "height": 414,
"width": 600, "resource_url":
"http://api.discogs.com/image/A-84752-1297548279.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1297548279.jpeg"}, {"uri":
"http://api.discogs.com/image/A-84752-1294786426.jpeg", "height": 450,
"width": 450, "resource_url":
"http://api.discogs.com/image/A-84752-1294786426.jpeg", "type":
"secondary", "uri150":
"http://api.discogs.com/image/A-150-84752-1294786426.jpeg"}],
"resource_url": "http://api.discogs.com/artists/84752", "id": 84752,
"data_quality": "Correct", "namevariations": ["AC / DC", "AC DC", "AC-DC",
"AC//DC", "ACDC", "DC/AC", "\u042d\u0439 \u0421\u0438 \u0414\u0438
\u0421\u0438"]}}}
but when you simply try to click on the link it looks like an xml file....
be it whatever be ...i saved both the formats of it and once tried to
fetch xml information and once tried to fetch json information....xml
worked for me ..i used the following code,which worked...put the thing
is....when i try to fetch the information directly from the link....i
don't get anything,please can someone fetch anything from that link?i am
totally confused what should i be fetching json or xml?
Document doc = builder.parse("D:/workspace1/dd.xml");
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression expr = xpath.compile("//resp/artist/images/image[@uri]");
NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
for (int zzz = 0; zzz < nl.getLength(); zzz++)
{
Node currentItem = nl.item(zzz);
String key =
currentItem.getAttributes().getNamedItem("uri").getNodeValue();
System.out.println(key);
}
Doctrine Association Mapping - undefined index
Doctrine Association Mapping - undefined index
I have users and products. I want the user to be able to add his favourite
products, but when he adds a new product to his favourites, I don't want
to change anything for the user, what I want is the Product entity to has
a variable, called usersWhoLikedMe and it to be an array, so each product
to keep an array to the users, who liked the product.
If possible I want the User class to know nothing about this, so I want to
change only the Product class. The problem is that I don't know how. :(
I guess it should be OneToMany relation, bacause one product can have many
users who like it.
/**
* @ORM\OneToMany(targetEntity="User", mappedBy="userId")
*/
protected $usersWhoLike;
I added this, but I don't know what to write in the mappedBy option.
Whatever I write, I get an error, saying
An exception has been thrown during the rendering of a template ("Notice:
Undefined index: userId in
C:\xampp\htdocs\MyProject\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php
line 1753")
that's because I wrote a function for Twig, using the new added fields.
I also added there functions to the Product class:
public function addUserWhoLike($user)
{
$this->usersWhoLike[] = $user;
return $this;
}
public function removeUserWhoLike($user)
{
$this->usersWhoLike->removeElement($user);
}
public function getUsersWhoLike()
{
return $this->usersWhoLike;
}
and one more that check if a user is in the array of userswholike a product.
Can you plase help me to fix the relation?
Although the error is in the template, I'm almost sure that it's comming
because of the word after mappedBy
I have users and products. I want the user to be able to add his favourite
products, but when he adds a new product to his favourites, I don't want
to change anything for the user, what I want is the Product entity to has
a variable, called usersWhoLikedMe and it to be an array, so each product
to keep an array to the users, who liked the product.
If possible I want the User class to know nothing about this, so I want to
change only the Product class. The problem is that I don't know how. :(
I guess it should be OneToMany relation, bacause one product can have many
users who like it.
/**
* @ORM\OneToMany(targetEntity="User", mappedBy="userId")
*/
protected $usersWhoLike;
I added this, but I don't know what to write in the mappedBy option.
Whatever I write, I get an error, saying
An exception has been thrown during the rendering of a template ("Notice:
Undefined index: userId in
C:\xampp\htdocs\MyProject\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php
line 1753")
that's because I wrote a function for Twig, using the new added fields.
I also added there functions to the Product class:
public function addUserWhoLike($user)
{
$this->usersWhoLike[] = $user;
return $this;
}
public function removeUserWhoLike($user)
{
$this->usersWhoLike->removeElement($user);
}
public function getUsersWhoLike()
{
return $this->usersWhoLike;
}
and one more that check if a user is in the array of userswholike a product.
Can you plase help me to fix the relation?
Although the error is in the template, I'm almost sure that it's comming
because of the word after mappedBy
Wednesday, 21 August 2013
How to set UITextfield position during device orientation
How to set UITextfield position during device orientation
I have one image view on that image view i put two textField there. When i
put device in portrait mode position on UITextfield is correct. Once i
rotate my device position of UITextfiled change. Please help me.I am using
IOS 6, Thanks in Advance.
I have one image view on that image view i put two textField there. When i
put device in portrait mode position on UITextfield is correct. Once i
rotate my device position of UITextfiled change. Please help me.I am using
IOS 6, Thanks in Advance.
File upload using HTML5's drag and drop in Asp.net
File upload using HTML5's drag and drop in Asp.net
Am trying to upload a file using HTML5's DnD and File API. Am not to sure
how to send form data to the server, i tried to send using XMLHttpRequest
but was not successful. This what i have so far.
- UI
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<br />
<div id="drop_area">Drop files here</div> <br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button"/>
</form>
</body>
- Client-Side Script
<script>
if (window.File && window.FileList && window.FileReader) {
var dropZone = document.getElementById('drop_area');
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleDnDFileSelect,
false);
}
else {
alert('Sorry! this browser does not support HTML5 File
APIs.');
}
</script>
var files;
function handleDragOver(event) {
event.stopPropagation();
event.preventDefault();
var dropZone = document.getElementById('drop_zone');
dropZone.innerHTML = "Drop now";
}
function handleDnDFileSelect(event) {
event.stopPropagation();
event.preventDefault();
/* Read the list of all the selected files. */
files = event.dataTransfer.files;
/* Consolidate the output element. */
var form = document.getElementById('form1');
var data = new FormData(form);
for (var i = 0; i < files.length; i++) {
data.append(files[i].name, files[i]);
}
var xhr = XMLHttpRequest();
xhr.open("POST", "Upload.aspx"); //Wrong ? not sure.
xhr.setRequestHeader("Content-type", "multipart/form-data");
xhr.send(data);
}
- Server Side
HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.Count; i++)
{
HttpPostedFile upload = fileCollection[i];
string filename ="c:\\Test\\" + upload.FileName;
upload.SaveAs(filename);
}
I know i have a button in the UI,as of now am not using. But as you can
see am trying to send a request using XMLHttpRequest. Can anyone suggest
me how can i proceed further. But my server side code never get executed
am not sure whether XMLHttpRequest was successful.
Any help is much appreciated. Thanks in advance.
Am trying to upload a file using HTML5's DnD and File API. Am not to sure
how to send form data to the server, i tried to send using XMLHttpRequest
but was not successful. This what i have so far.
- UI
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<br />
<div id="drop_area">Drop files here</div> <br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button"/>
</form>
</body>
- Client-Side Script
<script>
if (window.File && window.FileList && window.FileReader) {
var dropZone = document.getElementById('drop_area');
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleDnDFileSelect,
false);
}
else {
alert('Sorry! this browser does not support HTML5 File
APIs.');
}
</script>
var files;
function handleDragOver(event) {
event.stopPropagation();
event.preventDefault();
var dropZone = document.getElementById('drop_zone');
dropZone.innerHTML = "Drop now";
}
function handleDnDFileSelect(event) {
event.stopPropagation();
event.preventDefault();
/* Read the list of all the selected files. */
files = event.dataTransfer.files;
/* Consolidate the output element. */
var form = document.getElementById('form1');
var data = new FormData(form);
for (var i = 0; i < files.length; i++) {
data.append(files[i].name, files[i]);
}
var xhr = XMLHttpRequest();
xhr.open("POST", "Upload.aspx"); //Wrong ? not sure.
xhr.setRequestHeader("Content-type", "multipart/form-data");
xhr.send(data);
}
- Server Side
HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.Count; i++)
{
HttpPostedFile upload = fileCollection[i];
string filename ="c:\\Test\\" + upload.FileName;
upload.SaveAs(filename);
}
I know i have a button in the UI,as of now am not using. But as you can
see am trying to send a request using XMLHttpRequest. Can anyone suggest
me how can i proceed further. But my server side code never get executed
am not sure whether XMLHttpRequest was successful.
Any help is much appreciated. Thanks in advance.
apache2 : how to allow access from a file
apache2 : how to allow access from a file
I would like to restrict access to a folder according to some IPs.
I already know how to do that by
<Directory "/path/to/my/directory/">
Order Deny,Allow
Deny from all
Allow from 123.123.123.1 # IP 1
Allow from 123.123.123.2 # IP 2
Allow from 127
</Directory>
As I would like to manage the list of allowed IP differently, I would
prefer allow them from a text file where the IPs could be notes like that
:
123.123.123.1
123.123.123.2
Does anybody know how to do that ? If that's not possible is there another
way to do such thing ?
P.S.: To make everything clear, my final purpose is to grab IPs connected
to a local VPN (OpenVPN), complete a file with the IP if not already
include and restart apache2 so that it can take account of them. It's a
little bit strange but on the same server i have html contents that I
wanna be accessed only by vpn users. But even if I pass through the vpn,
apache2 see the remote IP address not the endpoint one...
I would like to restrict access to a folder according to some IPs.
I already know how to do that by
<Directory "/path/to/my/directory/">
Order Deny,Allow
Deny from all
Allow from 123.123.123.1 # IP 1
Allow from 123.123.123.2 # IP 2
Allow from 127
</Directory>
As I would like to manage the list of allowed IP differently, I would
prefer allow them from a text file where the IPs could be notes like that
:
123.123.123.1
123.123.123.2
Does anybody know how to do that ? If that's not possible is there another
way to do such thing ?
P.S.: To make everything clear, my final purpose is to grab IPs connected
to a local VPN (OpenVPN), complete a file with the IP if not already
include and restart apache2 so that it can take account of them. It's a
little bit strange but on the same server i have html contents that I
wanna be accessed only by vpn users. But even if I pass through the vpn,
apache2 see the remote IP address not the endpoint one...
get attribute with getattr from a object in python
get attribute with getattr from a object in python
I have an object p (liblas.point.Point) with several attributes
pattr = {
"r": 'return_number',
"n": 'number_of_returns',
"s": 'get_point_source_id()',
"e": 'flightline_edge',
"c": 'classification',
"a": 'scan_angle',
}
mylist = ["r", "n", "e", "c", "a"]
for letter in mylist:
print getattr(p, pattr[letter])
1
3
0
1
-23
I have a problem with get_point_source_id() where
p.get_point_source_id()
20
but when i use getattr i got this message
getattr(p, pattr["s"])
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py",
line 2721, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-81-bbad74aa3829>", line 1, in <module>
getattr(p, pattr["s"])
AttributeError: 'Point' object has no attribute 'get_point_source_id()'
I have an object p (liblas.point.Point) with several attributes
pattr = {
"r": 'return_number',
"n": 'number_of_returns',
"s": 'get_point_source_id()',
"e": 'flightline_edge',
"c": 'classification',
"a": 'scan_angle',
}
mylist = ["r", "n", "e", "c", "a"]
for letter in mylist:
print getattr(p, pattr[letter])
1
3
0
1
-23
I have a problem with get_point_source_id() where
p.get_point_source_id()
20
but when i use getattr i got this message
getattr(p, pattr["s"])
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py",
line 2721, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-81-bbad74aa3829>", line 1, in <module>
getattr(p, pattr["s"])
AttributeError: 'Point' object has no attribute 'get_point_source_id()'
Poincare duality on non closed manifolds
Poincare duality on non closed manifolds
For proving the Poincare duality $H_{\mathrm{dR},p}\cong
H_\mathrm{dR}^{m-p}$ one can use the bilinear form
$B:H_\mathrm{dR}^p\times H_\mathrm{dR}^{m-p}\to\mathbb{R}$ given by
$B([\omega],[\beta]):=\int_M\omega\wedge\beta$. $B$ only depends on the
cohomolgy class $[\omega]$ since if $\omega_1,\omega_2\in[\omega]$ one has
for a closed $(m-p)$-form $\beta$
$$\int_M\omega_1\wedge\beta=\int_M\omega_2\wedge\beta-\int_M\mathrm{d}\left(\alpha\wedge\beta\right)=\int_M\omega_2\wedge\beta$$
if $M$ is closed and orientable.
However, some authors (e.g. Jost) only assume $M$ to be compact and
orientable and still use the equation above in their proofs. I am aware
that there is chomolgy with compact support, but as far as I can see the
equation only holds if $\partial M=\varnothing$, i.e. $M$ is closed. What
am I missing?
For proving the Poincare duality $H_{\mathrm{dR},p}\cong
H_\mathrm{dR}^{m-p}$ one can use the bilinear form
$B:H_\mathrm{dR}^p\times H_\mathrm{dR}^{m-p}\to\mathbb{R}$ given by
$B([\omega],[\beta]):=\int_M\omega\wedge\beta$. $B$ only depends on the
cohomolgy class $[\omega]$ since if $\omega_1,\omega_2\in[\omega]$ one has
for a closed $(m-p)$-form $\beta$
$$\int_M\omega_1\wedge\beta=\int_M\omega_2\wedge\beta-\int_M\mathrm{d}\left(\alpha\wedge\beta\right)=\int_M\omega_2\wedge\beta$$
if $M$ is closed and orientable.
However, some authors (e.g. Jost) only assume $M$ to be compact and
orientable and still use the equation above in their proofs. I am aware
that there is chomolgy with compact support, but as far as I can see the
equation only holds if $\partial M=\varnothing$, i.e. $M$ is closed. What
am I missing?
Sharepoint 2013 and Exchange 2010 : synchronization
Sharepoint 2013 and Exchange 2010 : synchronization
I've already posted this situation in Sharepoint StackExchange but nobody
answered me, so I try my luck with you guys.
Here is my post:
I'm starting to use Sharepoint 2013 and trying to synchronize tasks with
Exchange (we have an Exchange 2010) by clicking on the "Sync to Outlook"
button in my profile. But I get the followed error:
We weren't able to sync your tasks. This could be because your mailbox is
on an Exchange server that isn't supported for syncing tasks. Please
contact your administrator for more help.
I read about Exchange 2013 synchronization, but nothing about 2010.
Someone here had the same error than mine. A possible answer is the
version of Exchange: a 2013 version seems to be required. But they talk
about Office version, than O365... So the answer is not satisfying enough.
Is that the source of my problem? Compatibility?
In this tutorial from TechNet, they only mention Exchange 2013, but I
can't find anything about 2010.
So, I'm asking you. Thanks in advance for the help you can provide.
Can someone confirm the Exchange 2013 requirement ?
PS to delete later: can someone create the "sharepoint-2013" tag please ?
I've already posted this situation in Sharepoint StackExchange but nobody
answered me, so I try my luck with you guys.
Here is my post:
I'm starting to use Sharepoint 2013 and trying to synchronize tasks with
Exchange (we have an Exchange 2010) by clicking on the "Sync to Outlook"
button in my profile. But I get the followed error:
We weren't able to sync your tasks. This could be because your mailbox is
on an Exchange server that isn't supported for syncing tasks. Please
contact your administrator for more help.
I read about Exchange 2013 synchronization, but nothing about 2010.
Someone here had the same error than mine. A possible answer is the
version of Exchange: a 2013 version seems to be required. But they talk
about Office version, than O365... So the answer is not satisfying enough.
Is that the source of my problem? Compatibility?
In this tutorial from TechNet, they only mention Exchange 2013, but I
can't find anything about 2010.
So, I'm asking you. Thanks in advance for the help you can provide.
Can someone confirm the Exchange 2013 requirement ?
PS to delete later: can someone create the "sharepoint-2013" tag please ?
Tuesday, 20 August 2013
Social Proxy Server Configuration
Social Proxy Server Configuration
I am using my Company proxy server while redirecting my page to facebook
and vice-versa it gives error for invalid crendentials... I have tried
below two option but its not working...
1.`public ConnectController connectController() { ConnectController
controller = new ConnectController( connectionFactoryLocator(),
connectionRepository());
controller.setApplicationUrl("https://graph.facebook.com/oauth/authorize?client_id=1399601086924425&redirect_uri=http://localhost:8080/spring-social-quickstart-30x");
return controller; }
` 2.
public ConnectController connectController() {
ConnectController controller = new ConnectController(
connectionFactoryLocator(), connectionRepository());
System.setProperty("proxyHost","myProxyAddres");
System.setProperty("proxyPort","myPortNumber");`
}
I am using my Company proxy server while redirecting my page to facebook
and vice-versa it gives error for invalid crendentials... I have tried
below two option but its not working...
1.`public ConnectController connectController() { ConnectController
controller = new ConnectController( connectionFactoryLocator(),
connectionRepository());
controller.setApplicationUrl("https://graph.facebook.com/oauth/authorize?client_id=1399601086924425&redirect_uri=http://localhost:8080/spring-social-quickstart-30x");
return controller; }
` 2.
public ConnectController connectController() {
ConnectController controller = new ConnectController(
connectionFactoryLocator(), connectionRepository());
System.setProperty("proxyHost","myProxyAddres");
System.setProperty("proxyPort","myPortNumber");`
}
open source alternative to BeyondCore One-Click Analysis
open source alternative to BeyondCore One-Click Analysis
Is there any open source alternative to BeyondCore One-Click Analysis ?
BeyondCore is used for detecting and visualizing insights automatically
(eg: uncovers hidden relationships in public health data, etc)
http://strata.oreilly.com/2013/08/one-click-analysis-detecting-and-visualizing-insights-automatically.html
Is there any open source alternative to BeyondCore One-Click Analysis ?
BeyondCore is used for detecting and visualizing insights automatically
(eg: uncovers hidden relationships in public health data, etc)
http://strata.oreilly.com/2013/08/one-click-analysis-detecting-and-visualizing-insights-automatically.html
RTL8188CUS on linux
RTL8188CUS on linux
I used my wifi usb dongle, 0bda:8176 RTL8188CUS, successfully on a
raspberry pi with raspbian (kernel 3.6.11+ compiled for arm). now I want
to have wifi on my dell desktop and the same dongle but it comes out to
suffer from this driver bug
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1030858.
my question is which distros (or which kernel versions) have the bug fixed
and are usable so that I can use them with my desktop
thanks
I used my wifi usb dongle, 0bda:8176 RTL8188CUS, successfully on a
raspberry pi with raspbian (kernel 3.6.11+ compiled for arm). now I want
to have wifi on my dell desktop and the same dongle but it comes out to
suffer from this driver bug
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1030858.
my question is which distros (or which kernel versions) have the bug fixed
and are usable so that I can use them with my desktop
thanks
How do get multicast to work on a Cisco AP1240?
How do get multicast to work on a Cisco AP1240?
I have a Cisco AP1142N in standalone mode acting as a simple AP. On the
wired segment of the LAN, there is an Apple TV that is used to mirror
laptop screens to a large TV screen.
As long as clients are in the wired LAN, they can see and stream to the
Apple TV without issue. It doesn't work when they are associated with the
WLAN, though.
It appears to me that this is a problem with the multicast mDNS queries
not being able to cross segments. Interestingly, according to iperf,
multicast traffic from the WiFi to the wired network is working, but not
the other way around.
I stumbled upon some posts (example) on the Cisco support forum indicating
that IGMP snooping should be deactivated to make multicast "just work", so
I did that:
>show ip igmp snooping
Global IGMP Snooping configuration:
-----------------------------------
IGMP snooping : Disabled
IGMPv3 snooping : Disabled
Report suppression : Disabled
TCN solicit query : Disabled
TCN flood query count : 2
Vlan 10:
--------
IGMP snooping : Disabled
IGMPv2 immediate leave : Disabled
Explicit host tracking : Enabled
Multicast router learning mode : pim-dvmrp
CGMP interoperability mode : IGMP_ONLY
Vlan 99:
--------
IGMP snooping : Disabled
IGMPv2 immediate leave : Disabled
Explicit host tracking : Enabled
Multicast router learning mode : pim-dvmrp
CGMP interoperability mode : IGMP_ONLY
But the situation is still the same: WiFi to wired multicast works, the
other way around does not; thus the WiFi users cannot see the Apple TV.
What other settings do I need to change in order to get mDNS working
across the access point?
I have a Cisco AP1142N in standalone mode acting as a simple AP. On the
wired segment of the LAN, there is an Apple TV that is used to mirror
laptop screens to a large TV screen.
As long as clients are in the wired LAN, they can see and stream to the
Apple TV without issue. It doesn't work when they are associated with the
WLAN, though.
It appears to me that this is a problem with the multicast mDNS queries
not being able to cross segments. Interestingly, according to iperf,
multicast traffic from the WiFi to the wired network is working, but not
the other way around.
I stumbled upon some posts (example) on the Cisco support forum indicating
that IGMP snooping should be deactivated to make multicast "just work", so
I did that:
>show ip igmp snooping
Global IGMP Snooping configuration:
-----------------------------------
IGMP snooping : Disabled
IGMPv3 snooping : Disabled
Report suppression : Disabled
TCN solicit query : Disabled
TCN flood query count : 2
Vlan 10:
--------
IGMP snooping : Disabled
IGMPv2 immediate leave : Disabled
Explicit host tracking : Enabled
Multicast router learning mode : pim-dvmrp
CGMP interoperability mode : IGMP_ONLY
Vlan 99:
--------
IGMP snooping : Disabled
IGMPv2 immediate leave : Disabled
Explicit host tracking : Enabled
Multicast router learning mode : pim-dvmrp
CGMP interoperability mode : IGMP_ONLY
But the situation is still the same: WiFi to wired multicast works, the
other way around does not; thus the WiFi users cannot see the Apple TV.
What other settings do I need to change in order to get mDNS working
across the access point?
About elements disposition in header: logo + slogan + social
About elements disposition in header: logo + slogan + social
I have this code:
<div style="float: left">
<div style="width: 150px; background-color: red">logo</div>
<h1 style="width: 250px; background-color: green" >long slogan</h1>
</div>
<div>fb like and g+ buttons</div>
Is there any way to place foobar3 above the green div???
NOTE: I want to use this code order (logo > long slogan > social), because
I want to show the slogan below the logo in mobiles and tablets, that is
my target, so maybe you can tell me any other work around.
I have this code:
<div style="float: left">
<div style="width: 150px; background-color: red">logo</div>
<h1 style="width: 250px; background-color: green" >long slogan</h1>
</div>
<div>fb like and g+ buttons</div>
Is there any way to place foobar3 above the green div???
NOTE: I want to use this code order (logo > long slogan > social), because
I want to show the slogan below the logo in mobiles and tablets, that is
my target, so maybe you can tell me any other work around.
Joining multiple selects based on a parameter
Joining multiple selects based on a parameter
I have two queries which return the following results (A) & (B) say:
SELECT username, ext_num FROM user u
JOIN extension e
ON u.id=e.user_id;
+----------+---------+
| username | ext_num |
+----------+---------+
| test | 2459871 |
+----------+---------+
1 row in set (0.00 sec)
SELECT TIME_TO_SEC(TIMEDIFF(od.created_at, oc.created_at)) as `duration
(sec)`, oc.ext_num, oc.destination, oc.created_at, oc.call_id
-> FROM on_connected oc
-> JOIN on_disconnected od ON od.call_id = oc.call_id
-> WHERE oc.ext_num = 2459871\G;
*************************** 1. row ***************************
duration (sec): 4
ext_num: 2459871
destination: 55544466677
created_at: 2013-08-19 17:11:53
call_id: 521243ad953e-965inwuz1gku
*************************** 2. row ***************************
duration (sec): 4
ext_num: 2459871
destination: 55544466677
created_at: 2013-08-20 10:28:48
call_id: 521336b51225-0w4mkelwpfui
2 rows in set (0.00 sec)
I would like to join the two tables above to return something like:
+----------------+----------------+-----------------------+---------------------+---------------------------+
| username | duration (sec) | ext_num | destination | created_at
| call_id |
+----------------+----------------+-----------------------+---------------------+---------------------------+
| test | 4 | 2459871 | 55544466677 | 2013-08-19
17:11:53 | 521243ad953e-965inwuz1gku |
| test | 4 | 2459871 | 55544466677 | 2013-08-20
10:28:48 | 521336b51225-0w4mkelwpfui |
+----------------+----------------+-----------------------+---------------------+---------------------------+
I could then, in theory, return all phone calls made for any particular
'ext_num' say or finer grained reporting on 'call_id' if needed.
What have I tried? Well I initially thought of the UNION operator:
(A) UNION (B);
where (A) was padded with NULL values in the SELECT statement but this
produced unstable results.
+----------------+---------+-------------+---------------------+
| duration (sec) | ext_num | destination | created_at |
+----------------+---------+-------------+---------------------+
| 4 | 2459871 | 55544466677 | 2013-08-19 17:11:53 |
| 4 | 2459871 | 55544466677 | 2013-08-20 10:28:48 |
| test | 2459871 | NULL | NULL |
+----------------+---------+-------------+---------------------+
3 rows in set (0.01 sec)
I have two queries which return the following results (A) & (B) say:
SELECT username, ext_num FROM user u
JOIN extension e
ON u.id=e.user_id;
+----------+---------+
| username | ext_num |
+----------+---------+
| test | 2459871 |
+----------+---------+
1 row in set (0.00 sec)
SELECT TIME_TO_SEC(TIMEDIFF(od.created_at, oc.created_at)) as `duration
(sec)`, oc.ext_num, oc.destination, oc.created_at, oc.call_id
-> FROM on_connected oc
-> JOIN on_disconnected od ON od.call_id = oc.call_id
-> WHERE oc.ext_num = 2459871\G;
*************************** 1. row ***************************
duration (sec): 4
ext_num: 2459871
destination: 55544466677
created_at: 2013-08-19 17:11:53
call_id: 521243ad953e-965inwuz1gku
*************************** 2. row ***************************
duration (sec): 4
ext_num: 2459871
destination: 55544466677
created_at: 2013-08-20 10:28:48
call_id: 521336b51225-0w4mkelwpfui
2 rows in set (0.00 sec)
I would like to join the two tables above to return something like:
+----------------+----------------+-----------------------+---------------------+---------------------------+
| username | duration (sec) | ext_num | destination | created_at
| call_id |
+----------------+----------------+-----------------------+---------------------+---------------------------+
| test | 4 | 2459871 | 55544466677 | 2013-08-19
17:11:53 | 521243ad953e-965inwuz1gku |
| test | 4 | 2459871 | 55544466677 | 2013-08-20
10:28:48 | 521336b51225-0w4mkelwpfui |
+----------------+----------------+-----------------------+---------------------+---------------------------+
I could then, in theory, return all phone calls made for any particular
'ext_num' say or finer grained reporting on 'call_id' if needed.
What have I tried? Well I initially thought of the UNION operator:
(A) UNION (B);
where (A) was padded with NULL values in the SELECT statement but this
produced unstable results.
+----------------+---------+-------------+---------------------+
| duration (sec) | ext_num | destination | created_at |
+----------------+---------+-------------+---------------------+
| 4 | 2459871 | 55544466677 | 2013-08-19 17:11:53 |
| 4 | 2459871 | 55544466677 | 2013-08-20 10:28:48 |
| test | 2459871 | NULL | NULL |
+----------------+---------+-------------+---------------------+
3 rows in set (0.01 sec)
upgrading to struts from 2.1.6 to 2.3.15.1
upgrading to struts from 2.1.6 to 2.3.15.1
I upgraded from 2.1.6 to 2.3.15.1 because of the security fixes available
in the latest version.
In my application we are heavily using redirect action, it is impossible
to handle the redirect action in current application. But for the security
improvement it`s need to upgrade the Struts version on PROD environment.
I had upgrade below jars in application lib folder.
a. commons-io-2.0.1 b. commons-logging-1.1.3 c. freemarker-2.3.19 d.
ognl-3.0.6 e. struts2-core-2.3.15 f. struts2-dojo-plugin-2.3.15 g.
struts2-spring-plugin-2.3.15 h. struts2-tiles-plugin-2.3.15 i.
xwork-core-2.3.15 j. xwork-core-2.3.15 k. commons-lang3-3.1
Also do the changes in application to handle the Map and also done the
changes in Localization file. Because of the application is multilingual.
For handle the action mapper i have created the custom mapper (as
suggested by Apache) which is extending to DefaultActionMapper. Now see
below are the xml entries in my xml file
<action name="brand" class="brand">
<param name="loginActionIncluded">true</param>
<result name="success" type="tiles">brand</result>
<result name="SubCategory" type="tiles">searchResult</result>
<result name="noProductsFound" type="tiles">noResultPage</result>
<result name="productPage" type="redirectAction">
<param name="actionName">productInformation</param>
<param name="productCode">${searchResult.redirectParam}</param>
<param name="token">${searchResult.searchToken}</param>
</result>
</action>
<bean id="brand" class="com.rexel.web.action.catbrow.BrandAction"
parent="abstractValidableAction" scope="prototype">
<property name="model" ref="brandModel"></property>
<property name="catalogBrowsingFacade"
ref="catalogBrowsingFacade"></property>
<property name="configurationContext" ref="configurationContext"></property>
<property name="productFacade" ref="productFacade" />
<property name="authorizationFacade" ref="authorizationFacade"/>
<property name="formatStrategy" ref="formatStrategy" />
<property name="redirectHandler" ref="redirectHandler"></property>
<property name="searchModel" ref="searchModel"></property>
</bean>
Now some times it working and sometimes it is not working. See below are
the exception.
Unable to instantiate Action, brand, defined for 'brand' in namespace
'/'Error creating bean with name 'brand' defined in Servlet Context
resource [/WEB-INF/spring/rexel-actions.xml]: Error setting property
values; nested exception is
org.springframework.beans.NotWritablePropertyException: Invalid property
'model' of bean class [com.rexel.web.action.catbrow.BrandAction]: Bean
property 'model' is not writable or has an invalid setter method. Does the
parameter type of the setter match the return type of the getter?
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:316)`
I am surprising some time it is working and some time it is not working.
The exception coming on random basis.
I upgraded from 2.1.6 to 2.3.15.1 because of the security fixes available
in the latest version.
In my application we are heavily using redirect action, it is impossible
to handle the redirect action in current application. But for the security
improvement it`s need to upgrade the Struts version on PROD environment.
I had upgrade below jars in application lib folder.
a. commons-io-2.0.1 b. commons-logging-1.1.3 c. freemarker-2.3.19 d.
ognl-3.0.6 e. struts2-core-2.3.15 f. struts2-dojo-plugin-2.3.15 g.
struts2-spring-plugin-2.3.15 h. struts2-tiles-plugin-2.3.15 i.
xwork-core-2.3.15 j. xwork-core-2.3.15 k. commons-lang3-3.1
Also do the changes in application to handle the Map and also done the
changes in Localization file. Because of the application is multilingual.
For handle the action mapper i have created the custom mapper (as
suggested by Apache) which is extending to DefaultActionMapper. Now see
below are the xml entries in my xml file
<action name="brand" class="brand">
<param name="loginActionIncluded">true</param>
<result name="success" type="tiles">brand</result>
<result name="SubCategory" type="tiles">searchResult</result>
<result name="noProductsFound" type="tiles">noResultPage</result>
<result name="productPage" type="redirectAction">
<param name="actionName">productInformation</param>
<param name="productCode">${searchResult.redirectParam}</param>
<param name="token">${searchResult.searchToken}</param>
</result>
</action>
<bean id="brand" class="com.rexel.web.action.catbrow.BrandAction"
parent="abstractValidableAction" scope="prototype">
<property name="model" ref="brandModel"></property>
<property name="catalogBrowsingFacade"
ref="catalogBrowsingFacade"></property>
<property name="configurationContext" ref="configurationContext"></property>
<property name="productFacade" ref="productFacade" />
<property name="authorizationFacade" ref="authorizationFacade"/>
<property name="formatStrategy" ref="formatStrategy" />
<property name="redirectHandler" ref="redirectHandler"></property>
<property name="searchModel" ref="searchModel"></property>
</bean>
Now some times it working and sometimes it is not working. See below are
the exception.
Unable to instantiate Action, brand, defined for 'brand' in namespace
'/'Error creating bean with name 'brand' defined in Servlet Context
resource [/WEB-INF/spring/rexel-actions.xml]: Error setting property
values; nested exception is
org.springframework.beans.NotWritablePropertyException: Invalid property
'model' of bean class [com.rexel.web.action.catbrow.BrandAction]: Bean
property 'model' is not writable or has an invalid setter method. Does the
parameter type of the setter match the return type of the getter?
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:316)`
I am surprising some time it is working and some time it is not working.
The exception coming on random basis.
Monday, 19 August 2013
iOS deleting a UITableViewCell from UITableView
iOS deleting a UITableViewCell from UITableView
I am using fmdb to manage some data that is display on a regular
UITableView. I am attempting to delete one cell using this code:
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
[db open];
[db beginTransaction];
NSString * stringtoInsert = [NSString stringWithFormat: @"DELETE
FROM TTLogObject WHERE id='%@'", [idArray
objectAtIndex:indexPath.row]];
BOOL success = [db executeUpdate:stringtoInsert];
if (!success)
{
NSLog(@"insert failed!!");
}
NSLog(@"Error %d: %@", [db lastErrorCode], [db lastErrorMessage]);
[db commit];
[db close];
[self getList];
}
}
Here is the code for viewDidLoad and the getList function that I am using.
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.tintColor = [UIColor
blackColor];
shipperCityArray = [[NSMutableArray alloc] init];
pickupDateArray = [[NSMutableArray alloc] init];
paidArray = [[NSMutableArray alloc] init];
idArray = [[NSMutableArray alloc] init];
//NSString *path = [[NSBundle mainBundle] pathForResource:@"tt"
ofType:@"db"];
[self getList];
}
- (void)getList
{
db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
[shipperCityArray removeAllObjects];
[pickupDateArray removeAllObjects];
[paidArray removeAllObjects];
[idArray removeAllObjects];
[db open];
FMResultSet *fResult= [db executeQuery:@"SELECT * FROM TTLogObject"];
while([fResult next])
{
[shipperCityArray addObject:[fResult
stringForColumn:@"shipperCity"]];
[pickupDateArray addObject:[fResult stringForColumn:@"pickupDate"]];
[paidArray addObject:[NSNumber numberWithBool:[fResult
boolForColumn:@"paid"]]];
[idArray addObject:[NSNumber numberWithInteger:[fResult
intForColumn:@"id"]]];
NSLog(@"%@", [NSNumber numberWithInteger:[fResult
intForColumn:@"id"]]);
}
[db close];
[self.tableView reloadData];
}
The issue is that the data gets deleted just fine from the database.
However, after delete is pressed, the table view does not display any
cells anymore. When I restart the app, the proper data gets loaded again,
with the cell that was deleted actually gone. I suspect it has something
to do with numberOfRowsInSection.
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
NSLog(@"%i", [shipperCityArray count]);
return [shipperCityArray count];
}
When the app is launched, it prints the proper amount of cells, but when
delete is hit, it does not print anything, and seems to not be called.
I have attempted to use [self.tableView beginUpdates] and [self.tableView
endUpdates] but those seem to error out stating something about the wrong
number of items resulting after the delete. I am not sure how to solve
this. If I must use beginUpdates and endUpdates, can someone explain to me
how this should be done properly, and what is actually going on?
I am using fmdb to manage some data that is display on a regular
UITableView. I am attempting to delete one cell using this code:
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
[db open];
[db beginTransaction];
NSString * stringtoInsert = [NSString stringWithFormat: @"DELETE
FROM TTLogObject WHERE id='%@'", [idArray
objectAtIndex:indexPath.row]];
BOOL success = [db executeUpdate:stringtoInsert];
if (!success)
{
NSLog(@"insert failed!!");
}
NSLog(@"Error %d: %@", [db lastErrorCode], [db lastErrorMessage]);
[db commit];
[db close];
[self getList];
}
}
Here is the code for viewDidLoad and the getList function that I am using.
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.tintColor = [UIColor
blackColor];
shipperCityArray = [[NSMutableArray alloc] init];
pickupDateArray = [[NSMutableArray alloc] init];
paidArray = [[NSMutableArray alloc] init];
idArray = [[NSMutableArray alloc] init];
//NSString *path = [[NSBundle mainBundle] pathForResource:@"tt"
ofType:@"db"];
[self getList];
}
- (void)getList
{
db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
[shipperCityArray removeAllObjects];
[pickupDateArray removeAllObjects];
[paidArray removeAllObjects];
[idArray removeAllObjects];
[db open];
FMResultSet *fResult= [db executeQuery:@"SELECT * FROM TTLogObject"];
while([fResult next])
{
[shipperCityArray addObject:[fResult
stringForColumn:@"shipperCity"]];
[pickupDateArray addObject:[fResult stringForColumn:@"pickupDate"]];
[paidArray addObject:[NSNumber numberWithBool:[fResult
boolForColumn:@"paid"]]];
[idArray addObject:[NSNumber numberWithInteger:[fResult
intForColumn:@"id"]]];
NSLog(@"%@", [NSNumber numberWithInteger:[fResult
intForColumn:@"id"]]);
}
[db close];
[self.tableView reloadData];
}
The issue is that the data gets deleted just fine from the database.
However, after delete is pressed, the table view does not display any
cells anymore. When I restart the app, the proper data gets loaded again,
with the cell that was deleted actually gone. I suspect it has something
to do with numberOfRowsInSection.
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
NSLog(@"%i", [shipperCityArray count]);
return [shipperCityArray count];
}
When the app is launched, it prints the proper amount of cells, but when
delete is hit, it does not print anything, and seems to not be called.
I have attempted to use [self.tableView beginUpdates] and [self.tableView
endUpdates] but those seem to error out stating something about the wrong
number of items resulting after the delete. I am not sure how to solve
this. If I must use beginUpdates and endUpdates, can someone explain to me
how this should be done properly, and what is actually going on?
Why doesn't this code render the time in addition to the date?
Why doesn't this code render the time in addition to the date?
This code renders the date (month, day, year) but not the time. It is
being used on a php upload site. I am grateful for any suggestions. Thank
you.
<time datetime="<?= date( 'm-d-Y', strtotime( $file->added ) ) ?>"><?=
date( 'm.d.Y', strtotime( $file->added ) ) ?>
This code renders the date (month, day, year) but not the time. It is
being used on a php upload site. I am grateful for any suggestions. Thank
you.
<time datetime="<?= date( 'm-d-Y', strtotime( $file->added ) ) ?>"><?=
date( 'm.d.Y', strtotime( $file->added ) ) ?>
Dynamic dropdown selection fills in textfields from db with ajax
Dynamic dropdown selection fills in textfields from db with ajax
I have 2 files. html.php and getuser.php
In html.php I have a dynamic dropdown filled with ids from a mysql
database. In getuser.php I have code that should take the selected
dropdown value and return the companyname where the id is the same as the
id value from the dropdown.
You can see the files in jsfiddle (In the js area!):
html.php
(http://jsfiddle.net/qHvZM/1/)
getuser.php
(http://jsfiddle.net/Ez9Hs/)
WHAT DO I WANT TO ACHIEVE: The db has the following details:
cb_dealerid = 001, 002, 003, 004
cb_bedrijfsnaam = Joop BV, Kelly Ltd, Johan Ltd, Peter BV
When you select from the dropdown value 002 then it should say in the
appropriate area Kelly Ltd.
Thanks for any help!
I have 2 files. html.php and getuser.php
In html.php I have a dynamic dropdown filled with ids from a mysql
database. In getuser.php I have code that should take the selected
dropdown value and return the companyname where the id is the same as the
id value from the dropdown.
You can see the files in jsfiddle (In the js area!):
html.php
(http://jsfiddle.net/qHvZM/1/)
getuser.php
(http://jsfiddle.net/Ez9Hs/)
WHAT DO I WANT TO ACHIEVE: The db has the following details:
cb_dealerid = 001, 002, 003, 004
cb_bedrijfsnaam = Joop BV, Kelly Ltd, Johan Ltd, Peter BV
When you select from the dropdown value 002 then it should say in the
appropriate area Kelly Ltd.
Thanks for any help!
int() argument must be a string or a number, not 'function' in django messages
int() argument must be a string or a number, not 'function' in django
messages
I am trying to use messages framework in my view, but its displaying the
following error
views.py
def gcontacts(request):
error = True
if request.method == 'POST':
if request.POST.has_key('wow'):
error = False
messages.add_message(request, messages.success, 'Wow key
exists !!!!')
else:
error = True
return render_to_response('key_exists.html', {'error':error},
context_instance=RequestContext(request))
error
Traceback (most recent call last):
File
"/home/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File
"/home/Envs/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py",
line 25, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/virtualenvironment/apps/myapp/views.py", line 33, in gcontacts
messages.add_message(request, messages.success, 'Wow key exists !!!!')
File
"/home/Envs/local/lib/python2.7/site-packages/django/contrib/messages/api.py",
line 20, in add_message
return request._messages.add(level, message, extra_tags)
File
"/home/Envs/local/lib/python2.7/site-packages/django/contrib/messages/storage/base.py",
line 153, in add
level = int(level)
TypeError: int() argument must be a string or a number, not 'function'
can anyone please let me know what i am doing wrong in the above code ?
messages
I am trying to use messages framework in my view, but its displaying the
following error
views.py
def gcontacts(request):
error = True
if request.method == 'POST':
if request.POST.has_key('wow'):
error = False
messages.add_message(request, messages.success, 'Wow key
exists !!!!')
else:
error = True
return render_to_response('key_exists.html', {'error':error},
context_instance=RequestContext(request))
error
Traceback (most recent call last):
File
"/home/local/lib/python2.7/site-packages/django/core/handlers/base.py",
line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File
"/home/Envs/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py",
line 25, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/virtualenvironment/apps/myapp/views.py", line 33, in gcontacts
messages.add_message(request, messages.success, 'Wow key exists !!!!')
File
"/home/Envs/local/lib/python2.7/site-packages/django/contrib/messages/api.py",
line 20, in add_message
return request._messages.add(level, message, extra_tags)
File
"/home/Envs/local/lib/python2.7/site-packages/django/contrib/messages/storage/base.py",
line 153, in add
level = int(level)
TypeError: int() argument must be a string or a number, not 'function'
can anyone please let me know what i am doing wrong in the above code ?
Sunday, 18 August 2013
Excel97 crash, Windows 7, VBA, DEP
Excel97 crash, Windows 7, VBA, DEP
I've not be able to get Excel 97 VBA to run correctly on Win 7 without
turning DEP entirely off. Access97 runs ok with just an Access DEP
exception, But making Excel a DEP exception has not helped.
Specifically, Excel 97 crashes and closes when I (a) try to delete an
add-in, or (b) call a Win32 API (even after I remove all the add-ins), or
(c) use a Forms button (which is a call to a COM object).
I can (and have) remove all the add-ins by moving the files. I can (and
have) remove all the unused references, including forms2.
Can you suggest any other DEP exclusions that might make Excel happy?
I've not be able to get Excel 97 VBA to run correctly on Win 7 without
turning DEP entirely off. Access97 runs ok with just an Access DEP
exception, But making Excel a DEP exception has not helped.
Specifically, Excel 97 crashes and closes when I (a) try to delete an
add-in, or (b) call a Win32 API (even after I remove all the add-ins), or
(c) use a Forms button (which is a call to a COM object).
I can (and have) remove all the add-ins by moving the files. I can (and
have) remove all the unused references, including forms2.
Can you suggest any other DEP exclusions that might make Excel happy?
WCF endpoint configuration with jsonp
WCF endpoint configuration with jsonp
I'm trying to solve this problem:
http://www.medicallperu.com/services/Medicall.svc
This is my current web.config file and I know its something about the
endpoint. I'm working on mochahost so I needed to add extra lines to work
with WCF, I also use crossdomain calls from java, so thats why I use
jsonp. Everything works well if I call any method, its working perfectly
but I have that endpoint error. Any help would be appreciated.
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP"
crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>
<services>
<service name="Medicall_WCF.Medicall">
<endpoint address="/Medicall.svc" binding="webHttpBinding"
bindingConfiguration="webHttpBindingWithJsonP"
contract="Medicall_WCF.Medicall"
behaviorConfiguration="webHttpBehavior"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.web>
<!--<compilation debug="true" targetFramework="4.0" />-->
<customErrors mode="Off"/>
</system.web>
<appSettings>
<add key="" value="" />
</appSettings>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="svc-ISAPI-2.0a" path="*.svc" verb="*" modules="IsapiModule"
scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
resourceType="Unspecified"
preCondition="classicMode,runtimeVersionv2.0,bitness32" />
<add name="svc-Integrateda" path="*.svc" verb="*"
type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</location>
I'm trying to solve this problem:
http://www.medicallperu.com/services/Medicall.svc
This is my current web.config file and I know its something about the
endpoint. I'm working on mochahost so I needed to add extra lines to work
with WCF, I also use crossdomain calls from java, so thats why I use
jsonp. Everything works well if I call any method, its working perfectly
but I have that endpoint error. Any help would be appreciated.
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP"
crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>
<services>
<service name="Medicall_WCF.Medicall">
<endpoint address="/Medicall.svc" binding="webHttpBinding"
bindingConfiguration="webHttpBindingWithJsonP"
contract="Medicall_WCF.Medicall"
behaviorConfiguration="webHttpBehavior"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.web>
<!--<compilation debug="true" targetFramework="4.0" />-->
<customErrors mode="Off"/>
</system.web>
<appSettings>
<add key="" value="" />
</appSettings>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="svc-ISAPI-2.0a" path="*.svc" verb="*" modules="IsapiModule"
scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
resourceType="Unspecified"
preCondition="classicMode,runtimeVersionv2.0,bitness32" />
<add name="svc-Integrateda" path="*.svc" verb="*"
type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</location>
Twitter Like URL but with a @'s?
Twitter Like URL but with a @'s?
I am making a social networking website, and I can't get this done: If the
url is http://url.com/@username, I want it to show the
http://url.com/user?u=username page, but show http://url.com/@username
URL.
However, if there is no @ in the beginning, treat it like a regular URL.
This is my .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/(\d+)*$ ./user.php?u=$1
I am making a social networking website, and I can't get this done: If the
url is http://url.com/@username, I want it to show the
http://url.com/user?u=username page, but show http://url.com/@username
URL.
However, if there is no @ in the beginning, treat it like a regular URL.
This is my .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/(\d+)*$ ./user.php?u=$1
fancyvrb and multicols together
fancyvrb and multicols together
I am using fancyvrb to list code in a multicols situation. I number the
code using:
\begin{Verbatim}[numbers=left]
When the code is in the left column, this is good, but not when it is in
the right column. I wish to put the numbers in the right column on the
right side.
Is there a way to automatically put the numbers on the side that the code
is being listed on? Or is there a way of determining what column I am in
in the multicols environment.
I am using fancyvrb to list code in a multicols situation. I number the
code using:
\begin{Verbatim}[numbers=left]
When the code is in the left column, this is good, but not when it is in
the right column. I wish to put the numbers in the right column on the
right side.
Is there a way to automatically put the numbers on the side that the code
is being listed on? Or is there a way of determining what column I am in
in the multicols environment.
Long running JDBC transaction: Closed Connection
Long running JDBC transaction: Closed Connection
I am using c3p0 for connection pooling and facing "Closed connection"
error with large data sets. I expect my transaction to be atomic and to
run for almost max 2 hours.
For large data sets, which take around 40-45 minutes in processing. When I
try to persist this data in the DB, I get exceptions in the following
sequence:
[WARN] [c3p0] A PooledConnection that has already signalled a Connection
error is still in use!
[WARN] [c3p0] Another error has occurred [
java.sql.SQLRecoverableException: Closed Connection ] which will not be
reported to listeners!
[ERROR] org.hibernate.transaction.JDBCTransaction: Could not toggle
autocommit
java.sql.SQLRecoverableException: Closed Connection
[ERROR] org.hibernate.transaction.JDBCTransaction: JDBC rollback failed
[ERROR]
org.springframework.transaction.interceptor.TransactionInterceptor:
Application exception overridden by rollback exception.
I have tried exploring solution a lot and tried to update my configuration
accordingly. Here is my C3P0 configuration:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${...}" />
<property name="jdbcUrl" value="${...}" />
<property name="user" value="${...}" />
<property name="password" value="${...}" />
<property name="initialPoolSize" value="2" />
<property name="minPoolSize" value="2" />
<property name="maxPoolSize" value="50" />
<property name="maxIdleTime" value="6000" />
<property name="maxIdleTimeExcessConnections" value="1800" />
<property name="idleConnectionTestPeriod" value="3600" />
<property name="checkoutTimeout" value="60000" />
<property name="acquireRetryAttempts" value="0" />
<property name="acquireRetryDelay" value="1000" />
<property name="numHelperThreads" value="1" />
<property name="preferredTestQuery" value="SELECT 1 FROM DUAL" />
</bean>
Please help.
I am using c3p0 for connection pooling and facing "Closed connection"
error with large data sets. I expect my transaction to be atomic and to
run for almost max 2 hours.
For large data sets, which take around 40-45 minutes in processing. When I
try to persist this data in the DB, I get exceptions in the following
sequence:
[WARN] [c3p0] A PooledConnection that has already signalled a Connection
error is still in use!
[WARN] [c3p0] Another error has occurred [
java.sql.SQLRecoverableException: Closed Connection ] which will not be
reported to listeners!
[ERROR] org.hibernate.transaction.JDBCTransaction: Could not toggle
autocommit
java.sql.SQLRecoverableException: Closed Connection
[ERROR] org.hibernate.transaction.JDBCTransaction: JDBC rollback failed
[ERROR]
org.springframework.transaction.interceptor.TransactionInterceptor:
Application exception overridden by rollback exception.
I have tried exploring solution a lot and tried to update my configuration
accordingly. Here is my C3P0 configuration:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${...}" />
<property name="jdbcUrl" value="${...}" />
<property name="user" value="${...}" />
<property name="password" value="${...}" />
<property name="initialPoolSize" value="2" />
<property name="minPoolSize" value="2" />
<property name="maxPoolSize" value="50" />
<property name="maxIdleTime" value="6000" />
<property name="maxIdleTimeExcessConnections" value="1800" />
<property name="idleConnectionTestPeriod" value="3600" />
<property name="checkoutTimeout" value="60000" />
<property name="acquireRetryAttempts" value="0" />
<property name="acquireRetryDelay" value="1000" />
<property name="numHelperThreads" value="1" />
<property name="preferredTestQuery" value="SELECT 1 FROM DUAL" />
</bean>
Please help.
how to see if all checkboxes are empty in php
how to see if all checkboxes are empty in php
In PHP, how do I see if all checkboxes are empty? This is an excerpt from
my code: Basically, I want to use an "if" and "else" code that is
specifically for when all my checkboxes are unchecked.
$titlebox=isset($_GET['title']) ? "checked='checked'" : '';
$authorbox=isset($_GET['author']) ? "checked='checked'" : '';
// keeps checkboxes checked after submit
<form action="" method="get">
<input type="text" name="search">
<input type="submit" value="Search">
<input type="checkbox" name="title" '.$titlebox.' >
<label for="title">Title</label>
<input type="checkbox" name="author" '.$authorbox.' >
<label for="author">Author</label>
</form>
// form
if (isset($_GET['title']))
{ $searchbooktitle = $bookfieldtitle;
}
else
{ $searchbooktitle = NULL;
};
// this is how I get individual checkboxes.
The last part shows how I get individual checkboxes, but how do I get all
the checkboxes and see if they are empty? I'd like to use a specific "if"
and "else" code that will strictly apply only if all checkboxes are
unchecked.
The answer might be simple but I'm new at this and confused. Please help!
In PHP, how do I see if all checkboxes are empty? This is an excerpt from
my code: Basically, I want to use an "if" and "else" code that is
specifically for when all my checkboxes are unchecked.
$titlebox=isset($_GET['title']) ? "checked='checked'" : '';
$authorbox=isset($_GET['author']) ? "checked='checked'" : '';
// keeps checkboxes checked after submit
<form action="" method="get">
<input type="text" name="search">
<input type="submit" value="Search">
<input type="checkbox" name="title" '.$titlebox.' >
<label for="title">Title</label>
<input type="checkbox" name="author" '.$authorbox.' >
<label for="author">Author</label>
</form>
// form
if (isset($_GET['title']))
{ $searchbooktitle = $bookfieldtitle;
}
else
{ $searchbooktitle = NULL;
};
// this is how I get individual checkboxes.
The last part shows how I get individual checkboxes, but how do I get all
the checkboxes and see if they are empty? I'd like to use a specific "if"
and "else" code that will strictly apply only if all checkboxes are
unchecked.
The answer might be simple but I'm new at this and confused. Please help!
Saturday, 17 August 2013
Does "-All Armor" create 1 debuff or 1 debuff for each armor type?
Does "-All Armor" create 1 debuff or 1 debuff for each armor type?
We know from this answer that skills/items with "-X All Armor" give a 5
second debuff on the monster that is refreshed if they are hit again
within that 5 seconds and continues to stack all the way down to 0 armor.
However, if I am playing a Berserker with "-200 Physical Armor" per hit
from the Shred Armor skill and my friend is playing an Engineer with "-100
All Armor" per hit, do they create separate debuffs (does the monster get
1 debuff saying -200 physical armor and 1 saying -100 all armor) from each
hit?
Or does the "-X All Armor" create 5 debuffs (1 for each armor type) such
that the "-X Physical Armor" stacks with the Shred Armor skill?
We know from this answer that skills/items with "-X All Armor" give a 5
second debuff on the monster that is refreshed if they are hit again
within that 5 seconds and continues to stack all the way down to 0 armor.
However, if I am playing a Berserker with "-200 Physical Armor" per hit
from the Shred Armor skill and my friend is playing an Engineer with "-100
All Armor" per hit, do they create separate debuffs (does the monster get
1 debuff saying -200 physical armor and 1 saying -100 all armor) from each
hit?
Or does the "-X All Armor" create 5 debuffs (1 for each armor type) such
that the "-X Physical Armor" stacks with the Shred Armor skill?
Auto login to Apple developer website
Auto login to Apple developer website
I am trying to login to the developer site through PHP or some other auto
login method but nothing has seemed to work.
The website link is here: Apple Developer Login
I have tried using curl with no luck. Any help would be great.
Thank You!
I am trying to login to the developer site through PHP or some other auto
login method but nothing has seemed to work.
The website link is here: Apple Developer Login
I have tried using curl with no luck. Any help would be great.
Thank You!
Keep track of everybody who uses my code
Keep track of everybody who uses my code
I made a theme for tumblr and I want to release the code to the public.
The thing is, want to know how many people are using my theme. Is there
any javascript or other solution to this other than google analytic?
I made a theme for tumblr and I want to release the code to the public.
The thing is, want to know how many people are using my theme. Is there
any javascript or other solution to this other than google analytic?
http_build_query param for ?
http_build_query param for ?
Does anyone know how to make http_build_query add a ? at the beginning if
one is not present?
Right now I am adding index.php? to all of my links. I have reasons to NOT
want the ? hardcoded into the link. If http_build_query would just add it
if one isn't present some how, that would be a huge help.
Does anyone know how to make http_build_query add a ? at the beginning if
one is not present?
Right now I am adding index.php? to all of my links. I have reasons to NOT
want the ? hardcoded into the link. If http_build_query would just add it
if one isn't present some how, that would be a huge help.
Linq DateTimeOffset throws InvalidTimeZoneException
Linq DateTimeOffset throws InvalidTimeZoneException
My Linq query of DateTimeOffset column always throws
InvalidTimeZoneException. The data appears to be correct. Any idea what's
happening?
Details:
Oracle Column: CREATED_DATETIME TIMESTAMP(0) WITH TIME ZONE
EF MAPPING: public Nullable<System.DateTimeOffset> CREATED_DATETIME {
get; set; }
DataAccess: ODP.net Oracle.DataAccess
Data Sample: (Timezone column available but not used)
CREATED_DATETIME TIMEZONE_NAME
8/16/2013 5:06:05 PM +00:00 US/Central
8/16/2013 5:35:06 PM +00:00 US/Mountain
Code:
var q = from isr in pc.ISRs
select isr.CREATED_DATETIME;
try
{
DateTimeOffset? value = q.First();
}
catch (InvalidTimeZoneException tze)
{
throw new ApplicationException(tze.Message);
}
catch (Exception e)
{
throw new ApplicationException(e.Message);
}
var orders = from o in q select o;
My Linq query of DateTimeOffset column always throws
InvalidTimeZoneException. The data appears to be correct. Any idea what's
happening?
Details:
Oracle Column: CREATED_DATETIME TIMESTAMP(0) WITH TIME ZONE
EF MAPPING: public Nullable<System.DateTimeOffset> CREATED_DATETIME {
get; set; }
DataAccess: ODP.net Oracle.DataAccess
Data Sample: (Timezone column available but not used)
CREATED_DATETIME TIMEZONE_NAME
8/16/2013 5:06:05 PM +00:00 US/Central
8/16/2013 5:35:06 PM +00:00 US/Mountain
Code:
var q = from isr in pc.ISRs
select isr.CREATED_DATETIME;
try
{
DateTimeOffset? value = q.First();
}
catch (InvalidTimeZoneException tze)
{
throw new ApplicationException(tze.Message);
}
catch (Exception e)
{
throw new ApplicationException(e.Message);
}
var orders = from o in q select o;
Do variable identifiers make it easier to read code?
Do variable identifiers make it easier to read code?
In most programming languages variables do not have identifiers like they
do in PHP. In PHP you must prefix a variable with the $ character.
Example;
var $foo = "something";
echo $foo;
I'm developing a new scripting language for a business application, and my
target users do not have a programming background. Do variable identifiers
make code easier to read and use?
One reason PHP uses the $ is because without it PHP can't tell if a name
is a function reference or variable reference. This is because the
language allows strange references to functions. So the $ symbol helps the
parser separate the namespace.
I don't have this problem in my parser. So my question is purely on
readability and ease of use. I have coded for so many years in PHP that
when I see $foo it's easy for me to identify this as a variable. Am I just
giving a bias preference to this identifier?
In most programming languages variables do not have identifiers like they
do in PHP. In PHP you must prefix a variable with the $ character.
Example;
var $foo = "something";
echo $foo;
I'm developing a new scripting language for a business application, and my
target users do not have a programming background. Do variable identifiers
make code easier to read and use?
One reason PHP uses the $ is because without it PHP can't tell if a name
is a function reference or variable reference. This is because the
language allows strange references to functions. So the $ symbol helps the
parser separate the namespace.
I don't have this problem in my parser. So my question is purely on
readability and ease of use. I have coded for so many years in PHP that
when I see $foo it's easy for me to identify this as a variable. Am I just
giving a bias preference to this identifier?
Subscribe to:
Comments (Atom)