Skip to content

Instantly share code, notes, and snippets.

@rbw
rbw / pscan.php
Last active April 23, 2023 14:16
Non-blocking tcp scanner in PHP
<?php
// Optional mappings
$port_service = array(
20 => "ftp-data",
21 => "ftp",
22 => "ssh",
23 => "telnet",
24 => "priv-mail",
25 => "smtp",
var TaskMessages = Class.create();
TaskMessages.prototype = {
initialize: function(sysId) {
this.sysId = sysId;
this.exclude = [
'calendar_stc', 'sys_class_name', 'calendar_duration', 'sys_domain,location',
'business_duration', 'reassignment_count', 'upon_reject',
];
this._generateHistory();
},
@rbw
rbw / _GOMP_barrier
Created September 24, 2018 23:08
_GOMP_barrier issue
$ CC=/usr/local/bin/gcc-8 python3 setup.py build_ext --inplace && python3 -m nanopy
running build_ext
building 'nanopy.work' extension
creating build
creating build/temp.macosx-10.6-intel-3.6
creating build/temp.macosx-10.6-intel-3.6/nanopy
gcc-8 -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c nanopy/work.c -o build/temp.macosx-10.6-intel-3.6/nanopy/work.o -fopenmp
gcc-8: warning: x86_64 conflicts with i386 (arch flags ignored)
nanopy/work.c: In function 'generate':
@rbw
rbw / nanopy_clang.txt
Last active September 24, 2018 17:01
Nanopy clang compile error
[/tmp/nanopy]$ CC=/usr/bin/clang python3 setup.py build_ext --enable-gpu --inplace
running build_ext
building 'nanopy.work' extension
/usr/bin/clang -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-sXpGnM/python3.6-3.6.3=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DHAVE_CL_CL_H=1 -I/usr/include/python3.6m -c nanopy/work.c -o build/temp.linux-x86_64-3.6/nanopy/work.o
clang: warning: argument unused during compilation: '-specs=/usr/share/dpkg/no-pie-compile.specs' [-Wunused-command-line-argument]
nanopy/work.c:15:31: warning: missing terminating '"' character [-Winvalid-pp-token]
const char *opencl_program = R"%%%(
^
nanopy/work.c:15:30: error: use of undeclared identifier 'R'
@rbw
rbw / part_of_day.py
Last active October 17, 2022 22:44
Get part of day (morning, afternoon, evening, night) in Python3.6+
#!/usr/bin/env python3
def get_part_of_day(h):
return (
"morning"
if 5 <= h <= 11
else "afternoon"
if 12 <= h <= 17
else "evening"