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

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


  Mostrar Mensajes
Páginas: 1 ... 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 [999] 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 ... 1236
9981  Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets en: 19 Diciembre 2012, 04:04 am
$Edu$ no se si tienes el VS pero si lo tienes donde escribes el código del form presiona "click derecho > insert snippet" y ahí ves lo que són.

Esto de snippets vendria a ser como "codigos sueltos" para poder copiar y tenerlos a mano siempre?
Ya te ha contestado Novlucker pero cabe decir que un snippet no es algo que haya inventado Microsoft, hay bastantes editores de texto que soportan el uso de snippets, y bueno... los que trabajen con HTML/CSS/PHP y todo eso seguro que están muy acostumbrados a usar snippets para sus diseños web, igual que se pueden tener snippets para Batch (xD).

saludos!



tal vez deberías de tener snippets que hagan las cosas de la manera más elegante y "performante" posible :P,
hay código mejorable

Hay algunos snippets que yo solo no podría haberlos creado porque no sé hacerlo, por ejemplo el "GlobalHotkeys.snippet", no véas cuanto código con las APIs, como para ponerme a intentar mejorarlos! :xD

Ahora te hago yo una sugerencia:
De sabios es compartir el conocimiento, hay que realizar buenas acciones antes de que se acabe el munedo en... 2 días  :silbar:,
Y lo que necesita todo aprendiz de programador es un aporte con los snippets del gran Nov, muchos lo agradecerían (O al menos uno aquí presente... xD).

Ahí lo dejo...  :-X

Saludos!
9982  Programación / .NET (C#, VB.NET, ASP) / Re: XmlDocument.LoadXml ¿Porque no me funciona? en: 18 Diciembre 2012, 22:30 pm
Nada Nov, no quiere funcionar... no me salta ninguna excepción.
Lo de "Load" lo había visto pero como me decía que era para una URL... xD lo he intentado con load y la app se cuelga en donde la excepción, pero no me manda ningún error, juas.



EDITO:
Vale, ahora sí me salta excepción...

Código:
"There are multiple root elements. Line 2, position 2."

¿Porque me dice que hay multiples elementos, si en teoría de lo que se trata es de obtener multiples elementos del mismo TagName xD?

Código
  1.        Try
  2.            xmlDoc.Load("C:\t.xml")
  3.        Catch ex As Exception
  4.            MessageBox.Show(ex.Message)
  5.        End Try

t.xml:
Código:
<name>1</name>
<name>2</name>
<name>3</name>
<name>4</name>
9983  Programación / .NET (C#, VB.NET, ASP) / Librería de Snippets para VB.NET !! (Compartan aquí sus snippets) en: 18 Diciembre 2012, 22:23 pm
¿Que es un Snippet?

Es una porción de código que suele contener una o varias Subrutinas con el propósito de realizar una tarea específica,
cuyo código es reusable por otras personas y fácil de integrar con sólamente copiar y pegar el contenido del Snippet.





( click para ver el índice )

9984  Programación / Scripting / Re: libro "python para todos" equivalencia en un curriculum en: 18 Diciembre 2012, 22:16 pm
¿Cuanto tiempo le veis a un menor un poco mas inteligente que la media aprender Java, C, C++, HTML, javascript, PHP, CSS y SQL a nivel medio?
 ;D

Has hecho un comentario fuera de lugar,
Si tienes una duda que no séa referente al tema que se está tranando en este hilo entonces formula tu pregunta en un nuevo post.

Pero ya puestos te aconsejo empezar con HTML para que te lo quites de encima bien rápido, ya que se aprende en menos de 7 días (Es un lenguaje de etiquetas), yo sé lo básico sólamente habiendo mirado el nombre de todos los tags 2 o 3 veces, y bueno, el resto te lo hace el DW xD.

PD: No sigas el tema porfavor.

Saludos.
9985  Programación / .NET (C#, VB.NET, ASP) / XmlDocument.LoadXml ¿Porque no me funciona? en: 18 Diciembre 2012, 20:43 pm
- ¿Porque no me funciona?
- ¿Y se puede cargar un archivo xml local sin setearlo en un string?

Código
  1. Imports System.Xml
  2. Imports System.Xml.Serialization
  3. Imports System.IO
  4.  
  5.  
  6.  
  7. Public Class Form1
  8.  
  9.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  10.  
  11.        Dim rawXML As String = _
  12.      "<Company>" & _
  13.      "  <Employee>" & _
  14.      "    <name>John</name>" & _
  15.      "    <Id>1</Id>" & _
  16.      "    <email>John@xxxxxx.com</email>" & _
  17.      "  </employee>" & _
  18.      "  <employee>" & _
  19.      "    <name>Sue</name>" & _
  20.      "    <Id>2</Id>" & _
  21.      "    <email>Sue@xxxxxx.com</email>" & _
  22.      "  </employee>" & _
  23.      "</Company>"
  24.  
  25.        Dim xmlDoc As New XmlDocument
  26.        Dim employeeNodes As XmlNodeList
  27.        Dim employeeNode As XmlNode
  28.        Dim baseDataNodes As XmlNodeList
  29.        Dim bFirstInRow As Boolean
  30.  
  31.        MsgBox("A")
  32.        xmlDoc.LoadXml(rawXML)
  33.        ' Este msgbox no se llega a ver
  34.        MsgBox("B")
  35.        employeeNodes = xmlDoc.GetElementsByTagName("name")
  36.  
  37.        For Each employeeNode In employeeNodes
  38.            baseDataNodes = employeeNode.ChildNodes
  39.            bFirstInRow = True
  40.  
  41.            For Each baseDataNode As XmlNode In baseDataNodes
  42.                If (bFirstInRow) Then
  43.                    bFirstInRow = False
  44.                Else
  45.                    MsgBox(", ")
  46.                End If
  47.                MsgBox(baseDataNode.Name & ": " & baseDataNode.InnerText)
  48.            Next
  49.        Next
  50.    End Sub
  51. End Class
9986  Programación / Scripting / Re: Habilitar conexión compartida a internet (ICS) con visual basic script en: 18 Diciembre 2012, 20:16 pm
PD : es un reto para todos los que les gusta la programación en scripting y sobre todo los retos.
Para que molestarse en codearlo cuando ya está hecho xD.

Pruébalo pasándole los argumentos necesarios:

Código
  1. Originally from http://www.autoitscript.com/forum/topic/28897-switch-ics/
  2. 'Changed to VBS, added arguments and fixed for private/public networkds by Dror Gluska 2012-06-25
  3. 'Dror Gluska (2012) - http://uhurumkate.blogspot.co.il/
  4.  
  5.  
  6. option explicit
  7.  
  8.  
  9.  
  10. Main( )
  11.  
  12. sub Main( )
  13.    dim objArgs, con, endis,con2
  14.  
  15.    Set objArgs = WScript.Arguments
  16.  
  17.    'WScript.Echo objArgs.Count
  18.  
  19.    if objArgs.Count > 0 then
  20.        con = objArgs(0)
  21.        con2 = objArgs(1)
  22.        endis = objArgs(2)
  23.  
  24.        EnableDisableICS con,con2, endis 'true enables, false disables
  25.  
  26.    else
  27.        DIM szMsg
  28.        szMsg = "Invalid usage! Please provide the name of the connection as the argument." & vbCRLF & vbCRLF & _
  29.                "Usage:" & vbCRLF & _
  30.                " " + WScript.scriptname + " ""Public Connection Name"" ""Private Connection Name"" true/false"
  31.        WScript.Echo( szMsg )
  32.  
  33.    end if
  34.  
  35. end sub
  36.  
  37.  
  38.  
  39. function EnableDisableICS(sPublicConnectionName, sPrivateConnectionName, bEnable)
  40.  
  41.    dim bFound
  42.    bFound = FALSE
  43.    dim oNetSharingManager, oConnectionCollection, oItem, EveryConnection, objNCProps
  44.  
  45.    set oNetSharingManager = Wscript.CreateObject("HNetCfg.HNetShare.1")
  46.     if (IsObject(oNetSharingManager)) = FALSE then
  47.        Wscript.Echo("Unable to get the HNetCfg.HnetShare.1 object.")
  48.        Exit function
  49.    End if
  50.  
  51.    if (IsNull(oNetSharingManager.SharingInstalled) = TRUE) then
  52.        Wscript.Echo( "Sharing is not available on this platform.")
  53.        Exit function
  54.    End if
  55.  
  56.  
  57.  
  58.     set oConnectionCollection = oNetSharingManager.EnumEveryConnection
  59.    for each oItem In oConnectionCollection
  60.        set EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection (oItem)
  61.        set objNCProps = oNetSharingManager.NetConnectionProps (oItem)
  62.         If objNCProps.name = sPrivateConnectionName Then
  63.            bFound = True
  64.           Wscript.Echo("Setting ICS Private to " & bEnable & " on connection: " & objNCProps.name)
  65.            If bEnable Then
  66.                EveryConnection.EnableSharing (1)
  67.            Else
  68.                EveryConnection.DisableSharing
  69.            End if
  70.        End if
  71.    Next
  72.  
  73.    set oConnectionCollection = oNetSharingManager.EnumEveryConnection
  74.    for each oItem In oConnectionCollection
  75.        set EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection (oItem)
  76.        set objNCProps = oNetSharingManager.NetConnectionProps (oItem)
  77.  
  78.        If objNCProps.name = sPublicConnectionName Then
  79.            bFound = True
  80.           Wscript.Echo("Setting ICS Public to " & bEnable & " on connection: " & objNCProps.name)
  81.            If bEnable Then
  82.                EveryConnection.EnableSharing (0)
  83.            Else
  84.                EveryConnection.DisableSharing
  85.            End if
  86.        End if
  87.    next
  88.  
  89.    If Not bFound Then
  90.       Wscript.Echo("Unable to find the connection " & sPublicConnectionName)
  91.    End if
  92.  
  93. end function
9987  Programación / .NET (C#, VB.NET, ASP) / Re: Duda sobre los elementos que trabajan en segundo plano en: 18 Diciembre 2012, 18:14 pm

Código
  1. 'Declaration
  2. Public Delegate Sub Action(Of In T1, In T2, In T3, In T4, In T5, In T6, In T7, In T8, In T9, In T10, In T11, In T12, In T13, In T14, In T15, In T16) ( _
  3. arg1 As T1, _
  4. arg2 As T2, _
  5. arg3 As T3, _
  6. arg4 As T4, _
  7. arg5 As T5, _
  8. arg6 As T6, _
  9. arg7 As T7, _
  10. arg8 As T8, _
  11. arg9 As T9, _
  12. arg10 As T10, _
  13. arg11 As T11, _
  14. arg12 As T12, _
  15. arg13 As T13, _
  16. arg14 As T14, _
  17. arg15 As T15, _
  18. arg16 As T16 _
  19. )

Eso ya pinta dificil.

PREGUNTA: ¿Action tiene un límite de 16 argumentos?
(Quizás no llegue a saber hacer eso en toda mi vida xD, pero estaría bien saberlo si se da el caso.)

De todas formas con toda esta info doy por solucionado el tema xD,
Gracias por vuestras respuestas.




Bonito snippet:

Simple Delegate Example

Código
  1.    Imports System
  2.    Namespace DelegateTest
  3.    Public Delegate Sub TestDelegate(ByVal message As String)
  4.  
  5.    Class Program
  6.    Public Shared Sub Display(ByVal message As String)
  7.    Console.WriteLine("")
  8.    Console.WriteLine("The string entered is : " + message)
  9.    End Sub
  10.  
  11.    Shared Sub Main(ByVal args As String())
  12.    '-- Instantiate the delegate
  13.    Dim t As New TestDelegate(AddressOf Display)
  14.  
  15.    '-- Input some text
  16.    Console.WriteLine("Please enter a string:")
  17.    Dim message As String = Console.ReadLine()
  18.  
  19.    '-- Invoke the delegate
  20.    t(message)
  21.    Console.ReadLine()
  22.    End Sub
  23.    End Class
  24.    End Namespace

9988  Programación / .NET (C#, VB.NET, ASP) / Re: Duda sobre los elementos que trabajan en segundo plano en: 18 Diciembre 2012, 17:20 pm
No has declarado un delegado, has utilizado uno predefinido, ¿que crees que es Action? :P

Vaya, eso lo explica todo XD,
estuve buscando un buen rato sobre lo que es "Action" porque en todos los snippets relacionados con multi-threading lo veo, pero no encontré nada, si pudieras pasarme algún link... xD

Gracias
9989  Programación / .NET (C#, VB.NET, ASP) / Re: Duda sobre los elementos que trabajan en segundo plano en: 18 Diciembre 2012, 16:07 pm
¿Y que me dicen de esto?
Código
  1.    ' Usage:
  2.    ' InvokeControl(RichTextBox1, Sub(x) x.AppendText("a"))
  3.  
  4. #Region " Invoke Controls "
  5.    Public Sub InvokeControl(Of T As Control)(ByVal Control As T, ByVal Action As Action(Of T))
  6.        If Control.InvokeRequired Then
  7.            Control.Invoke(New Action(Of T, Action(Of T))(AddressOf InvokeControl), New Object() {Control, Action})
  8.        Else
  9.            Action(Control)
  10.        End If
  11.    End Sub
  12. #End Region

Lo he testeado a fondo creando varios threads que modifican propiedades de varios controles al mismo tiempo, e incluso modifican el mismo control del form principal todos los threads al mismo tiempo, y no me ha saltado ninguna excepción, es decir, lo he podido usar sin escribir delegados...

¿Esa técnica la consideran buena o la idea de usar delegados sigue siendo mejor?
9990  Programación / .NET (C#, VB.NET, ASP) / (SOLUCIONADO) ¿Que tipo de parámetro debo pasarle? en: 18 Diciembre 2012, 15:11 pm
EDITO: Esto ya no necesito saberlo



Código
  1. Module InvokeRequiredHandler
  2.    <System.Runtime.CompilerServices.Extension()> _
  3.    Public Sub HandleInvokeRequired(Of T As ISynchronizeInvoke)(ByVal controlToInvoke As T, ByVal actionToPerform As Action(Of T))
  4.        'Check to see if the control's InvokeRequired property is true
  5.        If controlToInvoke.InvokeRequired Then
  6.            'Use Invoke() to invoke your action
  7.            controlToInvoke.Invoke(actionToPerform, New Object() {controlToInvoke})
  8.        Else
  9.            'Perform the action
  10.            actionToPerform(controlToInvoke)
  11.        End If
  12.    End Sub
  13. End Module

Si por ejemplo, desde otro hilo quisiera modificar la propiedad "Text" de un textbox... ¿Como lo hago?
Código:
HandleInvokeRequired(Textbox1, ¿?)
No se que argumento se puede usar como "Action"
Páginas: 1 ... 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 [999] 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines