Skip to content

Instantly share code, notes, and snippets.

View aliprogrammer69's full-sized avatar
🎯
Focusing

Ali aliprogrammer69

🎯
Focusing
View GitHub Profile
@aliprogrammer69
aliprogrammer69 / kadane
Last active August 6, 2022 10:08
best practice for the kadane's algorithm
public static (int, int) Calculate(int[] array) {
if (array.Length == 0)
return (0, 0);
int firstIndex = 0, lastIndex = 0, candidateFirstIndex = 0;
int currectSum = 0;
int globalSum = array[0];
for (int i = 0; i < array.Length; i++) {
currectSum += array[i];
if (array[i] >= currectSum) {
#This is just a base image that contains curl. you can use other images.
FROM mcr.microsoft.com/dotnet/runtime:3.1-buster-slim AS base
RUN curl --silent --location https://deb.nodesource.com/setup_10.x >> setup
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS final
COPY --from=base setup setup
RUN bash setup
RUN apt-get install --yes nodejs
@aliprogrammer69
aliprogrammer69 / WebApiEncoding
Created November 21, 2018 12:02
Change WebApi 2 Supported Encoding to encode new emojies
httpConfiguration.Formatters.JsonFormatter.SupportedEncodings.Clear();
httpConfiguration.Formatters.JsonFormatter.SupportedEncodings.Add(System.Text.Encoding.Unicode);//utf-16le
@aliprogrammer69
aliprogrammer69 / Sp_tabledeps.sql
Last active November 13, 2018 12:23
Getting All Db's Stored Procedures With Tabel Dependencies on them in microsoft sql server
SELECT OBJECT_SCHEMA_NAME(sd.object_id) + '.' + OBJECT_NAME(sd.object_id) sp_name
, OBJECT_SCHEMA_NAME(sd.referenced_major_id) + '.' + OBJECT_NAME(sd.referenced_major_id) table_name
FROM sys.sql_dependencies sd WITH (NOLOCK)
WHERE OBJECTPROPERTY(sd.object_id,'IsUserTable') = 0
AND OBJECTPROPERTY(sd.referenced_major_id,'IsUserTable') = 1

##Generate and Install IPA's file in device through Command Line

###Thanks to Mattt and phonegap's scripts

Take a note: all this steps can be automatized in a single script, if you know how to write it. (Bash or Ruby will be fine)

1.- Install your Provisioning Profile and Developer Certificate

2.- Install Shenzhen and ios-deploy: the firstone will generate the IPA file and the secondone will install it onto your device

@aliprogrammer69
aliprogrammer69 / Concat.sql
Created October 25, 2016 12:52
How to concat one cloumn of N Rows To One Column in sql server
SELECT STUFF((SELECT ',' + Username
FROM UserMgmt.[User]
FOR XML PATH('p'), TYPE).value('.', 'NVARCHAR(MAX)'),1,1,'')
@aliprogrammer69
aliprogrammer69 / SelectXmlAsData.sql
Created August 7, 2016 12:15
Select Xml As DataSet in sql server
DECLARE @xml XML='<root>
<row>
<CoreId>1</CoreId>
<Name>SrcName</Name>
<DataType>NVARCHAR(@LEN)</DataType>
<MaxLength>100</MaxLength>
<DefaultValue />
<IsNullable>0</IsNullable>
<Status>63</Status>
</row>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
public class FtpClient