Thursday, 3 October 2013

InvokeOnMainThread doesn't work with `method group`

InvokeOnMainThread doesn't work with `method group`

NOTE: I found a workaround to my problem even before asking the question,
but I'm still wondering why it behave like this.
I'm doing an usual xamarin.iOS application, using async/await, Mvvm, ...
nothing fancy on the technology side.
I found out that the following code (using a method group) wasn't working:
ViewModel.PropertyChanged += (sender, e) => {
if (e.PropertyName != "MyProperty")
return;
InvokeOnMainThread (tableViewController.TableView.ReloadData);
};
If I put a breakpoint on InvokeOnMainThread, I can see the exception:

But the same code with a lambda expression works just fine.
ViewModel.PropertyChanged += (sender, e) => {
if (e.PropertyName != "MyProperty")
return;
InvokeOnMainThread (() => tableViewController.TableView.ReloadData ());
};
A part of me is suspecting a bug, another part is already blaming my
ignorance. Anyone knows which part is right ?
Version details:
Xamarin Studio
Version 4.1.12 (build 6)
Installation UUID: [...]
Runtime:
Mono 3.2.3 ((no/8d3b4b7)
GTK+ 2.24.20 theme: Raleigh
GTK# (2.12.0.0)
Package version: 302030000
Apple Developer Tools
Xcode 5.0 (3332.22)
Build 5A1412
Xamarin.iOS
Version: 7.0.1.4 (Business Edition)
Hash: [...]
Branch:
Build date: 2013-20-09 23:14:32-0400
Build Information
Release ID: 401120006
Git revision: a9ae69a4bf37955e4ab4df0cec7804f574c51f72
Build date: 2013-09-25 16:59:37+0000
Xamarin addins: 761ae26f220068dda0b62f0dd2253f617589a8c6
Operating System
Mac OS X 10.8.5
Darwin Stephanes-MacBook-Air.local 12.5.0 Darwin Kernel Version 12.5.0
Mon Jul 29 16:33:49 PDT 2013
root:xnu-2050.48.11~1/RELEASE_X86_64 x86_64

Wednesday, 2 October 2013

NSJSONSerialization - What is the proper value to specify no NSJSONWritingOptions for dataWithJSONObject:options:error:?

NSJSONSerialization - What is the proper value to specify no
NSJSONWritingOptions for dataWithJSONObject:options:error:?

Apple's documentation has the NSJSONWritingOptions enum with one constant
defined: NSJSONWritingPrettyPrinted, and says that "If this option is not
set, the most compact possible JSON representation is generated."
I definitely want the most compact JSON representation.
My question is: what is the proper value to pass the
dataWithJSONObject:options:error: function if I don't want pretty printed,
and why?
The NSJSONWritingOptions enum is defined as
enum { NSJSONWritingPrettyPrinted = (1UL << 0) }; typedef NSUInteger
NSJSONWritingOptions;
I have read in a different post that 0 should be passed, but with no
further explanation as to why it shouldn't be nil.

Why content_for method undefined in rails view?

Why content_for method undefined in rails view?

I have a rails project.
In the application.html.slim I have:
doctype html
html
head
title RailsMongoidPj
= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track" => true
= javascript_include_tag "application", "data-turbolinks-track" => true
= csrf_meta_tags
meta content="width=device-width, initial-scale=1.0" name="viewport"
= yield(:html_head)
body
= yield
In a controller SearchController, which has a method:
def javascript(*files)
content_for(:html_head) do
javascript_include_tag(*files)
end
end
helper_method :javascript
Also this controller has a method new with a corresponding view, which
content is:
= javascript('/vendor/assets/javascript/handelbars.runtime.js')
- content_for :html_head do
script#entry-template type="text/x-handlebars-template"
| template content
But I have an error:
undefined method `content_for' for #<SearchFlickrController:0x007f8e4f2bae78>
Extracted source (around line #3):
1 / search flickr api page
2
3 = javascript('/vendor/assets/javascript/handelbars.runtime.js')
4
5 - content_for :html_head do
6 script#entry-template type="text/x-handlebars-template"
Why the method is content_for undefined? Isn't it an standard rails method?

When overriding the registration controller from devise, is it possible to access the newly created user on the create action?

When overriding the registration controller from devise, is it possible to
access the newly created user on the create action?

I'm trying to create a folder right after a user registers, so I override
the create action on the registration controller (devise) but I don't know
how to access the newly created user in order to create the folder with
it's name to upload files later.
So far I've got this:
class RegistrationsController < Devise::RegistrationsController
def new
super
end
def create
super
create_folder
end
def update
super
end
def create_folder
path = Pathname.new(':rails_root/tmp/')
directory_name = ":current_user"
Dir.mkdir(path, directory_name) unless File.exists?(directory_name)
end
end
routes.rb
devise_for :users, :controllers => {:registrations => "registrations"}
I followed this to override the registration controller.
Should I leave it there or move it to the create action? Instead of using
a method
is that the right way to access the current user?
Maybe instead of registration it's better to do it on sign in?
I'd appreciate any help I can get.

LINQ to SQL, not null, use default value

LINQ to SQL, not null, use default value

I'm using EF with DB First. My table looks like this:
CREATE TABLE [dbo].[Person](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) NOT NULL,
[dob] [datetime] NOT NULL
CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED )
GO
ALTER TABLE [dbo].[Person]
ADD CONSTRAINT [DF_Person_dob] DEFAULT ('12.12.3000') FOR [dob]
After using DB First I get the following partial Person class:
using System;
public partial class Person
{
public int id { get; set; }
public string name { get; set; }
public System.DateTime dob { get; set; }
}
The problem I have is that when I want to use the DB generated default
value for 'dob' field I get an exception because nulls are not allowed.
I'm trying to do this:
using (var db = new NullTestEntities())
{
var person = db.Person.Create();
person.name = "John Doe";
db.Person.Add(person);
db.SaveChanges();
}
I've tried adding
Column(IsDataBaseGenerated=true)
but I can't compile because I get an error:
'System.ComponentModel.DataAnnotations.Schema.ColumnAttribute' does not
contain a
definition for 'IsDatabaseGenerated'
What do I need to do in order to not define the dob attribute in C# code
and let the database generate the default value?

Tuesday, 1 October 2013

Menu images dropping down a little to low?

Menu images dropping down a little to low?

You can view the page in question here: http://portal.envisionlocal.com
Basically the image menu-sep.png which acts as a line break between the
different menus in my header is dropping down just a fraction below the
navigation bar and I can't figure out what to do to fix that. I'd prefer
to fix it inline instead of in a CSS file because the only solution to
fixing in the CSS file that I've found is editing line 52 of flex.css:
I changed
font: 13px/1.6em "Open Sans",Arial,sans-serif;
to
font: 11px/1.6em "Open Sans",Arial,sans-serif;
and it fixed the problem but also made all of the other text on the page
way too small - it didn't change the text size in the header but did fix
the problem for some reason...
Any help would be appreciated! Thanks!

Which is most cache friendly?

Which is most cache friendly?

I am trying to get a good grip on data oriented design and how to program
best with the cache in mind. There's basically two scenarios that I cannot
quite decide which is better and why - is it better to have a vector of
objects, or several vectors with the objects atomic data?
A) Vector of objects example
struct A
{
GLsizei mIndices;
GLuint mVBO;
GLuint mIndexBuffer;
GLuint mVAO;
size_t vertexDataSize;
size_t normalDataSize;
};
std::vector<A> gMeshes;
for_each(gMeshes as mesh)
{
glBindVertexArray(mesh.mVAO);
glDrawElements(GL_TRIANGLES, mesh.mIndices, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
....
}
B) Vectors with the atomic data
std::vector<GLsizei> gIndices;
std::vector<GLuint> gVBOs;
std::vector<GLuint> gIndexBuffers;
std::vector<GLuint> gVAOs;
std::vector<size_t> gVertexDataSizes;
std::vector<size_t> gNormalDataSizes;
size_t numMeshes = ...;
for (index = 0; index++; index < numMeshes)
{
glBindVertexArray(gVAOs[index]);
glDrawElements(GL_TRIANGLES, gIndices[index], GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
....
}
Which one is more memory efficient and cache friendly resulting in less
cache misses and better performance, and why?

SIEM DSCC - Upgrade Fails and then web console doesn't shows anything

SIEM DSCC - Upgrade Fails and then web console doesn't shows anything

Since trying to patch, we can not access the Web Interface, the Console
page is empty.
We also tried to upgrade trough CLI but it returns this error messages
Checking for undeployed changes...
Found undeployed changes!
[PATCH_UPDATER] [ERROR] The patch cannot continue because you have
undeployed changes in your system.
[PATCH_UPDATER] [ERROR] Please go to the Administration Console and deploy
changes before continuing with the patch.
An error was encountered attempting to process patches. Please contact
customer support for further assistance.
Check the Build Version of DSCC
[root@NOCMSIEM1 ~]# cat /opt/qradar/conf/build_version
7.1.0.414913
Before we start we did a backup of the configuration.
-rw-r--r-- 1 nobody nobody 57428857 Sep 19 12:51
backup.BackupUpgrade.NOCMSIEM1_3.19_09_2013.config.1379587862604.tgz
I don't have experience and have never worked with this console. But
looking through the internet I have seen similar errors in your forum and
I think you maybe could help me, I think the error is related to the
tomcat.
/opt/tomcat6/logs/catalina.2013-09-23.log
------------------
Sep 25, 2013 3:10:14 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Sep 25, 2013 3:10:14 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Sep 25, 2013 3:10:14 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=1/14 config=null
Sep 25, 2013 3:10:14 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6132 ms
Sep 25, 2013 3:10:14 PM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
Sep 25, 2013 3:10:15 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Sep 25, 2013 3:10:15 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
Sep 25, 2013 3:10:24 PM org.apache.catalina.realm.JAASRealm
setUseContextClassLoader
INFO: Setting useContextClassLoader = false
Sep 25, 2013 3:10:24 PM org.apache.tomcat.util.digester.SetPropertiesRule
begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Realm} Setting property
'debug' to '99' did not find a matching property.
Sep 25, 2013 3:10:24 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Sep 25, 2013 3:10:24 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 355 ms
Sep 25, 2013 3:10:24 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Sep 25, 2013 3:10:24 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
Sep 25, 2013 3:10:24 PM org.apache.catalina.startup.HostConfig
deployDirectory
INFO: Deploying web application directory console
Sep 25, 2013 3:10:29 PM
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
contextInitialized
INFO: WSSERVLET12: JAX-WS context listener initializing
Sep 25, 2013 3:10:30 PM
com.sun.xml.ws.transport.http.servlet.WSServletDelegate <init>
**INFO: WSSERVLET14: JAX-WS servlet initializing
Sep 25, 2013 3:10:30 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Sep 25, 2013 3:10:30 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/console] startup failed due to previous errors**
Sep 25, 2013 3:10:30 PM
com.sun.xml.ws.transport.http.servlet.WSServletDelegate destroy
INFO: WSSERVLET15: JAX-WS servlet destroyed
Sep 25, 2013 3:10:30 PM
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
contextDestroyed
INFO: WSSERVLET13: JAX-WS context listener destroyed
Sep 25, 2013 3:10:30 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Sep 25, 2013 3:10:30 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Sep 25, 2013 3:10:30 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/13 config=null
Sep 25, 2013 3:10:30 PM org.apache.catalina.startup.Catalina start
We have restored from the backup settings and reboot the appliance several
times and have not gotten to load the DSCC web interface.

Series $\sum=?iso-8859-1?Q?=5F{n_=3D_0}^{\infty}_?=(-1)^n \frac{5}{4^n}$ – math.stackexchange.com

Series $\sum_{n = 0}^{\infty} (-1)^n \frac{5}{4^n}$ – math.stackexchange.com

$$\sum_{n = 0}^{\infty} (-1)^n \frac{5}{4^n}$$ I tried writing out the
values for n = 0, 1, 2, 3, 4 so try to find partial sum equation but was
unsuccessful.