Use sharepoint credentials for sso with third party
I was drowning in the information available on sharepoint sso, so I'm
asking this question to see if I want is even possible...
At the company I work at we use office 365/sharepoint and some other
programs/websites hosted elsewhere. One of those websites is a homemade
website to manage worked hours, schedules and stuff like that; this is the
website I'm trying to use the sharepoint credentials on.
The website is build in PHP, uses a mysql database and has it's own login
with your email address as user name. The thing I'm trying to do here is
automatically sign people in on this website if they're logged in on
sharepoint based on their email address.
Some additional info:
Not using Windows Azure
The website doesn't run on a Windows server
Is it possible to do this?
Thursday, 3 October 2013
Wednesday, 2 October 2013
Making own java method for array length issue
Making own java method for array length issue
So I was asked in a quiz yesterday to make my own method for size of an
array of strings. I was told I couldnt use the .length shortcut. Here was
my attempt, is it right?
//doesn't receive array! because it's a datamember in the class already
public int sizeOfArray(){
int counter = 0;
while(arrayName != empty){
arrayName[counter];
counter ++;
}
return counter;
}
So I was asked in a quiz yesterday to make my own method for size of an
array of strings. I was told I couldnt use the .length shortcut. Here was
my attempt, is it right?
//doesn't receive array! because it's a datamember in the class already
public int sizeOfArray(){
int counter = 0;
while(arrayName != empty){
arrayName[counter];
counter ++;
}
return counter;
}
Add ProfileImage from users previously uploaded photos
Add ProfileImage from users previously uploaded photos
I have tried to do this but was unsuccessful. There's also no postings
covering this which is odd considering selecting Default photo is a option
for every social network. I have the CarrierWave gem and I want to set it
up so that the user can select their ProfileImage (default image) from
photos they have already uploaded. This photo would be used site wide.
It's like having an avatar, however the articles out there only show how
to upload a avatar as oppose to selecting a avatar from your uploaded
photos. I am sure this will be helpful to other people since this is a
common feature.
Photos controller:
def new
@photo = Photo.new
end
def create
@photo = Photo.new(params[:photo])
@photo.user = current_user
if @photo.save
flash[:notice] = "Successfully created photos."
redirect_to :back
else
render :action => 'new'
end
end
def edit
@photo = Photo.find(params[:id])
end
def update
@photo = Photo.find(params[:id])
if @photo.update_attributes(paramas[:photo])
flash[:notice] = "Successfully updated photo."
redirect_to @photo.gallery
else
render :action => 'edit'
end
end
def destroy
@photo = Photo.find(params[:id])
@photo.destroy
flash[:notice] = "Successfully destroyed photo."
redirect_to @photo.gallery
end
end
User model:
# It is setup so no gallery is created, and photos are associated with the
user.
private
def setup_gallery
Gallery.create(user: self)
end
Photo model:
attr_accessible :title, :body, :gallery_id, :name, :image,
:remote_image_url
belongs_to :gallery
has_many :gallery_users, :through => :gallery, :source => :user
belongs_to :user
mount_uploader :image, ImageUploader
LIMIT = 5
validate do |record|
record.validate_photo_quota
end
def validate_photo_quota
return unless self.user
if self.user.photos(:reload).count >= LIMIT
errors.add(:base, :exceeded_quota)
end
end
end
I have tried to do this but was unsuccessful. There's also no postings
covering this which is odd considering selecting Default photo is a option
for every social network. I have the CarrierWave gem and I want to set it
up so that the user can select their ProfileImage (default image) from
photos they have already uploaded. This photo would be used site wide.
It's like having an avatar, however the articles out there only show how
to upload a avatar as oppose to selecting a avatar from your uploaded
photos. I am sure this will be helpful to other people since this is a
common feature.
Photos controller:
def new
@photo = Photo.new
end
def create
@photo = Photo.new(params[:photo])
@photo.user = current_user
if @photo.save
flash[:notice] = "Successfully created photos."
redirect_to :back
else
render :action => 'new'
end
end
def edit
@photo = Photo.find(params[:id])
end
def update
@photo = Photo.find(params[:id])
if @photo.update_attributes(paramas[:photo])
flash[:notice] = "Successfully updated photo."
redirect_to @photo.gallery
else
render :action => 'edit'
end
end
def destroy
@photo = Photo.find(params[:id])
@photo.destroy
flash[:notice] = "Successfully destroyed photo."
redirect_to @photo.gallery
end
end
User model:
# It is setup so no gallery is created, and photos are associated with the
user.
private
def setup_gallery
Gallery.create(user: self)
end
Photo model:
attr_accessible :title, :body, :gallery_id, :name, :image,
:remote_image_url
belongs_to :gallery
has_many :gallery_users, :through => :gallery, :source => :user
belongs_to :user
mount_uploader :image, ImageUploader
LIMIT = 5
validate do |record|
record.validate_photo_quota
end
def validate_photo_quota
return unless self.user
if self.user.photos(:reload).count >= LIMIT
errors.add(:base, :exceeded_quota)
end
end
end
Notification of changes in files of a given type in a group of Github repositories
Notification of changes in files of a given type in a group of Github
repositories
I want to receive a notification (RSS, email, whatever) if anyone makes a
change on any .md file in a Github repository. I have many repositories to
watch. How can I do this?
repositories
I want to receive a notification (RSS, email, whatever) if anyone makes a
change on any .md file in a Github repository. I have many repositories to
watch. How can I do this?
Tuesday, 1 October 2013
java.lang.ClassNotFoundException: Class com.ibm.db2.jcc.DB2Driver not found in Worklight platform or project
java.lang.ClassNotFoundException: Class com.ibm.db2.jcc.DB2Driver not
found in Worklight platform or project
I try to test an sql adapter that connects to db2 but I get the following
result:
java.lang.ClassNotFoundException: Class com.ibm.db2.jcc.DB2Driver not
found in Worklight platform or project
here is my code:
<dataSourceDefinition>
<driverClass>com.ibm.db2.jcc.DB2Driver</driverClass>
<url>jdbc:db2://localhost:50000/WLTEST</url>
<user>db2admin</user>
<password>db2admin</password>
</dataSourceDefinition>
any idea what is going wrong?
found in Worklight platform or project
I try to test an sql adapter that connects to db2 but I get the following
result:
java.lang.ClassNotFoundException: Class com.ibm.db2.jcc.DB2Driver not
found in Worklight platform or project
here is my code:
<dataSourceDefinition>
<driverClass>com.ibm.db2.jcc.DB2Driver</driverClass>
<url>jdbc:db2://localhost:50000/WLTEST</url>
<user>db2admin</user>
<password>db2admin</password>
</dataSourceDefinition>
any idea what is going wrong?
django session lost when redirected from facebook oauth
django session lost when redirected from facebook oauth
I have a django app which is implementing Facebook oauth login.
Before an AnonymousUser, who has not yet been authenticated, is sent to
Facebook's oauth2, I store a token in the request.session.
Once the user log's in via facebook and is redirected back to our site,
the django session is lost. A new session key has been generated, the old
session key is removed from the db session store, and there is no data in
the session (so the original session token is missing). I can't figure out
why this is happening and need to get the original token?
I have the following in settings.py
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
SESSION_COOKIE_DOMAIN = '.mysite.com'
SESSION_COOKIE_SECURE = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
I have a django app which is implementing Facebook oauth login.
Before an AnonymousUser, who has not yet been authenticated, is sent to
Facebook's oauth2, I store a token in the request.session.
Once the user log's in via facebook and is redirected back to our site,
the django session is lost. A new session key has been generated, the old
session key is removed from the db session store, and there is no data in
the session (so the original session token is missing). I can't figure out
why this is happening and need to get the original token?
I have the following in settings.py
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
SESSION_COOKIE_DOMAIN = '.mysite.com'
SESSION_COOKIE_SECURE = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
No sound after exiting Rhythmbox party mode
No sound after exiting Rhythmbox party mode
After putting Rhythmbox into "party mode" I couldn't find a way to exit it
(a known bug), so I logged out and in again. After that my sound was gone.
Rebooting didn't fix the issue.
Note: Both my sound devices (laptop as well as my external speakers)
aren't working.
Edit: Reinstalling Rhythmbox and all its plugins didn't solve anything
After putting Rhythmbox into "party mode" I couldn't find a way to exit it
(a known bug), so I logged out and in again. After that my sound was gone.
Rebooting didn't fix the issue.
Note: Both my sound devices (laptop as well as my external speakers)
aren't working.
Edit: Reinstalling Rhythmbox and all its plugins didn't solve anything
Extracting a tar ball fails with "Cannot open: Not a directory"
Extracting a tar ball fails with "Cannot open: Not a directory"
I am trying to extract an tarball, I keep getting this error
tar: mediatek/custom/common/lk/lcm/bp101wx1_n/bp101wx1_n.c: Cannot open:
Not a directory
tar: mediatek/custom/common/lk/lcm/hsd070idw1/hsd070idw1.c: Cannot open:
Not a directory
tar: mediatek/custom/common/lk/lcm/nt35582/nt35582.c: Cannot open: Not a
directory
tar:
mediatek/custom/common/lk/lcm/r63311_fhd_dsi_vdo_sharp/r63311_fhd_dsi_vdo_sharp.c:
Cannot open: Not a directory
tar:
mediatek/custom/common/lk/lcm/otm9608_wvga_dsi_cmd/otm9608_wvga_dsi_cmd.c:
Cannot open: Not a directory
tar: mediatek/custom/common/lk/lcm/lg4571/lg4571.c: Cannot open: Not a
directory
tar:
mediatek/custom/common/lk/lcm/hx8363b_wvga_dsi_cmd/hx8363b_wvga_dsi_cmd.c:
Cannot open: Not a directory
tar:
mediatek/custom/common/lk/lcm/lg4573b_wvga_dsi_vdo_lh430mv1/lg4573b_wvga_dsi_vdo_lh430mv1.c:
Cannot open: Not a directory
tar: Exiting with failure status due to previous errors
The original file was a .zip file that contained a .tar.gz file, so I
first used unzip then I used pigz with the -d option to create the tar
file.
I extracted the tar file using tar with xf option.
The tar file is 3.8 GB if that matters
I am trying to extract an tarball, I keep getting this error
tar: mediatek/custom/common/lk/lcm/bp101wx1_n/bp101wx1_n.c: Cannot open:
Not a directory
tar: mediatek/custom/common/lk/lcm/hsd070idw1/hsd070idw1.c: Cannot open:
Not a directory
tar: mediatek/custom/common/lk/lcm/nt35582/nt35582.c: Cannot open: Not a
directory
tar:
mediatek/custom/common/lk/lcm/r63311_fhd_dsi_vdo_sharp/r63311_fhd_dsi_vdo_sharp.c:
Cannot open: Not a directory
tar:
mediatek/custom/common/lk/lcm/otm9608_wvga_dsi_cmd/otm9608_wvga_dsi_cmd.c:
Cannot open: Not a directory
tar: mediatek/custom/common/lk/lcm/lg4571/lg4571.c: Cannot open: Not a
directory
tar:
mediatek/custom/common/lk/lcm/hx8363b_wvga_dsi_cmd/hx8363b_wvga_dsi_cmd.c:
Cannot open: Not a directory
tar:
mediatek/custom/common/lk/lcm/lg4573b_wvga_dsi_vdo_lh430mv1/lg4573b_wvga_dsi_vdo_lh430mv1.c:
Cannot open: Not a directory
tar: Exiting with failure status due to previous errors
The original file was a .zip file that contained a .tar.gz file, so I
first used unzip then I used pigz with the -d option to create the tar
file.
I extracted the tar file using tar with xf option.
The tar file is 3.8 GB if that matters
Monday, 30 September 2013
Will my Cookie Clicker save last beyond a reboot=?iso-8859-1?Q?=3F_=96_gaming.stackexchange.com?=
Will my Cookie Clicker save last beyond a reboot? – gaming.stackexchange.com
I have been loathe to reboot my machine for risk my Cookie Clicker game
would lose all its hard-won progress. Am I being silly, here?
I have been loathe to reboot my machine for risk my Cookie Clicker game
would lose all its hard-won progress. Am I being silly, here?
Prove that $ P \cup Q = Q$ and $P \cap Q = P$ if $P$ is a subset of $Q$
Prove that $ P \cup Q = Q$ and $P \cap Q = P$ if $P$ is a subset of $Q$
pWhen $P$ is a subset of $Q$, use logical connectives to/p blockquote ol
lipProve $P \cup Q = Q$./p/li lipProve $P \cap Q = P$./p/li /ol
/blockquote pI know that they are true, but I don't know how to use the
definitions of union and intersection in terms of logical connectives to
prove them./p pThanks in advance!/p
pWhen $P$ is a subset of $Q$, use logical connectives to/p blockquote ol
lipProve $P \cup Q = Q$./p/li lipProve $P \cap Q = P$./p/li /ol
/blockquote pI know that they are true, but I don't know how to use the
definitions of union and intersection in terms of logical connectives to
prove them./p pThanks in advance!/p
Android and expandable results preview
Android and expandable results preview
what I want to do is realizing an awsome layout for my app. For this
reason I've thought to Display result of searches in a particular way: -
when I have less then or 4 results I display them in a simple listview; -
when I have more then 4 results I display the first four resoults and an
element that, when is clicked, expands my listview and shows all results.
I've seen ExpandableListView but it does not give me the possibility of
results preview. Any ideas?
what I want to do is realizing an awsome layout for my app. For this
reason I've thought to Display result of searches in a particular way: -
when I have less then or 4 results I display them in a simple listview; -
when I have more then 4 results I display the first four resoults and an
element that, when is clicked, expands my listview and shows all results.
I've seen ExpandableListView but it does not give me the possibility of
results preview. Any ideas?
VisualStateManager: how the page is aware of initial VisualState
VisualStateManager: how the page is aware of initial VisualState
I have one doubt regarding the working of VisualStateManager in Windows
Store apps...
Assume this sample page:
<common:LayoutAwarePage x:Name="pageRoot">
<Grid Style="{StaticResource LayoutRootStyle}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListView Grid.Column="0"
x:Name="testElement" />
<Grid Grid.Column="1" />
</Grid>
<common:LayoutAwarePage/>
I declare the next VisualStateManager behavior, with a sample VisualState:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ApplicationViewStates">
<VisualState x:Name="Snapped">
<Storyboard>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="testElement"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0"
Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
And now my questions:
How can the application determine that the "state" (I mean, the values of
the properties) is the one I used in the XAML declaration of the page?
Do I need to explicitly set the "initial" values of the page in - for
example - a FullScreenLandscapeOrWide VisualState?
Is it possible that the page will start (maybe with other screen
resolutions or particular devices) in a different VisualState "state" (not
FullScreenLandscapeOrWide), giving me problems if I do not declare the
FullScreenLandscapeOrWide VisualState (the initial status) ?
Thank you in advance for clarifications...
I have one doubt regarding the working of VisualStateManager in Windows
Store apps...
Assume this sample page:
<common:LayoutAwarePage x:Name="pageRoot">
<Grid Style="{StaticResource LayoutRootStyle}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ListView Grid.Column="0"
x:Name="testElement" />
<Grid Grid.Column="1" />
</Grid>
<common:LayoutAwarePage/>
I declare the next VisualStateManager behavior, with a sample VisualState:
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ApplicationViewStates">
<VisualState x:Name="Snapped">
<Storyboard>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="testElement"
Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0"
Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
And now my questions:
How can the application determine that the "state" (I mean, the values of
the properties) is the one I used in the XAML declaration of the page?
Do I need to explicitly set the "initial" values of the page in - for
example - a FullScreenLandscapeOrWide VisualState?
Is it possible that the page will start (maybe with other screen
resolutions or particular devices) in a different VisualState "state" (not
FullScreenLandscapeOrWide), giving me problems if I do not declare the
FullScreenLandscapeOrWide VisualState (the initial status) ?
Thank you in advance for clarifications...
Sunday, 29 September 2013
C++ return negative string
C++ return negative string
Hi i have the following code to convert string integer into integer, these
are the code:
#include <stdio.h>
int str_to_int(char* str) {
int output = 0;
char* p = str;
for (int i=0;str[i]!='\0';i++) {
char c = *p++;
if (c < '0' || c > '9')
continue;
output *= 10;
output += c - '0';
}
return output;
}
int main(){
printf("%d\n", str_to_int("456xy"));
printf("%d\n", str_to_int("32"));
printf("%d\n", str_to_int("-5"));
return 0;
}
But some how printf("%d\n", str_to_int("-5")); some how returning 5
instead -5, where am i wrong here? Thanks
Hi i have the following code to convert string integer into integer, these
are the code:
#include <stdio.h>
int str_to_int(char* str) {
int output = 0;
char* p = str;
for (int i=0;str[i]!='\0';i++) {
char c = *p++;
if (c < '0' || c > '9')
continue;
output *= 10;
output += c - '0';
}
return output;
}
int main(){
printf("%d\n", str_to_int("456xy"));
printf("%d\n", str_to_int("32"));
printf("%d\n", str_to_int("-5"));
return 0;
}
But some how printf("%d\n", str_to_int("-5")); some how returning 5
instead -5, where am i wrong here? Thanks
Umbraco 6.1.3 - Specified cast is not valid
Umbraco 6.1.3 - Specified cast is not valid
I am getting error that is "Specified cast is not valid." in umbraco 6.1.3
version. (Razor - MVC)
Page has macro that is rendering company list to the page. I am creating
company list data with ucomponents data grid component.
Also I added all error below. Why can i get this error? And how can i fix
this? I searched it but i didnt get any idea to fix.
Thanks
Server Error in '/' Application.
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 7:
Line 8: <div class="interior-page-content">
Line 9: @Umbraco.RenderMacro("All-FirmaListesi", new {anaSayfa="1055"})
Line 10: </div>
Source File:
c:\inetpub\vhosts\cbmeturkey.com\httpdocs\Views\KatilimListesi.cshtml
Line: 9
Stack Trace:
[InvalidCastException: Specified cast is not valid.]
System.Data.SqlClient.SqlBuffer.get_Byte() +52
System.Data.SqlClient.SqlDataReader.GetByte(Int32 i) +62
umbraco.DataLayer.RecordsReaderAdapter`1.GetByte(String fieldName) +168
umbraco.cms.businesslogic.macro.MacroProperty.setup() +215
umbraco.cms.businesslogic.macro.MacroProperty.GetProperties(Int32
MacroId) +189
umbraco.cms.businesslogic.macro.MacroModel..ctor(Macro m) +186
umbraco.macro..ctor(String alias) +117
Umbraco.Web.UmbracoHelper.RenderMacro(String alias, IDictionary`2
parameters) +59
Umbraco.Web.UmbracoHelper.RenderMacro(String alias, Object parameters) +47
ASP._Page_Views_KatilimListesi_cshtml.Execute() in
c:\inetpub\vhosts\cbmeturkey.com\httpdocs\Views\KatilimListesi.cshtml:9
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +199
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter
writer, Object instance) +257
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext,
TextWriter writer) +107
StackExchange.Profiling.MVCHelpers.WrappedView.Render(ViewContext
viewContext, TextWriter writer) +159
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
+291
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
+23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
filter, ResultExecutingContext preContext, Func`1 continuation) +245
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
+22
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
filter, ResultExecutingContext preContext, Func`1 continuation) +245
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
+22
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList`1 filters, ActionResult actionResult) +176
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName) +311
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +23
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult
_) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult
ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult
asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult
ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET
Version:4.0.30319.17929
I am getting error that is "Specified cast is not valid." in umbraco 6.1.3
version. (Razor - MVC)
Page has macro that is rendering company list to the page. I am creating
company list data with ucomponents data grid component.
Also I added all error below. Why can i get this error? And how can i fix
this? I searched it but i didnt get any idea to fix.
Thanks
Server Error in '/' Application.
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 7:
Line 8: <div class="interior-page-content">
Line 9: @Umbraco.RenderMacro("All-FirmaListesi", new {anaSayfa="1055"})
Line 10: </div>
Source File:
c:\inetpub\vhosts\cbmeturkey.com\httpdocs\Views\KatilimListesi.cshtml
Line: 9
Stack Trace:
[InvalidCastException: Specified cast is not valid.]
System.Data.SqlClient.SqlBuffer.get_Byte() +52
System.Data.SqlClient.SqlDataReader.GetByte(Int32 i) +62
umbraco.DataLayer.RecordsReaderAdapter`1.GetByte(String fieldName) +168
umbraco.cms.businesslogic.macro.MacroProperty.setup() +215
umbraco.cms.businesslogic.macro.MacroProperty.GetProperties(Int32
MacroId) +189
umbraco.cms.businesslogic.macro.MacroModel..ctor(Macro m) +186
umbraco.macro..ctor(String alias) +117
Umbraco.Web.UmbracoHelper.RenderMacro(String alias, IDictionary`2
parameters) +59
Umbraco.Web.UmbracoHelper.RenderMacro(String alias, Object parameters) +47
ASP._Page_Views_KatilimListesi_cshtml.Execute() in
c:\inetpub\vhosts\cbmeturkey.com\httpdocs\Views\KatilimListesi.cshtml:9
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +199
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter
writer, Object instance) +257
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext,
TextWriter writer) +107
StackExchange.Profiling.MVCHelpers.WrappedView.Render(ViewContext
viewContext, TextWriter writer) +159
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
+291
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
+23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
filter, ResultExecutingContext preContext, Func`1 continuation) +245
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
+22
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
filter, ResultExecutingContext preContext, Func`1 continuation) +245
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
+22
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList`1 filters, ActionResult actionResult) +176
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName) +311
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +23
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult
_) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult
ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult
asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult
ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET
Version:4.0.30319.17929
Making stored procedure after insert update other table trigger
Making stored procedure after insert update other table trigger
I've got these tables:
Reservations
Reseration_ID
User_ID
Total_Amount
Tourist_Reservation
Tourist_ID- foreign key
Reservation_ID - foreign key to Reservation
Extra_Charges table
Extra_Charge_ID
Amount
Description
Tourist_Extra_Charges
Tourist_ID - foreign key
Extra_Charge_ID - foreign key
But when a user makes a reservation at first – for example, the basic
packet costs 500 euro – it is inserted into the TotalAmount column in the
Reservation table.
But in the next form the user can select extra_charges which will (but
also he may not select any extra_charges) which are immediately inserted
in the Tourist_Extra_charges table.
The problem is that as the user has selected extra_charges I should update
the column TotalAMount.
So after insert in the tourist_extra_charges table I want to make a
trigger that will update the column TotalAmount in the Reservation table.
And this is what I came up with. Please advice me if I can optimize it and
as a whole if the procedure is good.
CREATE TRIGGER [dbo].[tralAmount] on [dbo].[TOURIST_EXTRA_CHARGES] After
Insert
AS
BEGIN
Declare @Res_ID int
Declare @Sum_toAdd money
select @Res_ID = Reservation_ID from inserted
Inner join TOURIST_RESERVATION on
inserted.Tourist_ID=TOURIST_RESERVATION.Tourist_ID
select @Sum_toAdd = Amout from inserted
Inner Join EXTRA_CHARGES on inserted.Extra_Charge_ID=
EXTRA_CHARGES.Extra_Charge_ID
Update RESERVATIONS
Set Reservation_TotalAmount = (Reservation_TotalAmount + @Sum_toAdd)
where Reservation_ID=@Res_ID
END
I've got these tables:
Reservations
Reseration_ID
User_ID
Total_Amount
Tourist_Reservation
Tourist_ID- foreign key
Reservation_ID - foreign key to Reservation
Extra_Charges table
Extra_Charge_ID
Amount
Description
Tourist_Extra_Charges
Tourist_ID - foreign key
Extra_Charge_ID - foreign key
But when a user makes a reservation at first – for example, the basic
packet costs 500 euro – it is inserted into the TotalAmount column in the
Reservation table.
But in the next form the user can select extra_charges which will (but
also he may not select any extra_charges) which are immediately inserted
in the Tourist_Extra_charges table.
The problem is that as the user has selected extra_charges I should update
the column TotalAMount.
So after insert in the tourist_extra_charges table I want to make a
trigger that will update the column TotalAmount in the Reservation table.
And this is what I came up with. Please advice me if I can optimize it and
as a whole if the procedure is good.
CREATE TRIGGER [dbo].[tralAmount] on [dbo].[TOURIST_EXTRA_CHARGES] After
Insert
AS
BEGIN
Declare @Res_ID int
Declare @Sum_toAdd money
select @Res_ID = Reservation_ID from inserted
Inner join TOURIST_RESERVATION on
inserted.Tourist_ID=TOURIST_RESERVATION.Tourist_ID
select @Sum_toAdd = Amout from inserted
Inner Join EXTRA_CHARGES on inserted.Extra_Charge_ID=
EXTRA_CHARGES.Extra_Charge_ID
Update RESERVATIONS
Set Reservation_TotalAmount = (Reservation_TotalAmount + @Sum_toAdd)
where Reservation_ID=@Res_ID
END
How do I pass a variable's value to html->link() $title?
How do I pass a variable's value to html->link() $title?
My code looks like this:
<li>
<?php echo $html-> link($post['Post']['title'],
array('action'=>'post', $post['Post']['id'])); ?>
</li>
I'm trying to get a link in the form of /cake/posts/view/<id>, where id is
1, 2, 3 etc.
The error Cake gives is
Error: Call to a member function link() on a non-object
Full code here: http://pastebin.com/hexVvkfk
My code looks like this:
<li>
<?php echo $html-> link($post['Post']['title'],
array('action'=>'post', $post['Post']['id'])); ?>
</li>
I'm trying to get a link in the form of /cake/posts/view/<id>, where id is
1, 2, 3 etc.
The error Cake gives is
Error: Call to a member function link() on a non-object
Full code here: http://pastebin.com/hexVvkfk
Saturday, 28 September 2013
Multithreading a password checker in C
Multithreading a password checker in C
pCurrently attempting to get this program to use multithreading using
codepthread_create/code, codepthread_join/code, codepthread_exit/code, and
codepthread_self/code. I then intend to use codecrypt_r/code in place of
codecrypt/code in my code./p pIt will only be able to go up to 8 threads,
but I don't even know how to get started with two. I just have one line
that declares codepthread_t t1,t2,t3,t4,t5,t6,t7,t8/code./p pThe plan with
these is to put them in to codepthread_create/code but besides
initializing these values, I don't know where to go from here./p pI know
that pthread_create's input would be something like codepthread_create(t1,
NULL, ... , ...)/code but I do not know how to go about making the 3rd
input or what the 4th input even is. I then have to make sure to split up
the range of letters that each thread is checking based on the number of
threads specified by a command line arg. I've designed this so far to work
on one thread only, planning on moving it to codecrypt_r/code with
multithreading.../p pReally confused as to how I could get to make this
work.. If possible./p pI know some sort of void function is the third
entry in to codepthread_create/code.. but does that function have to be
what my passwordChecker is? Or what?/p precode/* crack.exe */ /* g++ -o
crack crack.c -lcrypt -lpthread */ //#define _GNU_SOURCE #include
lt;crypt.hgt; #include lt;unistd.hgt; #include lt;stdio.hgt; #include
lt;stdlib.hgt; #include lt;errno.hgt; #include lt;pthread.hgt; #include
lt;string.hgt; #include lt;math.hgt; void *passwordLooper(int ks, char
target[9], char s[10]); void *threadFunction(void *threads); int main(int
argc, char *argv[]){ /* usage = crack threads keysize target */ int i = 0;
/* arg[0] = crack, arg[1] = #of threads arg[2] = size of password, arg[3]
= hashed password being cracked */ if (argc != 4) { fprintf(stderr, Too
few/many arguements give.\n); fprintf(stderr, Proper usage: ./crack
threads keysize target\n); exit(0); } int threads = *argv[1]-'0'; //
threads is now equal to the second command line argument number int
keysize = *argv[2]-'0'; // keysize is now equal to the third command line
argument number char target[9]; strcpy(target, argv[3]); char salt[10];
while ( i lt; 2 ){ //Takes first two characters of the hashed password and
assigns them to the salt variable salt[i] = target[i]; i++; }
printf(threads = %d\n, threads); /*used for testing */ printf(keysize =
%d\n, keysize); printf(target = %s\n, target); printf(salt = %s\n, salt);
if (threads lt; 1 || threads gt; 8){ fprintf(stderr, 0 lt; threads lt;=
8\n); exit(0); } /*Checks to be sure that threads and keysize are*/ if
(keysize lt; 1 || keysize gt; 8){ /*of the correct size */ fprintf(stderr,
0 lt; keysize lt;= 8\n); exit(0); } pthread_t t1,t2,t3,t4,t5,t6,t7,t8; if
( threads = 1 ){ pthread_create(amp;t1, NULL, *threadFunction, threads); }
char unSalted[30]; int j = 0; for (i = 2; target[i] != '\0'; i++){
/*generates variable from target that does not include salt*/ unSalted[j]
= target[i]; j++; } printf(unSalted = %s\n, unSalted); //unSalted is the
variable target without the first two characters (the salt) char
password[9] = {0}; passwordLooper(keysize, target, salt); }
/*_____________________________________________________________________________________________________________*/
/*_____________________________________________________________________________________________________________*/
void *passwordLooper(int ks, char target[9], char s[10]){ char password[9]
= {0}; struct crypt_data cd; cd.initialized = 0; int result; for (;;){ int
level = 0; while (level lt; ks amp;amp; strcmp( crypt(password, s), target
) != 0) { if (password[level] == 0){ password[level] = 'a'; break; } if
(password[level] gt;= 'a' amp;amp; password[level] lt; 'z'){
password[level]++; break; } if (password[level] == 'z'){ password[level] =
'a'; level++; } } char *cryptPW = crypt(password, s); result =
strcmp(cryptPW, target); if (result == 0){ //if result is zero, cryptPW
and target are the same printf(result = %d\n, result); printf (Password
found: %s\n, password); printf(Hashed version of password is %s\n,
cryptPW); break; } if (level gt;= ks){ //if level ends up bigger than the
keysize, break, no longer checking for passwords printf(Password not
found\n); break; } } return 0; } /code/pre
pCurrently attempting to get this program to use multithreading using
codepthread_create/code, codepthread_join/code, codepthread_exit/code, and
codepthread_self/code. I then intend to use codecrypt_r/code in place of
codecrypt/code in my code./p pIt will only be able to go up to 8 threads,
but I don't even know how to get started with two. I just have one line
that declares codepthread_t t1,t2,t3,t4,t5,t6,t7,t8/code./p pThe plan with
these is to put them in to codepthread_create/code but besides
initializing these values, I don't know where to go from here./p pI know
that pthread_create's input would be something like codepthread_create(t1,
NULL, ... , ...)/code but I do not know how to go about making the 3rd
input or what the 4th input even is. I then have to make sure to split up
the range of letters that each thread is checking based on the number of
threads specified by a command line arg. I've designed this so far to work
on one thread only, planning on moving it to codecrypt_r/code with
multithreading.../p pReally confused as to how I could get to make this
work.. If possible./p pI know some sort of void function is the third
entry in to codepthread_create/code.. but does that function have to be
what my passwordChecker is? Or what?/p precode/* crack.exe */ /* g++ -o
crack crack.c -lcrypt -lpthread */ //#define _GNU_SOURCE #include
lt;crypt.hgt; #include lt;unistd.hgt; #include lt;stdio.hgt; #include
lt;stdlib.hgt; #include lt;errno.hgt; #include lt;pthread.hgt; #include
lt;string.hgt; #include lt;math.hgt; void *passwordLooper(int ks, char
target[9], char s[10]); void *threadFunction(void *threads); int main(int
argc, char *argv[]){ /* usage = crack threads keysize target */ int i = 0;
/* arg[0] = crack, arg[1] = #of threads arg[2] = size of password, arg[3]
= hashed password being cracked */ if (argc != 4) { fprintf(stderr, Too
few/many arguements give.\n); fprintf(stderr, Proper usage: ./crack
threads keysize target\n); exit(0); } int threads = *argv[1]-'0'; //
threads is now equal to the second command line argument number int
keysize = *argv[2]-'0'; // keysize is now equal to the third command line
argument number char target[9]; strcpy(target, argv[3]); char salt[10];
while ( i lt; 2 ){ //Takes first two characters of the hashed password and
assigns them to the salt variable salt[i] = target[i]; i++; }
printf(threads = %d\n, threads); /*used for testing */ printf(keysize =
%d\n, keysize); printf(target = %s\n, target); printf(salt = %s\n, salt);
if (threads lt; 1 || threads gt; 8){ fprintf(stderr, 0 lt; threads lt;=
8\n); exit(0); } /*Checks to be sure that threads and keysize are*/ if
(keysize lt; 1 || keysize gt; 8){ /*of the correct size */ fprintf(stderr,
0 lt; keysize lt;= 8\n); exit(0); } pthread_t t1,t2,t3,t4,t5,t6,t7,t8; if
( threads = 1 ){ pthread_create(amp;t1, NULL, *threadFunction, threads); }
char unSalted[30]; int j = 0; for (i = 2; target[i] != '\0'; i++){
/*generates variable from target that does not include salt*/ unSalted[j]
= target[i]; j++; } printf(unSalted = %s\n, unSalted); //unSalted is the
variable target without the first two characters (the salt) char
password[9] = {0}; passwordLooper(keysize, target, salt); }
/*_____________________________________________________________________________________________________________*/
/*_____________________________________________________________________________________________________________*/
void *passwordLooper(int ks, char target[9], char s[10]){ char password[9]
= {0}; struct crypt_data cd; cd.initialized = 0; int result; for (;;){ int
level = 0; while (level lt; ks amp;amp; strcmp( crypt(password, s), target
) != 0) { if (password[level] == 0){ password[level] = 'a'; break; } if
(password[level] gt;= 'a' amp;amp; password[level] lt; 'z'){
password[level]++; break; } if (password[level] == 'z'){ password[level] =
'a'; level++; } } char *cryptPW = crypt(password, s); result =
strcmp(cryptPW, target); if (result == 0){ //if result is zero, cryptPW
and target are the same printf(result = %d\n, result); printf (Password
found: %s\n, password); printf(Hashed version of password is %s\n,
cryptPW); break; } if (level gt;= ks){ //if level ends up bigger than the
keysize, break, no longer checking for passwords printf(Password not
found\n); break; } } return 0; } /code/pre
What is the PHP equivalent of MySQL's UNHEX()?
What is the PHP equivalent of MySQL's UNHEX()?
What is the PHP equivalent of MySQL's UNHEX()?
For instance, the following query and PHP function should provide the same
value.
SELECT UNHEX(c1) AS unhexed_c1 FROM table;
$unhexed_c1=PHPs_UNHEX_Equivalent($c1);
What is the PHP equivalent of MySQL's UNHEX()?
For instance, the following query and PHP function should provide the same
value.
SELECT UNHEX(c1) AS unhexed_c1 FROM table;
$unhexed_c1=PHPs_UNHEX_Equivalent($c1);
AngularJS - Help creating a YouTube frameapi directive
AngularJS - Help creating a YouTube frameapi directive
I am trying to build a yotube directive with the Youtube Player FrameAPI
example code
Here is the code
HTML
<div you-tube id="player"></div>
Directive
angular.module('mainApp.player').directive('youTube',
function(/*slides_ui*/) {
return {
restrict: 'A', // only activate on element attribute
scope: true, // New scope to use but rest inherit from parent
controller: function($scope, $element, $attrs) {
}, //open for now
link: function(scope, elm, attrs, ctrl) {
// Load the js api
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
}
});
Now the problem I am facing is where to put the rest of the frameapi js.
FrameAPI js
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
If I leave the above code in the HTML it works.
If I move it in the Controller/link function of the directive it doesn't
work.
What am I missing?
I am trying to build a yotube directive with the Youtube Player FrameAPI
example code
Here is the code
HTML
<div you-tube id="player"></div>
Directive
angular.module('mainApp.player').directive('youTube',
function(/*slides_ui*/) {
return {
restrict: 'A', // only activate on element attribute
scope: true, // New scope to use but rest inherit from parent
controller: function($scope, $element, $attrs) {
}, //open for now
link: function(scope, elm, attrs, ctrl) {
// Load the js api
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
}
});
Now the problem I am facing is where to put the rest of the frameapi js.
FrameAPI js
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
If I leave the above code in the HTML it works.
If I move it in the Controller/link function of the directive it doesn't
work.
What am I missing?
Dynamic ContextMenuStrip
Dynamic ContextMenuStrip
In my application I have 3 RichTextboxes, I created only one
ContextMenuStrip because I don't like the idea of duplicate the same code
of the same contextmenu and all the context menu options 3 times to use it
with the other 2 Richs, the problem is I don't know how to use the same
ContextMenu for the three RichTextBoxes.
For example one option of the ContextMenuStrip is "Clear text", then
inside the procedure I need to specify the RichTextbox object name to
clear the text:
Private Sub MenuItem_Clear_Text_Click(sender As Object, e As EventArgs) _
Handles MenuItem_Clear_Text.Click
RichTextBox_Affix.Clear()
End Sub
How I can handle in a dynamic way the clear method in that sub for the
other richtextboxes?
I've tried to find the necessary information about which RichTextBox
called the contextmenu to handle the contextmenu procedure only for that
RichTextBox, but I've found anything in the sender or "e" variables.
In my application I have 3 RichTextboxes, I created only one
ContextMenuStrip because I don't like the idea of duplicate the same code
of the same contextmenu and all the context menu options 3 times to use it
with the other 2 Richs, the problem is I don't know how to use the same
ContextMenu for the three RichTextBoxes.
For example one option of the ContextMenuStrip is "Clear text", then
inside the procedure I need to specify the RichTextbox object name to
clear the text:
Private Sub MenuItem_Clear_Text_Click(sender As Object, e As EventArgs) _
Handles MenuItem_Clear_Text.Click
RichTextBox_Affix.Clear()
End Sub
How I can handle in a dynamic way the clear method in that sub for the
other richtextboxes?
I've tried to find the necessary information about which RichTextBox
called the contextmenu to handle the contextmenu procedure only for that
RichTextBox, but I've found anything in the sender or "e" variables.
Subscribe to:
Posts (Atom)