Skip to content

Instantly share code, notes, and snippets.

--- testdata_original_delete 2019-07-30 12:14:25.430923889 +0000
+++ testdata_original 2019-07-30 12:13:13.064253409 +0000
@@ -561,6 +561,8 @@
ansanotify:116/tcp
mcidas:112/tcp
gppitnp:103/tcp
+mpm-flags:44/tcp
+smtp:25/tcp
nimbusdb:48004/tcp
jvl-mactalk:47100/udp
--- testdata_thash_output_sorted 2019-07-30 07:56:15.926762046 +0000
+++ testdata_original 2019-07-30 07:57:44.266766721 +0000
@@ -114,6 +114,7 @@
adapt-sna:1365/tcp
adcp:7508/tcp
adi-gxp-srvprt:6769/tcp
+admind:3279/tcp
admind:8403/tcp
admins-lms:2692/tcp
adobeserver-1:1102/tcp
@ovidiucs
ovidiucs / gist:14c21dc23d7b48cb0f763f4c2e2d2105
Last active June 22, 2019 18:14
lldb debug for while loop in hashing program
(lldb)
Process 27249 stopped
* thread #1, name = 't_hash', stop reason = step over
frame #0: 0x00005555555554bc t_hash`h_search(hTable=0x0000555555559260, key="400") at myhash.c:134:30
131 else {
132 // looking for the key inside the next element of the linked list
133 char* keyAtNextValue = hTable->h_items[resultHash]->h_next->h_key;
-> 134 while( nextValue->h_next != NULL) {
135 fprintf(stderr, "Found a collision, traversing Linked list at address %p, key is: %s",
136 nextValue, nextValue);
@ovidiucs
ovidiucs / laterthiseveningcolor.txt
Created March 9, 2019 07:20
Later this evening color scheme
Name=Later This Evening
ColorForeground=#959595
ColorBackground=#222222
ColorCursor=#424242
ColorPalette=#2b2b2b;#d45a60;#afba67;#e5d289;#a0bad6;#c092d6;#91bfb7;#3c3d3d;
#454747;#d3232f;#aabb39;#e5be39;#6699d6;#ab53d6;#5fc0ae;#c1c2c2
type # concepts
BasicValue[T] = concept v
v.value is T
MinValue[T] = concept v
v is BasicValue[T]
v.min is T
MaxValue[T] = concept v
v is BasicValue[T]
v.max is T
'''
Requires paramiko >=1.8.0 (paramiko had an issue with multiprocessing prior
to this)
Example code showing how to use netmiko for multiprocessing. Create a
separate process for each ssh connection. Each subprocess executes a
'show version' command on the remote device. Use a multiprocessing.queue to
pass data from subprocess to parent process.
Only supports Python2
@ovidiucs
ovidiucs / paramiko-proxy.py
Last active October 12, 2023 16:53
Paramiko Connect via proxy
#!/usr/bin/env python
#-*- coding:utf8 -*-
# sources
# 1. https://gist.github.com/tell-k/4943359#file-paramiko_proxycommand_sample-py-L11
# 2. https://github.com/paramiko/paramiko/pull/97
# info: http://bitprophet.org/blog/2012/11/05/gateway-solutions/
# local -> proxy-server -> dest-server
# ~/.ssh/config
#
# Host proxy-server
@ovidiucs
ovidiucs / Class2.py
Last active August 29, 2015 14:21
Explaining Classes
class MyClass(object):
"""A simple class example"""
# Class OBJECTS support two kinds of operations
# 1. Attribute reference
# 2. Instantiation
i = 12345
def something(self):
print 'printing - hello world'
return "returning - Hi"
class User(UserMixin, db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(16), index=True, unique=True)
username = db.Column(db.String(16), index=True, unique=True)
password_hash = db.Column(db.String(64))
def set_password(self, password):
@ovidiucs
ovidiucs / subnetloop.py
Last active August 29, 2015 14:21
Subnet for loop for IPv4
units = [1 << (8*i) for i in range(3,-1,-1)]
def ip_to_int(ip):
return sum(int(byte) * unit for(byte,unit) in zip(ip.split('.'), units))
def int_to_ip(i):
return '.'.join(str((i/bit) & 0xff) for bit in units)
start_ip = '1.0.0.0'
end_ip = '1.0.0.255'