elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


  Mostrar Mensajes
Páginas: 1 ... 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 [512] 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 ... 1236
5111  Media / Multimedia / Re: BAJARSE VIDEO O MUSICA CON SOLO LA URL en: 19 Junio 2015, 12:54 pm
Puedes utilizar el gestor de descargas JDownloader, soporta videos normales y protegidos de Youtube (cómo los de Vevo, de música).

Imagino que otros gestores que le hacen la competencia a JD también tendrán soporte para Youtube, cómo IDM (Internet Download Manager).

Saludos
5112  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets para VB.Net !! (Compartan aquí sus snippets) en: 19 Junio 2015, 12:34 pm
Un pequeño código para crear nuevas cuentas de usuario en el equipo.

Ejemplo de uso:
Código
  1.        CreateUserAccount(username:="Elektro",
  2.                          password:="",
  3.                          displayName:="Elektro account.",
  4.                          description:="This is a test user-account.",
  5.                          canChangePwd:=True,
  6.                          pwdExpires:=False,
  7.                          groupSid:=WellKnownSidType.BuiltinAdministratorsSid)

Código fuente:
Código
  1.    ''' ----------------------------------------------------------------------------------------------------
  2.    ''' <remarks>
  3.    ''' Title : Create user-account.
  4.    ''' Author: Elektro
  5.    ''' Date  : 19-June-2015
  6.    ''' </remarks>
  7.    ''' ----------------------------------------------------------------------------------------------------
  8.    ''' <example>
  9.    ''' CreateUserAccount(username:="Elektro",
  10.    '''                   password:="",
  11.    '''                   displayName:="Elektro Account.",
  12.    '''                   description:="This is a test user-account.",
  13.    '''                   canChangePwd:=True,
  14.    '''                   pwdExpires:=False,
  15.    '''                   groupSid:=WellKnownSidType.BuiltinAdministratorsSid)
  16.    ''' </example>
  17.    ''' ----------------------------------------------------------------------------------------------------
  18.    ''' <summary>
  19.    ''' Creates a new user account in the current machine.
  20.    ''' This function does not adds the user to the machine.
  21.    ''' </summary>
  22.    ''' ----------------------------------------------------------------------------------------------------
  23.    ''' <param name="username">
  24.    ''' The user name.
  25.    ''' </param>
  26.    '''
  27.    ''' <param name="password">
  28.    ''' The user password.
  29.    ''' If this value is empty, account is set to don't require a password.
  30.    ''' </param>
  31.    '''
  32.    ''' <param name="displayName">
  33.    ''' The display name of the user account.
  34.    ''' </param>
  35.    '''
  36.    ''' <param name="description">
  37.    ''' The description of the user account.
  38.    ''' </param>
  39.    '''
  40.    ''' <param name="canChangePwd">
  41.    ''' A value that indicates whether the user can change its password.
  42.    ''' </param>
  43.    '''
  44.    ''' <param name="pwdExpires">
  45.    ''' A value that indicates whether the password should expire.
  46.    ''' </param>
  47.    ''' ----------------------------------------------------------------------------------------------------
  48.    ''' <returns>
  49.    ''' An <see cref="UserPrincipal"/> object that contains the user data.
  50.    ''' </returns>
  51.    ''' ----------------------------------------------------------------------------------------------------
  52.    <DebuggerStepThrough>
  53.    Public Shared Function CreateUserAccount(ByVal username As String,
  54.                                             ByVal password As String,
  55.                                             ByVal displayName As String,
  56.                                             ByVal description As String,
  57.                                             ByVal canChangePwd As Boolean,
  58.                                             ByVal pwdExpires As Boolean) As UserPrincipal
  59.  
  60.        Using context As New PrincipalContext(ContextType.Machine)
  61.  
  62.            Dim user As New UserPrincipal(context)
  63.  
  64.            With user
  65.  
  66.                .Name = username
  67.  
  68.                .SetPassword(password)
  69.                .PasswordNotRequired = String.IsNullOrEmpty(password)
  70.  
  71.                .DisplayName = displayName
  72.                .Description = description
  73.  
  74.                .UserCannotChangePassword = canChangePwd
  75.                .PasswordNeverExpires = pwdExpires
  76.  
  77.                .Enabled = True
  78.                .Save()
  79.  
  80.            End With
  81.  
  82.            Return user
  83.  
  84.        End Using
  85.  
  86.    End Function
  87.  
  88.    ''' ----------------------------------------------------------------------------------------------------
  89.    ''' <remarks>
  90.    ''' Title : Add user-account.
  91.    ''' Author: Elektro
  92.    ''' Date  : 19-June-2015
  93.    ''' </remarks>
  94.    ''' ----------------------------------------------------------------------------------------------------
  95.    ''' <example>
  96.    ''' AddUserAccount(username:="Elektro",
  97.    '''                password:="",
  98.    '''                displayName:="Elektro Account.",
  99.    '''                description:="This is a test user-account.",
  100.    '''                canChangePwd:=True,
  101.    '''                pwdExpires:=False,
  102.    '''                groupSid:=WellKnownSidType.BuiltinAdministratorsSid)
  103.    ''' </example>
  104.    ''' ----------------------------------------------------------------------------------------------------
  105.    ''' <summary>
  106.    ''' Adds a new user account in the current machine.
  107.    ''' </summary>
  108.    ''' ----------------------------------------------------------------------------------------------------
  109.    ''' <param name="username">
  110.    ''' The user name.
  111.    ''' </param>
  112.    '''
  113.    ''' <param name="password">
  114.    ''' The user password.
  115.    ''' If this value is empty, account is set to don't require a password.
  116.    ''' </param>
  117.    '''
  118.    ''' <param name="displayName">
  119.    ''' The display name of the user account.
  120.    ''' </param>
  121.    '''
  122.    ''' <param name="description">
  123.    ''' The description of the user account.
  124.    ''' </param>
  125.    '''
  126.    ''' <param name="canChangePwd">
  127.    ''' A value that indicates whether the user can change its password.
  128.    ''' </param>
  129.    '''
  130.    ''' <param name="pwdExpires">
  131.    ''' A value that indicates whether the password should expire.
  132.    ''' </param>
  133.    '''
  134.    ''' <param name="groupSid">
  135.    ''' A <see cref="WellKnownSidType"/> security identifier (SID) that determines the account group where to add the user.
  136.    ''' </param>
  137.    ''' ----------------------------------------------------------------------------------------------------
  138.    <DebuggerStepThrough>
  139.    Public Shared Sub AddUserAccount(ByVal username As String,
  140.                                     ByVal password As String,
  141.                                     ByVal displayName As String,
  142.                                     ByVal description As String,
  143.                                     ByVal canChangePwd As Boolean,
  144.                                     ByVal pwdExpires As Boolean,
  145.                                     Optional ByVal groupSid As WellKnownSidType = WellKnownSidType.BuiltinUsersSid)
  146.  
  147.        Using context As New PrincipalContext(ContextType.Machine)
  148.  
  149.            Using user As UserPrincipal = CreateUserAccount(username, password, displayName, description, canChangePwd, pwdExpires)
  150.  
  151.                Using group As GroupPrincipal = GroupPrincipal.FindByIdentity(context, IdentityType.Sid, New SecurityIdentifier(groupSid, Nothing).Value)
  152.  
  153.                    group.Members.Add(user)
  154.                    group.Save()
  155.  
  156.                End Using ' group
  157.  
  158.            End Using ' user
  159.  
  160.        End Using ' context
  161.  
  162.    End Sub
  163.  
  164.    ''' ----------------------------------------------------------------------------------------------------
  165.    ''' <remarks>
  166.    ''' Title : Add user-account.
  167.    ''' Author: Elektro
  168.    ''' Date  : 19-June-2015
  169.    ''' </remarks>
  170.    ''' ----------------------------------------------------------------------------------------------------
  171.    ''' <example>
  172.    ''' AddUserAccount(user:=myUserPrincipal, groupSid:=WellKnownSidType.BuiltinAdministratorsSid)
  173.    ''' </example>
  174.    ''' ----------------------------------------------------------------------------------------------------
  175.    ''' <summary>
  176.    ''' Adds a new user account in the current machine.
  177.    ''' </summary>
  178.    ''' ----------------------------------------------------------------------------------------------------
  179.    ''' <param name="user">
  180.    ''' An <see cref="UserPrincipal"/> object that contains the user data.
  181.    ''' </param>
  182.    '''
  183.    ''' <param name="groupSid">
  184.    ''' A <see cref="WellKnownSidType"/> security identifier (SID) that determines the account group where to add the user.
  185.    ''' </param>
  186.    ''' ----------------------------------------------------------------------------------------------------
  187.    <DebuggerStepThrough>
  188.    Public Shared Sub AddUserAccount(ByVal user As UserPrincipal,
  189.                                     Optional ByVal groupSid As WellKnownSidType = WellKnownSidType.BuiltinUsersSid)
  190.  
  191.        Using context As New PrincipalContext(ContextType.Machine)
  192.  
  193.            Using group As GroupPrincipal = GroupPrincipal.FindByIdentity(context, IdentityType.Sid, New SecurityIdentifier(groupSid, Nothing).Value)
  194.  
  195.                group.Members.Add(user)
  196.                group.Save()
  197.  
  198.            End Using ' group
  199.  
  200.        End Using ' context
  201.  
  202.    End Sub
5113  Foros Generales / Foro Libre / Re: La repugnante «rata-pollo» de KFC que causa estragos en Facebook en: 19 Junio 2015, 11:58 am
...

5114  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets para VB.Net !! (Compartan aquí sus snippets) en: 19 Junio 2015, 10:22 am
Una Class para manipular archivos de texto.

Diagrama de clase:


Ejemplo de uso:
Código
  1.        Using txtFile As New TextfileStream("C:\File.txt", Encoding.Default)
  2.  
  3.            txtFile.Lock()
  4.  
  5.            txtFile.Lines.Add("Test")
  6.            txtFile.Lines(0) = "Hello World!"
  7.            txtFile.Save()
  8.  
  9.            Dim lineIndex As Integer
  10.            Dim lineCount As Integer = txtFile.Lines.Count
  11.            Dim textFormat As String =
  12.                Environment.NewLine &
  13.                String.Join(ControlChars.NewLine,
  14.                            From line As String In txtFile.Lines
  15.                            Select String.Format("{0}: {1}",
  16.                            Interlocked.Increment(lineIndex).ToString(New String("0"c, lineCount.ToString.Length)), line))
  17.  
  18.            Console.WriteLine(String.Format("FilePath: {0}", txtFile.Filepath))
  19.            Console.WriteLine(String.Format("Encoding: {0}", txtFile.Encoding.WebName))
  20.            Console.WriteLine(String.Format("Lines   : {0}", textFormat))
  21.  
  22.        End Using
  23.  

Código fuente:
Código
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Modified : 18-June-2015
  4. ' ***********************************************************************
  5. ' <copyright file="TextfileStream.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Usage Examples "
  11.  
  12. 'Using txtFile As New TextfileStream("C:\File.txt")
  13. '
  14. '    txtFile.Lock()
  15. '
  16. '    txtFile.Lines.Add("Test")
  17. '    txtFile.Lines(0) = "Hello World!"
  18. '    txtFile.Save()
  19. '
  20. '    Dim lineIndex As Integer
  21. '    Dim lineCount As Integer = txtFile.Lines.Count
  22. '    Dim textFormat As String =
  23. '        Environment.NewLine &
  24. '        String.Join(ControlChars.NewLine,
  25. '                    From line As String In txtFile.Lines
  26. '                    Select String.Format("{0}: {1}",
  27. '                    Interlocked.Increment(lineIndex).ToString(New String("0"c, lineCount.ToString.Length)), line))
  28. '
  29. '    Console.WriteLine(String.Format("FilePath: {0}", txtFile.Filepath))
  30. '    Console.WriteLine(String.Format("Encoding: {0}", txtFile.Encoding.WebName))
  31. '    Console.WriteLine(String.Format("Lines   : {0}", textFormat))
  32. '
  33. 'End Using
  34.  
  35. #End Region
  36.  
  37. #Region " Option Statements "
  38.  
  39. Option Strict On
  40. Option Explicit On
  41. Option Infer Off
  42.  
  43. #End Region
  44.  
  45. #Region " Imports "
  46.  
  47. Imports Microsoft.Win32.SafeHandles
  48. Imports System
  49. Imports System.Collections.Generic
  50. Imports System.ComponentModel
  51. Imports System.IO
  52. Imports System.Linq
  53. Imports System.Text
  54.  
  55. #End Region
  56.  
  57. #Region " Textfile "
  58.  
  59. ''' <summary>
  60. ''' Reads and manages the contents of a textfile.
  61. ''' It encapsulates a <see cref="System.IO.FileStream"/> to access the textfile.
  62. ''' </summary>
  63. Public NotInheritable Class TextfileStream : Implements IDisposable
  64.  
  65. #Region " Properties "
  66.  
  67.    ''' ----------------------------------------------------------------------------------------------------
  68.    ''' <summary>
  69.    ''' Gets the textfile path.
  70.    ''' </summary>
  71.    ''' ----------------------------------------------------------------------------------------------------
  72.    ''' <value>
  73.    ''' The textfile path.
  74.    ''' </value>
  75.    ''' ----------------------------------------------------------------------------------------------------
  76.    Public ReadOnly Property Filepath As String
  77.        Get
  78.            Return Me.filepathB
  79.        End Get
  80.    End Property
  81.    ''' <summary>
  82.    ''' (Backing field)
  83.    ''' The textfile path.
  84.    ''' </summary>
  85.    Private ReadOnly filepathB As String
  86.  
  87.    ''' ----------------------------------------------------------------------------------------------------
  88.    ''' <summary>
  89.    ''' Gets the textfile <see cref="Encoding"/>.
  90.    ''' </summary>
  91.    ''' ----------------------------------------------------------------------------------------------------
  92.    ''' <value>
  93.    ''' The textfile <see cref="Encoding"/>.
  94.    ''' </value>
  95.    ''' ----------------------------------------------------------------------------------------------------
  96.    Public ReadOnly Property Encoding As Encoding
  97.        Get
  98.            Return Me.encodingB
  99.        End Get
  100.    End Property
  101.    ''' <summary>
  102.    ''' (Backing field)
  103.    ''' The textfile <see cref="Encoding"/>.
  104.    ''' </summary>
  105.    Private ReadOnly encodingB As Encoding = Encoding.Default
  106.  
  107.    ''' ----------------------------------------------------------------------------------------------------
  108.    ''' <summary>
  109.    ''' Gets or sets the textfile lines.
  110.    ''' </summary>
  111.    ''' ----------------------------------------------------------------------------------------------------
  112.    ''' <value>
  113.    ''' The textfile lines.
  114.    ''' </value>
  115.    ''' ----------------------------------------------------------------------------------------------------
  116.    Public Property Lines As TexfileLines
  117.        Get
  118.            Return Me.linesB
  119.        End Get
  120.        Set(ByVal value As TexfileLines)
  121.            Me.linesB = value
  122.        End Set
  123.    End Property
  124.    ''' <summary>
  125.    ''' (Backing field)
  126.    ''' The textfile lines.
  127.    ''' </summary>
  128.    Private linesB As TexfileLines
  129.  
  130.    ''' ----------------------------------------------------------------------------------------------------
  131.    ''' <summary>
  132.    ''' Gets the <see cref="System.IO.FileStream"/> instance that exposes a <see cref="System.IO.Stream"/> around the textfile.
  133.    ''' </summary>
  134.    ''' ----------------------------------------------------------------------------------------------------
  135.    ''' <value>
  136.    ''' The <see cref="System.IO.FileStream"/> instance.
  137.    ''' </value>
  138.    ''' ----------------------------------------------------------------------------------------------------
  139.    Private ReadOnly Property fs As FileStream
  140.        Get
  141.            Return Me.fsB
  142.        End Get
  143.    End Property
  144.    ''' <summary>
  145.    ''' (Backing Field)
  146.    ''' The <see cref="System.IO.FileStream"/> instance that exposes a <see cref="System.IO.Stream"/> around the textfile.
  147.    ''' </summary>
  148.    Private ReadOnly fsB As FileStream
  149.  
  150.    ''' ----------------------------------------------------------------------------------------------------
  151.    ''' <summary>
  152.    ''' Gets a <see cref="Microsoft.Win32.SafeHandles.SafeFileHandle"/> object that represents the operating system file handle of the textfile.
  153.    ''' </summary>
  154.    ''' ----------------------------------------------------------------------------------------------------
  155.    ''' <value>
  156.    ''' A <see cref="Microsoft.Win32.SafeHandles.SafeFileHandle"/> object that represents the operating system file handle of the textfile.
  157.    ''' </value>
  158.    ''' ----------------------------------------------------------------------------------------------------
  159.    Public ReadOnly Property FileHandle As SafeFileHandle
  160.        Get
  161.            Return Me.fs.SafeFileHandle
  162.        End Get
  163.    End Property
  164.    ''' <summary>
  165.    ''' (Backing Field)
  166.    ''' A <see cref="Microsoft.Win32.SafeHandles.SafeFileHandle"/> object that represents the operating system file handle of the textfile.
  167.    ''' </summary>
  168.    Private ReadOnly fileHandleB As SafeFileHandle
  169.  
  170. #End Region
  171.  
  172. #Region " Sub-Classes "
  173.  
  174.    ''' <summary>
  175.    ''' Defines a <see cref="System.Collections.Generic.List(Of String)"/> that contains the text-lines of a textfile.
  176.    ''' </summary>
  177.    Partial Public NotInheritable Class TexfileLines : Inherits List(Of String)
  178.  
  179. #Region " Properties "
  180.  
  181.        ''' ----------------------------------------------------------------------------------------------------
  182.        ''' <summary>
  183.        ''' Gets the number of blank elements actually contained in the <see cref="System.Collections.Generic.List(Of T)"/>.
  184.        ''' </summary>
  185.        ''' ----------------------------------------------------------------------------------------------------
  186.        ''' <value>
  187.        ''' The number of blank elements actually contained in the <see cref="System.Collections.Generic.List(Of T)"/>.
  188.        ''' </value>
  189.        ''' ----------------------------------------------------------------------------------------------------
  190.        Public ReadOnly Property CountBlank As Integer
  191.            Get
  192.                Return (From line As String In Me
  193.                        Where String.IsNullOrEmpty(line) OrElse
  194.                              String.IsNullOrWhiteSpace(line)).Count
  195.            End Get
  196.        End Property
  197.  
  198.        ''' ----------------------------------------------------------------------------------------------------
  199.        ''' <summary>
  200.        ''' Gets the number of non-blank elements actually contained in the <see cref="System.Collections.Generic.List(Of T)"/>.
  201.        ''' </summary>
  202.        ''' ----------------------------------------------------------------------------------------------------
  203.        ''' <value>
  204.        ''' The number of non-blank elements actually contained in the <see cref="System.Collections.Generic.List(Of T)"/>.
  205.        ''' </value>
  206.        ''' ----------------------------------------------------------------------------------------------------
  207.        Public ReadOnly Property CountNonBlank As Integer
  208.            Get
  209.                Return (From line As String In Me
  210.                        Where Not String.IsNullOrEmpty(line) AndAlso
  211.                              Not String.IsNullOrWhiteSpace(line)).Count
  212.            End Get
  213.        End Property
  214.  
  215. #End Region
  216.  
  217. #Region " Constructors "
  218.  
  219.        ''' ----------------------------------------------------------------------------------------------------
  220.        ''' <summary>
  221.        ''' Initializes a new instance of the <see cref="TexfileLines"/> class.
  222.        ''' </summary>
  223.        ''' ----------------------------------------------------------------------------------------------------
  224.        Public Sub New()
  225.        End Sub
  226.  
  227.        ''' ----------------------------------------------------------------------------------------------------
  228.        ''' <summary>
  229.        ''' Initializes a new instance of the <see cref="TexfileLines"/> class.
  230.        ''' </summary>
  231.        ''' ----------------------------------------------------------------------------------------------------
  232.        ''' <param name="lines">
  233.        ''' The text-lines.
  234.        ''' </param>
  235.        ''' ----------------------------------------------------------------------------------------------------
  236.        Public Sub New(ByVal lines As IEnumerable(Of String))
  237.  
  238.            Me.AddRange(lines)
  239.  
  240.        End Sub
  241.  
  242. #End Region
  243.  
  244. #Region " Public Methods "
  245.  
  246.        ''' ----------------------------------------------------------------------------------------------------
  247.        ''' <summary>
  248.        ''' Randomizes the elements of the <see cref="System.Collections.Generic.List(Of T)"/>.
  249.        ''' </summary>
  250.        ''' ----------------------------------------------------------------------------------------------------
  251.        ''' <returns>
  252.        ''' An <see cref="IEnumerable(Of String)"/> that contains the randomized elements.
  253.        ''' </returns>
  254.        ''' ----------------------------------------------------------------------------------------------------
  255.        <DebuggerStepThrough>
  256.        Public Function Randomize() As IEnumerable(Of String)
  257.  
  258.            Dim rand As New Random
  259.  
  260.            Return From line As String In Me
  261.                   Order By rand.Next
  262.  
  263.        End Function
  264.  
  265.        ''' ----------------------------------------------------------------------------------------------------
  266.        ''' <summary>
  267.        ''' Removes the elements at the specified indexes of the <see cref="System.Collections.Generic.List(Of T)"/>.
  268.        ''' </summary>
  269.        ''' ----------------------------------------------------------------------------------------------------
  270.        ''' <param name="indexes">
  271.        ''' The zero-based indexes of the elements to remove.
  272.        ''' </param>
  273.        ''' ----------------------------------------------------------------------------------------------------
  274.        ''' <exception cref="IndexOutOfRangeException">
  275.        ''' </exception>
  276.        ''' ----------------------------------------------------------------------------------------------------
  277.        <DebuggerStepThrough>
  278.        Public Overloads Sub RemoveAt(ByVal indexes As IEnumerable(Of Integer))
  279.  
  280.            Dim lineCount As Integer = Me.Count
  281.  
  282.            Select Case indexes.Max
  283.  
  284.                Case Is < 0, Is > lineCount
  285.                    Throw New IndexOutOfRangeException()
  286.  
  287.                Case Else
  288.                    Dim tmpRef As IEnumerable(Of String) =
  289.                        Me.Select(Function(line As String, index As Integer)
  290.                                      Return New With
  291.                                             {
  292.                                                 Key .line = line,
  293.                                                 Key .index = index + 1
  294.                                             }
  295.                                  End Function).
  296.                           Where(Function(con) Not indexes.Contains(con.index)).
  297.                           Select(Function(con) con.line)
  298.  
  299.                    Me.Clear()
  300.                    Me.AddRange(tmpRef)
  301.                    tmpRef = Nothing
  302.  
  303.            End Select
  304.  
  305.        End Sub
  306.  
  307.        ''' ----------------------------------------------------------------------------------------------------
  308.        ''' <summary>
  309.        ''' Removes all leading and trailing occurrences of a set of characters from all the elements of the <see cref="System.Collections.Generic.List(Of T)"/>.
  310.        ''' </summary>  
  311.        ''' ----------------------------------------------------------------------------------------------------
  312.        ''' <param name="trimChars">
  313.        ''' An array of Unicode characters to remove.
  314.        ''' If <paramref name="trimChars"></paramref> is <c>Nothing</c> or an empty array, Unicode white-space characters are removed instead.
  315.        ''' </param>
  316.        ''' ----------------------------------------------------------------------------------------------------
  317.        ''' <returns>
  318.        ''' The <see cref="IEnumerable(Of String)"/> that remains after all occurrences of the specified characters are removed from the start and the end of the elements.
  319.        ''' </returns>
  320.        ''' ----------------------------------------------------------------------------------------------------
  321.        <DebuggerStepThrough>
  322.        Public Function Trim(Optional ByVal trimChars As Char() = Nothing) As IEnumerable(Of String)
  323.  
  324.            Return From line As String In Me
  325.                   Select line.Trim(trimChars)
  326.  
  327.        End Function
  328.  
  329.        ''' ----------------------------------------------------------------------------------------------------
  330.        ''' <summary>
  331.        ''' Removes all leading occurrences of a set of characters from all the elements of the <see cref="System.Collections.Generic.List(Of T)"/>.
  332.        ''' </summary>
  333.        ''' ----------------------------------------------------------------------------------------------------
  334.        ''' <param name="trimChars">
  335.        ''' An array of Unicode characters to remove.
  336.        ''' If <paramref name="trimChars"></paramref> is <c>Nothing</c> or an empty array, Unicode white-space characters are removed instead.
  337.        ''' </param>
  338.        ''' ----------------------------------------------------------------------------------------------------
  339.        ''' <returns>
  340.        ''' The <see cref="IEnumerable(Of String)"/> that remains after all occurrences of the specified characters are removed from the start of the elements.
  341.        ''' </returns>
  342.        ''' ----------------------------------------------------------------------------------------------------
  343.        <DebuggerStepThrough>
  344.        Public Function TrimStart(Optional ByVal trimChars As Char() = Nothing) As IEnumerable(Of String)
  345.  
  346.            Return From line As String In Me
  347.                   Select line.TrimStart(trimChars)
  348.  
  349.        End Function
  350.  
  351.        ''' ----------------------------------------------------------------------------------------------------
  352.        ''' <summary>
  353.        ''' Removes all trailing occurrences of a set of characters from all the elements of the <see cref="System.Collections.Generic.List(Of T)"/>.
  354.        ''' </summary>
  355.        ''' ----------------------------------------------------------------------------------------------------
  356.        ''' <param name="trimChars">
  357.        ''' An array of Unicode characters to remove.
  358.        ''' If <paramref name="trimChars"></paramref> is <c>Nothing</c> or an empty array, Unicode white-space characters are removed instead.
  359.        ''' </param>
  360.        ''' ----------------------------------------------------------------------------------------------------
  361.        ''' <returns>
  362.        ''' The <see cref="IEnumerable(Of String)"/> that remains after all occurrences of the specified characters are removed from the end of the elements.
  363.        ''' </returns>
  364.        ''' ----------------------------------------------------------------------------------------------------
  365.        <DebuggerStepThrough>
  366.        Public Function TrimEnd(Optional ByVal trimChars As Char() = Nothing) As IEnumerable(Of String)
  367.  
  368.            Return From line As String In Me
  369.                   Select line.TrimEnd(trimChars)
  370.  
  371.        End Function
  372.  
  373. #End Region
  374.  
  375.    End Class
  376.  
  377. #End Region
  378.  
  379. #Region " Constructors "
  380.  
  381.    ''' ----------------------------------------------------------------------------------------------------
  382.    ''' <summary>
  383.    ''' Prevents a default instance of the <see cref="TextfileStream"/> class from being created.
  384.    ''' </summary>
  385.    ''' ----------------------------------------------------------------------------------------------------
  386.    Private Sub New()
  387.    End Sub
  388.  
  389.    ''' ----------------------------------------------------------------------------------------------------
  390.    ''' <summary>
  391.    ''' Initializes a new instance of the <see cref="TextfileStream"/> class.
  392.    ''' </summary>
  393.    ''' ----------------------------------------------------------------------------------------------------
  394.    ''' <param name="filepath">
  395.    ''' The textfile path.
  396.    ''' If the path doesn't exists, the file will be created.
  397.    ''' </param>
  398.    '''
  399.    ''' <param name="encoding">
  400.    ''' The file encoding used to read the textfile.
  401.    ''' If <paramref name="encoding"></paramref> value is <c>Nothing</c>, an attempt to detect the encoding will be realized,
  402.    ''' if the attempt to detect the file encoding fails, <see cref="Encoding.Default"/> will be used.
  403.    ''' </param>
  404.    ''' ----------------------------------------------------------------------------------------------------
  405.    ''' <exception cref="FileNotFoundException">
  406.    ''' File not found.
  407.    ''' </exception>
  408.    ''' ----------------------------------------------------------------------------------------------------
  409.    <DebuggerStepThrough>
  410.    Public Sub New(ByVal filepath As String,
  411.                   Optional ByVal encoding As Encoding = Nothing)
  412.  
  413.        If Not File.Exists(filepath) Then
  414.            Throw New FileNotFoundException(message:="File not found.", fileName:=filepath)
  415.  
  416.        Else
  417.            Me.filepathB = filepath
  418.            Me.encodingB = encoding
  419.  
  420.            If Me.encodingB Is Nothing Then
  421.                Me.encodingB = Me.GetEncoding
  422.            End If
  423.  
  424.            Me.linesB = New TexfileLines(File.ReadAllLines(Me.filepathB, Me.encodingB))
  425.            Me.fsB = New FileStream(filepath, FileMode.OpenOrCreate)
  426.  
  427.        End If
  428.  
  429.    End Sub
  430.  
  431. #End Region
  432.  
  433. #Region " Public Methods "
  434.  
  435.    ''' ----------------------------------------------------------------------------------------------------
  436.    ''' <summary>
  437.    ''' Prevents other processes from reading or writing to the textfile.
  438.    ''' </summary>
  439.    ''' ----------------------------------------------------------------------------------------------------
  440.    <DebuggerStepThrough>
  441.    Public Sub Lock()
  442.  
  443.        Me.fsB.Lock(0, Me.fsB.Length)
  444.  
  445.    End Sub
  446.  
  447.    ''' ----------------------------------------------------------------------------------------------------
  448.    ''' <summary>
  449.    ''' Allows access by other processes to read or write to a textfile that was previously locked.
  450.    ''' </summary>
  451.    ''' ----------------------------------------------------------------------------------------------------
  452.    <DebuggerStepThrough>
  453.    Public Sub Unlock()
  454.  
  455.        Me.fsB.Unlock(0, Me.fsB.Length)
  456.  
  457.    End Sub
  458.  
  459.    ''' ----------------------------------------------------------------------------------------------------
  460.    ''' <summary>
  461.    ''' Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
  462.    ''' </summary>
  463.    ''' ----------------------------------------------------------------------------------------------------
  464.    <DebuggerStepThrough>
  465.    Public Sub Close()
  466.        Me.fsB.Close()
  467.    End Sub
  468.  
  469.    ''' ----------------------------------------------------------------------------------------------------
  470.    ''' <summary>
  471.    ''' Save the lines of the current textfile, in the current textfile.
  472.    ''' Note that the <see cref="Save"></see> method should be called to apply any realized changes in the lines of the textfile
  473.    ''' before disposing this <see cref="TextfileStream"></see> instance.
  474.    ''' </summary>
  475.    ''' ----------------------------------------------------------------------------------------------------
  476.    ''' <param name="encoding">
  477.    ''' The file encoding used to write the textfile.
  478.    ''' </param>
  479.    ''' ----------------------------------------------------------------------------------------------------
  480.    <DebuggerStepThrough>
  481.    Public Sub Save(Optional ByVal encoding As Encoding = Nothing)
  482.  
  483.        If encoding Is Nothing Then
  484.            encoding = Me.encodingB
  485.        End If
  486.  
  487.        Dim bytes As Byte() = encoding.GetBytes(Me.ToString)
  488.  
  489.        Me.fs.SetLength(bytes.Length)
  490.        Me.fs.Write(bytes, 0, bytes.Length)
  491.  
  492.    End Sub
  493.  
  494.    ''' ----------------------------------------------------------------------------------------------------
  495.    ''' <summary>
  496.    ''' Save the lines of the current textfile, in the target textfile.
  497.    ''' </summary>
  498.    ''' ----------------------------------------------------------------------------------------------------
  499.    ''' <param name="filepath">
  500.    ''' The target filepath where to save the text.
  501.    ''' </param>
  502.    '''
  503.    ''' <param name="encoding">
  504.    ''' The file encoding used to write the textfile.
  505.    ''' </param>
  506.    ''' ----------------------------------------------------------------------------------------------------
  507.    <DebuggerStepThrough>
  508.    Public Sub Save(ByVal filepath As String,
  509.                    Optional ByVal encoding As Encoding = Nothing)
  510.  
  511.        If encoding Is Nothing Then
  512.            encoding = Me.encodingB
  513.        End If
  514.  
  515.        Using fs As New FileStream(filepath, FileMode.OpenOrCreate)
  516.  
  517.            Dim bytes As Byte() = encoding.GetBytes(Me.ToString)
  518.  
  519.            fs.SetLength(bytes.Length)
  520.            fs.Write(bytes, 0, bytes.Length)
  521.  
  522.        End Using
  523.  
  524.    End Sub
  525.  
  526.    ''' ----------------------------------------------------------------------------------------------------
  527.    ''' <summary>
  528.    ''' Returns a <see cref="String"/> that represents this instance.
  529.    ''' </summary>
  530.    ''' ----------------------------------------------------------------------------------------------------
  531.    ''' <returns>
  532.    ''' A <see cref="String"/> that represents this instance.
  533.    ''' </returns>
  534.    ''' ----------------------------------------------------------------------------------------------------
  535.    <DebuggerStepThrough>
  536.    Public Overrides Function ToString() As String
  537.  
  538.        Return String.Join(ControlChars.NewLine, Me.linesB)
  539.  
  540.    End Function
  541.  
  542. #End Region
  543.  
  544. #Region " Private Methods "
  545.  
  546.    ''' ----------------------------------------------------------------------------------------------------
  547.    ''' <summary>
  548.    ''' Determines the <see cref="Encoding"/> of the current textfile.
  549.    ''' </summary>
  550.    ''' ----------------------------------------------------------------------------------------------------
  551.    ''' <returns>
  552.    ''' If the encoding can be detected, the return value is the detected <see cref="Encoding"/>,
  553.    ''' if the encoding can't be detected, the return value is <see cref="Encoding.Default"/>.
  554.    ''' </returns>
  555.    ''' ----------------------------------------------------------------------------------------------------
  556.    <DebuggerStepThrough>
  557.    Private Function GetEncoding() As Encoding
  558.  
  559.        Dim encoding As Encoding = Nothing
  560.        Dim bytes As Byte() = File.ReadAllBytes(Me.filepathB)
  561.  
  562.        For Each encodingInfo As EncodingInfo In encoding.GetEncodings()
  563.  
  564.            Dim currentEncoding As Encoding = encodingInfo.GetEncoding()
  565.            Dim preamble As Byte() = currentEncoding.GetPreamble()
  566.            Dim match As Boolean = True
  567.  
  568.            If (preamble.Length > 0) AndAlso (preamble.Length <= bytes.Length) Then
  569.  
  570.                For i As Integer = 0 To (preamble.Length - 1)
  571.  
  572.                    If preamble(i) <> bytes(i) Then
  573.                        match = False
  574.                        Exit For
  575.                    End If
  576.  
  577.                Next i
  578.  
  579.            Else
  580.                match = False
  581.  
  582.            End If
  583.  
  584.            If match Then
  585.                encoding = currentEncoding
  586.                Exit For
  587.            End If
  588.  
  589.        Next encodingInfo
  590.  
  591.        If encoding Is Nothing Then
  592.            Return encoding.Default
  593.  
  594.        Else
  595.            Return encoding
  596.  
  597.        End If
  598.  
  599.    End Function
  600.  
  601. #End Region
  602.  
  603. #Region " IDisposable "
  604.  
  605.    ''' ----------------------------------------------------------------------------------------------------
  606.    ''' <summary>
  607.    ''' To detect redundant calls when disposing.
  608.    ''' </summary>
  609.    ''' ----------------------------------------------------------------------------------------------------
  610.    Private isDisposed As Boolean = False
  611.  
  612.    ''' ----------------------------------------------------------------------------------------------------
  613.    ''' <summary>
  614.    ''' Prevent calls to methods after disposing.
  615.    ''' </summary>
  616.    ''' ----------------------------------------------------------------------------------------------------
  617.    ''' <exception cref="System.ObjectDisposedException"></exception>
  618.    ''' ----------------------------------------------------------------------------------------------------
  619.    Private Sub DisposedCheck()
  620.  
  621.        If Me.isDisposed Then
  622.            Throw New ObjectDisposedException(Me.GetType.FullName)
  623.        End If
  624.  
  625.    End Sub
  626.  
  627.    ''' ----------------------------------------------------------------------------------------------------
  628.    ''' <summary>
  629.    ''' Releases all the resources used by this <see cref="TextfileStream"></see> instance.
  630.    ''' </summary>
  631.    ''' ----------------------------------------------------------------------------------------------------
  632.    Public Sub Dispose() Implements IDisposable.Dispose
  633.        Me.Dispose(isDisposing:=True)
  634.        GC.SuppressFinalize(obj:=Me)
  635.    End Sub
  636.  
  637.    ''' ----------------------------------------------------------------------------------------------------
  638.    ''' <summary>
  639.    ''' Releases unmanaged and - optionally - managed resources.
  640.    ''' </summary>
  641.    ''' ----------------------------------------------------------------------------------------------------
  642.    ''' <param name="isDisposing">
  643.    ''' <c>True</c> to release both managed and unmanaged resources;
  644.    ''' <c>False</c> to release only unmanaged resources.
  645.    ''' </param>
  646.    ''' ----------------------------------------------------------------------------------------------------
  647.    Protected Sub Dispose(ByVal isDisposing As Boolean)
  648.  
  649.        If Not Me.isDisposed Then
  650.  
  651.            If isDisposing Then
  652.  
  653.                If Me.fsB IsNot Nothing Then
  654.                    Me.fsB.Close()
  655.                    Me.linesB.Clear()
  656.                End If
  657.  
  658.            End If
  659.  
  660.        End If
  661.  
  662.        Me.isDisposed = True
  663.  
  664.    End Sub
  665.  
  666. #End Region
  667.  
  668. End Class
  669.  
  670. #End Region
5115  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets para VB.Net !! (Compartan aquí sus snippets) en: 19 Junio 2015, 07:03 am
Hola Eleкtro.

Disculpas las molestias pero el primer link de la pag 1 de snippets que es de mediafire no funciona ni tampoco el de la pagina 36 Actualizada la colección de snippets con un total de 544 Snippets
talvez puedas compartirlos en otro compila o volver a subir ese no habia teniado el gusto de ver el tema y me parece muy bueno.

Saludos.

Hmmm... antes de nada, ¡Gracias por avisar!, pero estoy preparando una actualización importante, hay muchos snippets antiguos que necesitan una refactorización completa, otros es mejor eliminarlos o adaptarlos para otros propósitos, y en fin, un lio, prefiero no resubir nada de momento hasta que no "limpie" todos los snippets, y son unos 700 (me está llevando meses xD).

De todas formas, aquí puedes descargar una versión más reciente de la colección de snippets:


(si prefieres no usar el exe, puedes desempaquetar su contenido con la aplicación InnoUnp para InnoSetup)

Saludos!
5116  Programación / .NET (C#, VB.NET, ASP) / Re: Error de librerias creo en: 19 Junio 2015, 06:46 am
Me pregunto si luego de usar los componentes free y generar un ejecutable los usuarios finales podrán ejecutar el programa sin problemas.

zonahurbana, cómo dice la respuesta de la imagen que he mostrado, si, se podrá seguir usando sin problemas, pero, inexorablemente al iniciar la app algunas veces (al cargar el ensamblado base de Telerik), aparecerá un popup de aviso recordando que se está utilizando una versión de prueba.

...Al menos eso es lo que da a entender por "from time to time", pero quizás también se puede estar refiriendo a que se muestre un aviso cada "X" minutos mientras la aplicación se mantenga en ejecución, no se que sería peor xD.

EDITO:
Para salir de dudas sobre la agresividad de las limitaciones post-trial (ya que no te manejas bien con el inglés para preguntar al soporte de Telerik), lo mejor que puedes hacer es instalarte una V.M., compilas una app en tu S.O. huésped con la versión de prueba de Telerik UI, y por último ejecutas en el S.O. invitado la app que compilaste para ver que ocurre. ...O pásale la app a algún colega y que la pruebe xD.

Saludos!
5117  Programación / .NET (C#, VB.NET, ASP) / Re: Error de librerias creo en: 19 Junio 2015, 04:05 am
¿Por qué nunca nadie se lee el F.A.Q de un servicio del que tiene dudas, o acude a la asistencia de dicho servicio para encontrar respuestas de sus representantes?.  :-\

http://www.telerik.com/purchase/faq/platform

[ img ]http://i.imgur.com/qPn2e5R.png[ /img ]

EDITO: No es exactamente eso, estoy buscando ahora sobre WinForms.


http://www.telerik.com/forums/question-regarding-trial-versions



Saludos!
5118  Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda extraer texto de una web en: 19 Junio 2015, 03:51 am
Buenas

Para usar un servicio online, antes de ponerte a trastear primero tienes que analizar y/o documentarte sobre que parámetros puede tomar la query de dicho servicio.

Dicho esto, por lo que siempre he visto, es mala idea traducir la respuesta de GoogleTranslate, te va a dar cientos de problemas muy concretos de parsing, pero si aun así lo quieres intentar, entonces para intentar sacarle el máximo beneficio posible a lo que estás intentando hacer, obtén la respuesta en formato JSON, esto lo puedes hacer asignando el parámetro client con un valor que sea diferente a "t":

Ejemplo:
http://translate.google.com/translate_a/t?client=p&text=hola&sl=es&tl=en

Respuesta (RAW):
Código:
{"sentences":[{"trans":"Hello","orig":"hola","translit":"","src_translit":""}],"src":"es","server_time":26}

Respuesta formateada:
Código:
{
"sentences":
[
{
"trans":"Hello",
"orig":"hola",
"translit":"",
"src_translit":""
}
],
"src":"es",
"server_time":26
}

Puedes utilizar la ibrería JSON.Net (si no recuerdo mal la tienes disponible desde la consola NuGet de VisualStudio también) para llevar a cabo la tarea de parseo de la manera más eficiente.

PD: Hay proyectos de clientes gratuitos y muy elaborados de GoogleTranslate en C# que puedes encontrar en páginas cómo codeproject.com, pero ninguno es perfecto al intentar traducir en ciertas circunstancias (por las complicaciones variables del parseo de la respuesta). En cambio, la Web-API de pago de GoogleTranslate te lo da todo hecho de manera muy limpia y facil, sin complicaciones (al menos por lo que he visto en la documentación oficial de Google Dev).

Saludos!
5119  Foros Generales / Foro Libre / Re: La repugnante «rata-pollo» de KFC que causa estragos en Facebook en: 19 Junio 2015, 03:20 am
Con poner en Google "KFC Rat" salen cientos de debunks a esta noticia, que claramente es un intento de fraude por parte del cliente, cliente que además al parecer se niega a cooperar con los representantes de KFC.

Es claramente un listillo que ya no puede seguir fingiendo.



Algunos datos interesantes:

Citar

Citar
A customer has made a serious claim against KFC and refuses to cooperate in the investigation.

The images the customer originally posted do not include this second angle because it clearly shows it’s a piece of hand-breaded white meat chicken.

Based on this, and the fact that he refuses to allow anyone to see the product, we are left to believe that he intended to deceive the public with this hoax and we are considering all options.



Citar


Where’s the skull? Where are the legs? What about the third tower? Frying oil isn’t hot enough to melt steel beams!

If you look at the evidence, it’s clear that this is not a rat, it’s just a piece of fried chicken with a “tail” of fat hanging off of it.

Fuente(s):
http://imgur.com/gallery/wxg9VcQ
http://gawker.com/kfconspiracy-did-kfc-serve-someone-a-fried-breaded-ra-1711946555
5120  Foros Generales / Foro Libre / Re: La repugnante «rata-pollo» de KFC que causa estragos en Facebook en: 19 Junio 2015, 03:00 am
Citar
Tras comprobar que su pedido no era carne rebozada, sino una rata empanada, decidió denunciarlo y para demostrarlo no dudó en compartir las fotografías.

Yo no entiendo a la gente, es para cabrearse, con lo facil que sería aportar una prueba irrefutable quitando un poco de la superficie empanada para que se vea la carne y así poder comprobar si la piel tiene pelo de rata o es piel de pollo...

Así que sin pruebas, la forma de rata no demuestra evidencia alguna, unos ven a Jesucristo en las galletas, y otros pueden ver ratas donde puede que no haya nada más que pollo.

Tal vez solo sea un caso de alguien que busca dinero facil con una denuncia a una empresa cómo KFC, porque si hacer una foto al "alimento" sin rasgar la superficie ni mostrar fotos de la carne ni nada ...pues si esa es la única forma que este individuo ha encontrado para "demostrar" algo, entonces vamos apañados.

A mi me parece un FAAAKE.

Saludos!
Páginas: 1 ... 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 [512] 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines