Skip to content

Instantly share code, notes, and snippets.

View malkitsingh's full-sized avatar
🎯
Focusing

Malkit Singh malkitsingh

🎯
Focusing
View GitHub Profile
@malkitsingh
malkitsingh / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@malkitsingh
malkitsingh / iOS
Created December 2, 2014 16:59
objective C defining useful constants
#define TimeZone [[NSTimeZone localTimeZone] name]
#define IS_IPHONE_6_PLUS ([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)] && [UIScreen mainScreen].nativeScale > 2.1)
#define IS_IPHONE_4 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)480) < DBL_EPSILON)
#define IS_IPHONE_5 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)568) < DBL_EPSILON)
#define IS_IPHONE_6 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)667) < DBL_EPSILON)
#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
#define IS_OS_5_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0)
#define IS_OS_6_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)
@malkitsingh
malkitsingh / apna taste test queies.sql
Last active August 29, 2015 14:10
apna taste testing queries
select * from orders
select * from orders ORDER BY id DESC
@malkitsingh
malkitsingh / allow cors.xml
Last active August 29, 2015 14:10
to allow cross site service call for web api
<system.webServer>
<httpProtocol>
<customHeaders>
<!-- Adding the following custom HttpHeader will help prevent CORS from stopping the Request-->
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
public String ConvertImageURLToBase64(String url)
{
StringBuilder _sb = new StringBuilder();
Byte[] _byte = this.GetImage(url);
_sb.Append(Convert.ToBase64String(_byte, 0, _byte.Length));
return _sb.ToString();
}
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
SELECT SUSER_NAME()
create schema dbo authorization appointmenthouseUser;
create schema my_schema_name authorization my_user;
alter user appointmenthouseUser with default_schema= dbo;
UPDATE dbo.timezone SET dbo.timezone.[Column 4] = REPLACE( dbo.timezone.[Column 4], RIGHT(dbo.timezone.[Column 4], 1), '' )
CREATE FUNCTION [dbo].[UNIX_TIMESTAMP] (
@ctimestamp datetime
)
RETURNS integer
AS
BEGIN
/* Function body */
declare @return integer
SELECT @return = DATEDIFF(SECOND,{d '1970-01-01'}, @ctimestamp)
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
catch (DbEntityValidationException ex)
{
foreach (var validationErrors in ex.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,