Although Python programming language comes with many learning resources, you can find a lot of free audiobooks on Amazon.
You can try a free trial then you need to pay $14.95 a month after 30 days - cancel online anytime.
Is a blog about python programming language. You can see my work with python programming language, tutorials and news.
NameError: name 'sys' is not defined. Did you forget to import 'sys'?
$ pip install PyGobject
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
$ whereis sway
$ env/bin/pytest --sway=/usr/bin/sway
$ sudo env/bin/pytest --sway=/usr/bin/sway
mkdir rsconnect-python-001
cd rsconnect-python-001
pip install rsconnect-python --user
Collecting rsconnect-python
rsconnect add --account catafest --name catafest --token YOUR_TOKEN --secret YOUR_SECRET
Detected the following inputs:
name: COMMANDLINE
insecure: DEFAULT
account: COMMANDLINE
token: COMMANDLINE
secret: COMMANDLINE
Checking shinyapps.io credential... [OK]
Added shinyapps.io credential "catafest".
library(shiny)
# Definirea interfeței utilizatorului
ui <- fluidPage(
titlePanel("Aplicație Shiny Simplă"),
sidebarLayout(
sidebarPanel(
numericInput("num", "Introduceți un număr:", value = 1),
actionButton("goButton", "Generează")
),
mainPanel(
textOutput("rezultat")
)
)
)
# Definirea serverului
server <- function(input, output) {
observeEvent(input$goButton, {
num <- input$num
output$rezultat <- renderText({
paste("Numărul introdus este:", num)
})
})
}
# Crearea aplicației Shiny
shinyApp(ui, server)
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
# Creați o aplicație Dash
app = dash.Dash(__name__)
# Definiți aspectul și structura aplicației
app.layout = html.Div([
html.H1("Aplicație Dash Simplă"),
dcc.Graph(id='grafic'),
dcc.Input(id='input-numar', type='number', value=1),
html.Div(id='rezultat')
])
# Definiți funcția callback pentru actualizarea graficului
@app.callback(
Output('grafic', 'figure'),
Input('input-numar', 'value')
)
def actualizare_grafic(numar):
# Implementați logica de actualizare a graficului aici
# Exemplu simplu: Un grafic cu o linie dreaptă cu panta egală cu numărul introdus
import plotly.express as px
import pandas as pd
data = pd.DataFrame({'x': range(10), 'y': [numar * x for x in range(10)]})
fig = px.line(data, x='x', y='y', title='Graficul personalizat')
return fig
# Rulează aplicația
if __name__ == '__main__':
app.run_server(debug=True)
shiny::runApp("C:/PythonProjects/rsconnect-python-001/")
Listening on http://127.0.0.1:7036
>rsconnect deploy shiny . --name catafest --title test
[WARNING] 2023-09-01T22:28:10+0300 Can't determine entrypoint; defaulting to 'app'
Warning: Capturing the environment using 'pip freeze'.
Consider creating a requirements.txt file instead.
...
Task done: Stopping old instances
Application successfully deployed to https://catafest.shinyapps.io/test/
...
deploying - Starting instances
Task done: Stopping old instances
Application successfully deployed to https://catafest.shinyapps.io/rsconnect-python-001/
←[32;20m [OK]
←[0m←[0mSaving deployed information...←[0m←[32;20m [OK]
←[0m
[notice] A new release of pip is available: 23.1.2 -> 23.2.1
[notice] To update, run: /srv/connect/venv/bin/python3 -m pip install --upgrade pip
[2023-09-01T22:43:31.378864990+0000] Copying file manifest.json
←[31;20m [ERROR]: Application deployment failed with error: Unhandled Exception: Child Task 1332185768 error:
Unhandled Exception: 599
←[0mError: Application deployment failed with error: Unhandled Exception: Child Task 1332185768 error:
Unhandled Exception: 599
pip install capstone --user
Collecting capstone
Obtaining dependency information for capstone from https://files.pythonhosted.org/packages/d0/dd/b28df50316ca193
dd1275a4c47115a720796d
9e1501c1888c4bfa5dc2260/capstone-5.0.1-py3-none-win_amd64.whl.metadata
Downloading capstone-5.0.1-py3-none-win_amd64.whl.metadata (3.5 kB)
Downloading capstone-5.0.1-py3-none-win_amd64.whl (1.3 MB)
---------------------------------------- 1.3/1.3 MB 1.6 MB/s eta 0:00:00
Installing collected packages: capstone
Successfully installed capstone-5.0.1
pip install pefile --user
Collecting pefile
Downloading pefile-2023.2.7-py3-none-any.whl (71 kB)
---------------------------------------- 71.8/71.8 kB 564.7 kB/s eta 0:00:00
Installing collected packages: pefile
Successfully installed pefile-2023.2.7
format PE64 GUI 5.0
entry start
include 'INCLUDE\win64a.inc'
section '.text' code readable executable
start:
push rbp
invoke GetModuleHandle,0
invoke DialogBoxParam,rax,37,HWND_DESKTOP,DialogProc,0
invoke ExitProcess,0
proc DialogProc uses rbx rsi rdi,hWnd,wMsg,wParam,lParam
mov [hWnd],rcx
mov [wMsg],rdx
mov [wParam],r8
mov [lParam],r9
cmp [wMsg],WM_COMMAND
je wmcommand
cmp [wMsg],WM_CLOSE
je wmclose
cmp [wMsg],WM_SYSCOMMAND
je wmsyscommand
xor rax,rax
jmp finish
wmsyscommand:
cmp [wParam],SC_RESTORE
je sc_restore
invoke DefWindowProc,[hWnd],[wMsg],[wParam],[lParam]
ret
sc_restore:
invoke AnimateWindow,[hWnd],DWORD 1000,0x00040004 ;HERE IT IS
invoke ShowWindow,[hWnd],SW_RESTORE
mov rax,1
ret
wmcommand:
cmp [wParam],BN_CLICKED shl 16 + IDOK
jne processed
invoke ShowWindow,[hWnd],SW_MINIMIZE
ret
wmclose:
invoke EndDialog,[hWnd],0
processed:
mov rax,1
ret ; this no need and use cmp to get error
; cmp rax,0
; je show_error
; show_error:
; invoke GetLastError ;must call this first and save the result before doing anything else
; invoke wsprintf,...
; invoke MessageBox,...
finish:
ret
endp
section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'
import kernel,\
GetModuleHandle,'GetModuleHandleA',\
ExitProcess,'ExitProcess'
import user,\
DialogBoxParam,'DialogBoxParamA',\
CheckRadioButton,'CheckRadioButton',\
GetDlgItemText,'GetDlgItemTextA',\
IsDlgButtonChecked,'IsDlgButtonChecked',\
MessageBox,'MessageBoxA',\
DefWindowProc,'DefWindowProcA',\
EndDialog,'EndDialog',\
AnimateWindow,'AnimateWindow',\
ShowWindow,'ShowWindow'
section '.rsrc' resource data readable
directory RT_DIALOG,dialogs
resource dialogs,\
37,LANG_ENGLISH+SUBLANG_DEFAULT,demonstration
dialog demonstration,'Create message box',70,70,190,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
dialogitem 'BUTTON','OK',IDOK,85,150,45,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
enddialog
import pefile
from capstone import *
exe_file = 'test_001_no_err_imp.EXE'
pe = pefile.PE(exe_file)
# find text section
offset = False
for section in pe.sections:
if section.Name == b'.text\x00\x00\x00':
offset = section.VirtualAddress
codePtr = section.PointerToRawData
codeEndPtr = codePtr+section.SizeOfRawData
break
code = pe.get_memory_mapped_image()[codePtr:codeEndPtr]
# start disassembling text section
md = Cs(CS_ARCH_X86, CS_MODE_32)
md.detail = True
if offset:
for i in md.disasm(code, offset):
print('0x%x:\t%s\t%s' % (i.address, i.mnemonic, i.op_str))
python capstone_test_001.py
0x1000: push ebp
0x1001: dec eax
0x1002: sub esp, 0x20
0x1005: dec eax
0x1006: mov ecx, 0
0x100c: call dword ptr [0x105e]
0x1012: dec eax
0x1013: add esp, 0x20
0x1016: dec eax
0x1017: sub esp, 0x30
0x101a: dec eax
0x101b: mov ecx, eax
0x101d: dec eax
0x101e: mov edx, 0x25
0x1024: dec ecx
0x1025: mov eax, 0
0x102b: dec ecx
0x102c: mov ecx, 0x40105a
0x1032: dec eax
0x1033: mov dword ptr [esp + 0x20], 0
0x103b: call dword ptr [0x109f]
0x1041: dec eax
0x1042: add esp, 0x30
0x1045: dec eax
0x1046: sub esp, 0x20
0x1049: dec eax
0x104a: mov ecx, 0
0x1050: call dword ptr [0x1022]
0x1056: dec eax
0x1057: add esp, 0x20
0x105a: push ebp
0x105b: dec eax
0x105c: mov ebp, esp
0x105e: dec eax
0x105f: sub esp, 8
0x1062: push ebx
0x1063: push esi
0x1064: push edi
0x1065: dec eax
0x1066: mov dword ptr [ebp + 0x10], ecx
0x1069: dec eax
0x106a: mov dword ptr [ebp + 0x18], edx
0x106d: dec esp
0x106e: mov dword ptr [ebp + 0x20], eax
0x1071: dec esp
0x1072: mov dword ptr [ebp + 0x28], ecx
0x1075: dec eax
0x1076: cmp dword ptr [ebp + 0x18], 0x111
0x107d: je 0x1110
0x1083: dec eax
0x1084: cmp dword ptr [ebp + 0x18], 0x10
0x1088: je 0x1135
0x108e: dec eax
0x108f: cmp dword ptr [ebp + 0x18], 0x112
0x1096: je 0x10a0
0x1098: dec eax
0x1099: xor eax, eax
0x109b: jmp 0x115a
0x10a0: dec eax
0x10a1: cmp dword ptr [ebp + 0x20], 0xf120
0x10a8: je 0x10cd
0x10aa: dec eax
0x10ab: sub esp, 0x20
0x10ae: dec eax
0x10af: mov ecx, dword ptr [ebp + 0x10]
0x10b2: dec eax
0x10b3: mov edx, dword ptr [ebp + 0x18]
0x10b6: dec esp
0x10b7: mov eax, dword ptr [ebp + 0x20]
0x10ba: dec esp
0x10bb: mov ecx, dword ptr [ebp + 0x28]
0x10be: call dword ptr [0x1024]
0x10c4: dec eax
0x10c5: add esp, 0x20
0x10c8: pop edi
0x10c9: pop esi
0x10ca: pop ebx
0x10cb: leave
0x10cc: ret
0x10cd: dec eax
0x10ce: sub esp, 0x20
0x10d1: dec eax
0x10d2: mov ecx, dword ptr [ebp + 0x10]
0x10d5: mov edx, 0x3e8
0x10da: dec ecx
0x10db: mov eax, 0x40004
0x10e1: call dword ptr [0x1011]
0x10e7: dec eax
0x10e8: add esp, 0x20
0x10eb: dec eax
0x10ec: sub esp, 0x20
0x10ef: dec eax
0x10f0: mov ecx, dword ptr [ebp + 0x10]
0x10f3: dec eax
0x10f4: mov edx, 9
0x10fa: call dword ptr [0x1000]
0x1100: dec eax
0x1101: add esp, 0x20
0x1104: dec eax
0x1105: mov eax, 1
0x110b: pop edi
0x110c: pop esi
0x110d: pop ebx
0x110e: leave
0x110f: ret
0x1110: dec eax
0x1111: cmp dword ptr [ebp + 0x20], 1
0x1115: jne 0x114e
0x1117: dec eax
0x1118: sub esp, 0x20
0x111b: dec eax
0x111c: mov ecx, dword ptr [ebp + 0x10]
0x111f: dec eax
0x1120: mov edx, 6
0x1126: call dword ptr [0xfd4]
0x112c: dec eax
0x112d: add esp, 0x20
0x1130: pop edi
0x1131: pop esi
0x1132: pop ebx
0x1133: leave
0x1134: ret
0x1135: dec eax
0x1136: sub esp, 0x20
0x1139: dec eax
0x113a: mov ecx, dword ptr [ebp + 0x10]
0x113d: dec eax
0x113e: mov edx, 0
0x1144: call dword ptr [0xfa6]
0x114a: dec eax
0x114b: add esp, 0x20
0x114e: dec eax
0x114f: mov eax, 1
0x1155: pop edi
0x1156: pop esi
0x1157: pop ebx
0x1158: leave
0x1159: ret
0x115a: pop edi
0x115b: pop esi
0x115c: pop ebx
0x115d: leave
0x115e: ret
0x115f: add byte ptr [eax], al
0x1161: add byte ptr [eax], al
0x1163: add byte ptr [eax], al
0x1165: add byte ptr [eax], al
0x1167: add byte ptr [eax], al
0x1169: add byte ptr [eax], al
0x116b: add byte ptr [eax], al
0x116d: add byte ptr [eax], al
0x116f: add byte ptr [eax], al
0x1171: add byte ptr [eax], al
0x1173: add byte ptr [eax], al
0x1175: add byte ptr [eax], al
0x1177: add byte ptr [eax], al
0x1179: add byte ptr [eax], al
0x117b: add byte ptr [eax], al
0x117d: add byte ptr [eax], al
0x117f: add byte ptr [eax], al
0x1181: add byte ptr [eax], al
0x1183: add byte ptr [eax], al
0x1185: add byte ptr [eax], al
0x1187: add byte ptr [eax], al
0x1189: add byte ptr [eax], al
0x118b: add byte ptr [eax], al
0x118d: add byte ptr [eax], al
0x118f: add byte ptr [eax], al
0x1191: add byte ptr [eax], al
0x1193: add byte ptr [eax], al
0x1195: add byte ptr [eax], al
0x1197: add byte ptr [eax], al
0x1199: add byte ptr [eax], al
0x119b: add byte ptr [eax], al
0x119d: add byte ptr [eax], al
0x119f: add byte ptr [eax], al
0x11a1: add byte ptr [eax], al
0x11a3: add byte ptr [eax], al
0x11a5: add byte ptr [eax], al
0x11a7: add byte ptr [eax], al
0x11a9: add byte ptr [eax], al
0x11ab: add byte ptr [eax], al
0x11ad: add byte ptr [eax], al
0x11af: add byte ptr [eax], al
0x11b1: add byte ptr [eax], al
0x11b3: add byte ptr [eax], al
0x11b5: add byte ptr [eax], al
0x11b7: add byte ptr [eax], al
0x11b9: add byte ptr [eax], al
0x11bb: add byte ptr [eax], al
0x11bd: add byte ptr [eax], al
0x11bf: add byte ptr [eax], al
0x11c1: add byte ptr [eax], al
0x11c3: add byte ptr [eax], al
0x11c5: add byte ptr [eax], al
0x11c7: add byte ptr [eax], al
0x11c9: add byte ptr [eax], al
0x11cb: add byte ptr [eax], al
0x11cd: add byte ptr [eax], al
0x11cf: add byte ptr [eax], al
0x11d1: add byte ptr [eax], al
0x11d3: add byte ptr [eax], al
0x11d5: add byte ptr [eax], al
0x11d7: add byte ptr [eax], al
0x11d9: add byte ptr [eax], al
0x11db: add byte ptr [eax], al
0x11dd: add byte ptr [eax], al
0x11df: add byte ptr [eax], al
0x11e1: add byte ptr [eax], al
0x11e3: add byte ptr [eax], al
0x11e5: add byte ptr [eax], al
0x11e7: add byte ptr [eax], al
0x11e9: add byte ptr [eax], al
0x11eb: add byte ptr [eax], al
0x11ed: add byte ptr [eax], al
0x11ef: add byte ptr [eax], al
0x11f1: add byte ptr [eax], al
0x11f3: add byte ptr [eax], al
0x11f5: add byte ptr [eax], al
0x11f7: add byte ptr [eax], al
0x11f9: add byte ptr [eax], al
0x11fb: add byte ptr [eax], al
0x11fd: add byte ptr [eax], al
# clone repository and navigate to root directory
git clone https://github.com/roboflow/supervision.git
cd supervision
# setup python environment and activate it
python3 -m venv venv
source venv/bin/activate
# headless install
pip install -e "."
# desktop install
pip install -e ".[desktop]"
import numpy as np
import tensorflow as tf
import keras
from keras import layers
units = 64
tf.keras.layers.GRU(
units,
activation="tanh",
recurrent_activation="sigmoid",
use_bias=True,
kernel_initializer="glorot_uniform",
recurrent_initializer="orthogonal",
bias_initializer="zeros",
kernel_regularizer=None,
recurrent_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
kernel_constraint=None,
recurrent_constraint=None,
bias_constraint=None,
dropout=0.0,
recurrent_dropout=0.0,
return_sequences=False,
return_state=False,
go_backwards=False,
stateful=False,
unroll=False,
time_major=False,
reset_after=True,
)
inputs = tf.random.normal([32, 10, 8])
gru = tf.keras.layers.GRU(4)
output = gru(inputs)
print(output.shape)
gru = tf.keras.layers.GRU(4, return_sequences=True, return_state=True)
whole_sequence_output, final_state = gru(inputs)
print(whole_sequence_output.shape)
print(final_state.shape)
WARNING: The following packages were previously imported in this runtime:
[numpy]
You must restart the runtime in order to use newly installed versions.
# This is formatted as CUDA code
__global__ void cuda_hello(){
printf("Hello World from GPU!\n");
}
int main() {
cuda_hello<<<1,1>>>();
return 0;
}
%%sh
echo "List all running VM processes."
ps -ef
echo "Done"