Jump to content
  1. fopetesl

    fopetesl

  • Similar Content

    • By iamtheky
      Hopefully this expands as I get to play more with Neo4j.  Starting simple here is an example of mapping artists to the bands they are in (a not quite complete Puscifer visualization).
       

       
       
      ;2DArray TO Neo4j #include<array.au3> Local $aBandMaster[0] ; declare this array fo later Local $aArray[1][2] ; declare this array for right....now $aArray[0][0] = "name" ;Title of column 1, will also be the Property of the NODEs established by the elements in this column $aArray[0][1] = "is_member_of" ;Title of column 2, will also be the Relationship of the items in column 1 to those in column 2 $Property = $aArray[0][0] ; Using 0,0 as property $Relationship = $aArray[0][1] ; using 0,1 as relationship ;creating a 2D array with semicolon as the delimiter between the NAME (The Property) ; IS_MEMBER_OF (The Relationship) ;(The Relationship) for this example, is a comma delimited list of the bands that the person IS_MEMBER_OF _ArrayAdd($aArray , "Jeff;Puscifer,APC,EODM,TBM,CarinaRound,Filter" , 0 , ";") _ArrayAdd($aArray , "MJK;Puscifer,APC,Tool" , 0 , ";") _ArrayAdd($aArray , "MattMc;Puscifer,EODM,TBM" , 0 , ";") _ArrayAdd($aArray , "Carina;Puscifer,CarinaRound" , 0 , ";") _ArrayAdd($aArray , "MatMit;Puscifer" , 0 , ";") _ArrayAdd($aArray , "Paul;Puscifer,Ministry" , 0 , ";") _ArrayAdd($aArray , "Mahsa;Puscifer,Omniflux" , 0 , ";") ;~ _ArrayDisplay($aArray) ; Mira! it is the array we just created $sOutStr = "Create" & @LF ;sOutStr will be the running catchall for the command we eventually want to run in Neo4j For $i = 1 to ubound($aArray) - 1 $sOutStr &= "(" & $aArray[$i][0] & ":Person {" & $Property & ": '" & $aArray[$i][0] & "'})," & @LF ; as we are looping through, use column one to create NODES that are PERSONS (this is assumed unique, if not you should get on that) _ArrayAdd($aBandMaster , stringsplit($aArray[$i][1] , "," , 2)) ; also while looping split all the comma delimited strings in column 2 and make one big list of bands stored in $aBandMaster ;~ _ArrayDisplay($aBandMaster , "BandMaster") Next $aBands = _ArrayUnique($aBandMaster) ; unique that master list and now we have a nice list of all of the bands from everyones list ;~ _ArrayDisplay($aBands , "unique bands") For $k = 1 to $aBands[0] $sOutStr &= "(" & $aBands[$k] & ":Band {" & $Property & ": '" & $aBands[$k] & "'})," & @LF ;roll through that list once creating NODES, one for each BAND Next For $i = 1 to ubound($aArray) - 1 $aPersonalBands = stringsplit($aArray[$i][1] , "," , 2) ; second loop, only this time we are building relationships, so we are working only off of the comma separated list for each individual For $k = 0 to ubound($aPersonalBands) - 1 $sOutStr &= "(" & $aArray[$i][0] & ")-[:" & $Relationship & "]->(" & $aPersonalBands[$k] & ")," & @LF ;Since those NODES were created above, we know their names and can build RELATIONSHIPS Next Next consolewrite(stringtrimright($sOutstr , 2) & @LF) ; This should be able to copy/paste directly into Neo4j ; match n optional match (n)-[r]-() return n, r; ; you need to run this afterward in Neo4j for the visualization  
       
    • By guinness
      Maybe other ideas will follow.


      using System; using System.Collections.Generic; namespace Rot13 { internal class Program { public static void Main() { Rot13 rot13 = new Rot13(); // Create a rotation 13 object. string encodedString = rot13.Encode("Rotate this string."); // Encode the string. Console.WriteLine("Encoded string: {0}", encodedString); string decodedString = rot13.Decode(encodedString); // Decode the rotated string. Console.WriteLine("Decoded string: {0}", decodedString); Console.WriteLine(""); // Create a new line. Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } } public class Rot13 { private Dictionary<char, char> rot13 = new Dictionary<char, char>(); /// <summary> /// Initialise the dictionary on a per object basis. I guess it could be made static as well?! /// </summary> public Rot13() { string lowLower = "abcdefghijklm", highLower = "nopqrstuvwxyz"; string lowUpper = "ABCDEFGHIJKLM", highUpper = "NOPQRSTUVWXYZ"; for (int i = 0; i < lowUpper.Length; i++) { // Convert a => n and A => N. rot13.Add(lowLower[i], highLower[i]); rot13.Add(highLower[i], lowLower[i]); // Convert n => a and N => A. rot13.Add(lowUpper[i], highUpper[i]); rot13.Add(highUpper[i], lowUpper[i]); } } /// <summary> /// Decode a Rot13 string. /// </summary> /// <param name="data">A Rot13 encoded string.</param> /// <returns>The original string.</returns> public string Decode(string data) { return Encode(data); } /// <summary> /// Encode a string to using Rot13. /// </summary> /// <param name="data">A string to be encoded.</param> /// <returns>An encoded string.</returns> public string Encode(string data) { char rotated = new char(); char[] array = data.ToCharArray(); for (int i = 0; i < array.Length; i++) { if (rot13.TryGetValue(array[i], out rotated)) { array[i] = rotated; } } return new string(array); } } }
    • By DeltaRocked
      Hope this helps someone.


      $string = 'Hello World' $string=Rot47($string) MsgBox(0, 'Encode', $string) $string=Rot47($string) MsgBox(0, 'Decode', $string) Func Rot47($input) Local $rotted, $i=1 While $i <= StringLen($input) $pos = StringMid($input, $i, 1) If Asc($pos) + 47 >= 127 And Asc($pos) > 32 And Asc($pos) < 127 Then $rotted &= Chr(Asc($pos) - 47) ElseIf Asc($pos) + 47 <= 126 And Asc($pos) > 32 And Asc($pos) < 127 Then $rotted &= Chr(Asc($pos) + 47) Else $rotted &= $pos EndIf $i += 1 WEnd Return $rotted EndFunc ;==>Rot47
×
×
  • Create New...