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

 

 


Tema destacado: Curso de javascript por TickTack


  Mostrar Mensajes
Páginas: 1 ... 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 [976] 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 ... 1232
9751  Programación / .NET (C#, VB.NET, ASP) / Re: Pequeña duda sobre argumentos en: 13 Enero 2013, 18:20 pm
Podrías pasar un object, pero no es para nada recomendable, donde vea que comienzas a hacer eso te baneo :xD)

Pero digo yo que no seré el primero en tener este problemilla xD... ¿Como lo solucionarías tú?  :-[

Que pocas soluciones hay entonces.

PD: gracias!

EDITO:
Citar
en un rato me paso por tu post de snippets para darte unas sugerencias en cuanto a estructura de código :)
perfecto!
9752  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] Pequeña duda sobre argumentos en: 13 Enero 2013, 18:10 pm
¿Se puede definir más de un tipo por Valor/Referencia por argumento?

Necesito hacer algo así:
Código:
Public Function blablabla(ByRef Image_File As String or As Bitmap)

O en su defecto:
Código:
Public Function blablabla(ByRef Image_File As "Cualquier tipo que séa aceptable")
If Image_File = Ctype(string) then...
if Image_File = Ctype(Bitmap) then...
9753  Programación / Scripting / Re: hola soy nuevo y tengo un problemilla con phyton en: 13 Enero 2013, 15:50 pm
A mi no me sale ninguna imagen, pero bueno xD.

Asegúrate de estar usando la versión correcta del intérprete de python, porque varios métodos y ordenes cambian.

Python 2.7.X
o
Python 3.X

Te recomiendo que uses la versión 2.7.X porque la mayoría de documentación/Ejemplos que encuentres estará escrita para esa versión...

Saludos.
9754  Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets (ACTUALIZADO 12/01/2013) Posteen aquí sus snippets!! en: 13 Enero 2013, 07:34 am
Get OS Version

Código
  1.        Dim OS_Version As String = System.Environment.OSVersion.ToString
  2.        MsgBox(OS_Version)



String Is Email

Código
  1.    ' // By Elektro H@cker
  2.    '
  3.    ' USAGE:
  4.    '
  5.    ' MsgBox(String_Is_Email("User@Email.com"))
  6.  
  7. #Region " String Is Email Function "
  8.  
  9.    Private Function String_Is_Email(ByVal Email_String As String)
  10.        Dim Emaill_RegEx As New System.Text.RegularExpressions.Regex("^[A-Za-z0-9][A-Za-z0-9]+\@[A-Za-z0-9]+\.[A-Za-z0-9][A-Za-z0-9]+$")
  11.        If Emaill_RegEx.IsMatch(Email_String) Then Return True Else Return False
  12.    End Function
  13.  
  14. #End Region



Get Random Password

Código
  1.    ' USAGE:
  2.    '
  3.    ' MsgBox(Get_Random_Password(8))
  4.    ' MsgBox(Get_Random_Password(36))
  5.  
  6. #Region " Get Random Password Function "
  7.  
  8.    Public Function Get_Random_Password(ByVal Password_Length As Double) As String
  9.        Dim New_Password As String = System.Guid.NewGuid.ToString
  10.        If Password_Length <= 0 OrElse Password_Length > New_Password.Length Then
  11.            Throw New ArgumentException("Length must be between 1 and " & New_Password.Length)
  12.        End If
  13.        Return New_Password.Substring(0, Password_Length)
  14.    End Function
  15.  
  16. #End Region



Get Printers

Código
  1.    ' // By Elektro H@cker
  2.    '
  3.    ' USAGE:
  4.    '
  5.    '  For Each Printer_Name In Get_Printers() : MsgBox(Printer_Name) : Next
  6.  
  7.    Private Function Get_Printers()
  8.        Dim Printer_Array As New List(Of String)
  9.        Try
  10.            For Each Printer_Name As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters : Printer_Array.Add(Printer_Name) : Next
  11.        Catch ex As Exception
  12.            If ex.Message.Contains("RPC") Then Return "RPC Service is not avaliable"
  13.        End Try
  14.        Return Printer_Array
  15.    End Function
9755  Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets (ACTUALIZADO 12/01/2013) Posteen aquí sus snippets!! en: 12 Enero 2013, 23:30 pm
Set_PC_State

Código
  1.    ' // By Elektro H@cker
  2.  
  3.    ' USAGE:
  4.    '
  5.    ' Set_PC_State(RESET)
  6.    ' Set_PC_State(SUSPEND, 30, "I'm suspending your system.")
  7.    ' Set_PC_State(LOG_OFF)
  8.    ' Set_PC_State(HIBERN)
  9.    ' Set_PC_State(ABORT)
  10.  
  11. #Region " Set PC State "
  12.  
  13.    Const RESET As String = " -R "
  14.    Const SUSPEND As String = " -S "
  15.    Const LOG_OFF As String = " -L "
  16.    Const HIBERN As String = " -H "
  17.    Const ABORT As String = " -A "
  18.  
  19.    Private Function Set_PC_State(ByVal PowerState_Action As String, Optional ByVal TimeOut As Integer = 1, Optional ByVal COMMENT As String = "")
  20.  
  21.        Dim Shutdown_Command As New ProcessStartInfo
  22.        Shutdown_Command.FileName = "Shutdown.exe"
  23.  
  24.        Try
  25.            If PowerState_Action = ABORT Or PowerState_Action = HIBERN Or PowerState_Action = LOG_OFF Then
  26.                Shutdown_Command.Arguments = PowerState_Action ' Windows don't allow TimeOut or Comment options for HIBERN, LOG_OFF or ABORT actions.
  27.            ElseIf PowerState_Action = RESET Or PowerState_Action = SUSPEND Then
  28.                If Not COMMENT = "" Then
  29.                    If COMMENT.Length > 512 Then COMMENT = COMMENT.Substring(0, 512) ' Only 512 chars are allowed for comment
  30.                    Shutdown_Command.Arguments = PowerState_Action & " -T " & TimeOut & " /C " & COMMENT
  31.                Else
  32.                    Shutdown_Command.Arguments = PowerState_Action & " -T " & TimeOut
  33.                End If
  34.                Shutdown_Command.WindowStyle = ProcessWindowStyle.Hidden
  35.                Process.Start(Shutdown_Command)
  36.                Return True
  37.            End If
  38.        Catch ex As Exception
  39.            Return ex.Message
  40.        End Try
  41.  
  42.        Return Nothing ' Invalid argument
  43.    End Function
  44.  
  45. #End Region





Día local:

Código
  1. Dim Today as string = My.Computer.Clock.LocalTime.DayOfWeek ' In English language
  2.  
  3. Dim Today as string = System.Globalization.DateTimeFormatInfo.CurrentInfo.GetDayName(Date.Today.DayOfWeek) ' In system language




String is URL?

Código
  1.    ' USAGE:
  2.    '
  3.    ' If String_Is_URL("http://google.com") Then MsgBox("Valid url!") Else MsgBox("Invalid url!")
  4.  
  5. #Region " String Is URL Function "
  6.  
  7.    Private Function String_Is_URL(ByVal STR As String)
  8.        Dim URL_Pattern As String = "^(http|https):/{2}[a-zA-Z./&\d_-]+"
  9.        Dim URL_RegEx As New System.Text.RegularExpressions.Regex(URL_Pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase Or System.Text.RegularExpressions.RegexOptions.ExplicitCapture)
  10.        If URL_RegEx.IsMatch(STR) Then Return True Else Return False
  11.    End Function
  12.  
  13. #End Region




G-Mail Sender (Envía emails)

Código
  1.    ' USAGE:
  2.    '
  3.    ' GMail_Sender("Your_Email@Gmail.com", "Your_Password", "Email Subject", "Message Body", "Destiny@Email.com")
  4.  
  5. #Region " GMail Sender function "
  6.  
  7.    Private Function GMail_Sender(ByVal Gmail_Username As String, ByVal Gmail_Password As String, ByVal Email_Subject As String, ByVal Email_Body As String, ByVal Email_Destiny As String)
  8.        Try
  9.            Dim MailSetup As New System.Net.Mail.MailMessage
  10.            MailSetup.Subject = Email_Subject
  11.            MailSetup.To.Add(Email_Destiny)
  12.            MailSetup.From = New System.Net.Mail.MailAddress(Gmail_Username)
  13.            MailSetup.Body = Email_Body
  14.            Dim SMTP As New System.Net.Mail.SmtpClient("smtp.gmail.com")
  15.            SMTP.Port = 587
  16.            SMTP.EnableSsl = True
  17.            SMTP.Credentials = New Net.NetworkCredential(Gmail_Username, Gmail_Password)
  18.            SMTP.Send(MailSetup)
  19.            Return True ' Email is sended OK
  20.        Catch ex As Exception
  21.            Return ex.Message ' Email can't be sended
  22.        End Try
  23.    End Function
  24.  
  25. #End Region

9756  Programación / .NET (C#, VB.NET, ASP) / Re: My.Computer.Clock.LocalTime.DayOfWeek en: 12 Enero 2013, 22:28 pm
Gracias ^^, sabía que habría que utilizar lo del cultureinfo pero no sabía como xD.
9757  Programación / .NET (C#, VB.NET, ASP) / Re: Como simular el método "performclick" de un botón? en: 12 Enero 2013, 21:44 pm
nah ya está, el autor me ha dicho que el método ".click" en este control es ".clickbuttonarea"

xD

Saludos
9758  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] My.Computer.Clock.LocalTime.DayOfWeek en: 12 Enero 2013, 20:45 pm
¿Se puede obtener este dato en el idioma instalado del equipo?

Código:
My.Computer.Clock.LocalTime.DayOfWeek
9759  Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets (ACTUALIZADO 12/01/2013) Posteen aquí sus snippets!! en: 12 Enero 2013, 20:36 pm
Otro convertidor, en esta ocasión un convertidor de tiempo, ms, segundos, minutos, horas.


Código
  1. #Region " Convert Time Function"
  2.  
  3.    ' // By Elektro H@cker
  4.    '
  5.    ' MsgBox(Convert_Time(1, "h", "m"))
  6.    ' MsgBox(Convert_Time(1, "h", "s"))
  7.    ' MsgBox(Convert_Time(1, "h", "ms"))
  8.    ' MsgBox(Convert_Time(6000, "milliseconds", "seconds"))
  9.    ' MsgBox(Convert_Time(6000, "seconds", "minutes"))
  10.    ' MsgBox(Convert_Time(6000, "minutes", "hours"))
  11.  
  12.    Private Function Convert_Time(ByVal Time As Int64, ByVal Input_Time_Format As String, ByVal Output_Time_Format As String)
  13.        Dim Time_Span As New TimeSpan
  14.        If Input_Time_Format.ToUpper = "MS" Or Output_Time_Format.ToUpper = "MILLISECONDS" Then Time_Span = New TimeSpan(TimeSpan.TicksPerMillisecond * Time)
  15.        If Input_Time_Format.ToUpper = "S" Or Output_Time_Format.ToUpper = "SECONDS" Then Time_Span = New TimeSpan(TimeSpan.TicksPerSecond * Time)
  16.        If Input_Time_Format.ToUpper = "M" Or Output_Time_Format.ToUpper = "MINUTES" Then Time_Span = New TimeSpan(TimeSpan.TicksPerMinute * Time)
  17.        If Input_Time_Format.ToUpper = "H" Or Output_Time_Format.ToUpper = "HOURS" Then Time_Span = New TimeSpan(TimeSpan.TicksPerHour * Time)
  18.        If Output_Time_Format.ToUpper = "MS" Or Output_Time_Format.ToUpper = "MILLISECONDS" Then Return Time_Span.TotalMilliseconds
  19.        If Output_Time_Format.ToUpper = "S" Or Output_Time_Format.ToUpper = "SECONDS" Then Return Time_Span.TotalSeconds
  20.        If Output_Time_Format.ToUpper = "M" Or Output_Time_Format.ToUpper = "MINUTES" Then Return Time_Span.TotalMinutes
  21.        If Output_Time_Format.ToUpper = "H" Or Output_Time_Format.ToUpper = "HOURS" Then Return Time_Span.TotalHours
  22.        Return False ' Returns false if argument is in incorrect format
  23.    End Function
  24.  
  25. #End Region
  26.  
9760  Programación / .NET (C#, VB.NET, ASP) / Re: Como aplicar cambios al registro y refrescar el sistema sin tener que reiniciar? en: 12 Enero 2013, 18:44 pm
Sigo sin saber nada xD.

Páginas: 1 ... 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 [976] 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 ... 1232
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines