This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define connection and name of database/collection for storing data | |
try{ | |
$mongo = new Mongo(); | |
$db = $mongo->myfirstdb; | |
$collection = $db->samples; | |
}catch(MongoConnectionException $check){ | |
die('Database connection failed!'. $check->getMessage()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Initialize connection | |
try{ | |
$mongo = New Mongo(); | |
$db = $mongo->test; | |
$collection = $db->logs; | |
; | |
} catch (MongoConnectionException $check){ | |
die ('Error msg: '. $check->getMessage()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
import hashlib | |
algorithms = dict( | |
md5 = lambda s: hashlib.md5(s).hexdigest(), | |
sha1 = lambda s: hashlib.sha1(s).hexdigest(), | |
sha256 = lambda s: hashlib.sha256(s).hexdigest(), | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: client.o server.o | |
client.o: client-beta.c poruke.h | |
gcc client-beta.c -o client | |
server.o: server-beta.c | |
gcc server-beta.c -o server | |
clean: | |
rm server-beta.c server.exe client-beta.c client.exe poruke.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Extract RSA keys in separate files | |
""" | |
Example of usage: | |
1. Generate your RSA keys | |
# openssl genrsa 2048 > mykeys.key | |
2. Read keys in human way and save it to a new .txt file | |
# openssl rsa -in mykeys.key -noout -text | |
3. Exclude keys in separate files with rsa-keys.py script | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.0 | |
import hashlib | |
import sys | |
algorithm = dict( | |
sha256 = lambda x: hashlib.sha256(x).hexdigest() | |
) | |
def usage(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Backup your packages list | |
# Get a packages list | |
dpkg --get-selections > ~/Package.list | |
# Copy list of repositories | |
sudo cp /etc/apt/sources.list ~/sources.list | |
# Export repo keys | |
sudo apt-key exportall > ~/Repo.keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Time: /bin/date | |
Login: users | awk '{print $1}' | |
Architecture: uname -m | |
Kernel version: uname -v -r | |
Processor: cat /proc/cpuinfo | grep \"name\" | cut -d : -f2 | uniq | |
Operating system: cat /etc/*-release | grep \"PRETTY_NAME\" | cut -d \"=\" -f2 | uniq | |
Interfaces: ip link show | grep 'eth\|wlan' | awk '{print $1,$2}' | |
IP addresses: ip a | grep 'eth\|wlan' | awk '{print $1,$2}' | |
Transmitted: /sbin/ifconfig eth0 | grep 'TX bytes' | awk '{print $7,$8}' | |
Recieved: /sbin/ifconfig eth0 | grep 'RX bytes' | awk '{print $3,$4}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gcd(a,b): # Define function with two parameters | |
while b != 0: # Run loop till 'b' value is 0 | |
if a > b: # 'a' value must be larger than 'b' | |
r = a % b # Remainder value | |
a = b # Assign 'b' to 'a' | |
b = r # Asign remainder value to 'b' | |
return a # Return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import json | |
# Define url you wanna fetch | |
url = "http://api.openweathermap.org/data/2.5/find?q=London&units=metric" | |
# Fetch url | |
response = urllib.urlopen(url) | |
# Load url response to json |
OlderNewer