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 | |
""" | |
A simple python(3) bf interpreter. | |
First argument is .bf file with code to execute. | |
Optionally a file with input arguments can be specified as second argument. | |
""" | |
import sys | |
import re |
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 | |
""" | |
Iterate over each subset of any size (Power set) | |
""" | |
def power_set(A): | |
subsets = [] | |
N = len(A) | |
# iterate over each subset |
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
/* Code snippet for measuring bandwidth with harmonic mean */ | |
#define SKIPS 10 // initial measurement skips - skip the first slow-start values | |
// bandwidth metrics | |
double bandwidth = -1; // in MB/s | |
float total_bytes = 0; | |
int n = 0; // number of measure values | |
int skips = SKIPS; | |
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
/** | |
* Code snippet that tries to create a connection with the given wmiLocator object to the given namespace. | |
* @return An IJIDispatch object that can be used for WQL queries to the given namesapce of the target machine. | |
* @Exception In case the ConnectServer method could not be properly executed. | |
*/ | |
public IJIDispatch createNamespaceServer(IJIDispatch wmiLocator, String nameSpace, String ipAddress) throws Exception | |
{ | |
// create an instance of the WbemScripting.SWbemLocator object to talk to WMI on the target machine. | |
// namespace could be for instance "root\\cimv2" | |
JIVariant results[] = |
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
/* | |
* A simple client that opens a socket. | |
*/ | |
#include <stdio.h> | |
#include <sys/socket.h> | |
int main(int argc, char *argv[]) | |
{ | |
int sockfd; |
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
# Simple static header for update-motd framework | |
COLOR_GREEN="\033[0;32m" | |
# print personal static banner in green | |
printf "${COLOR_GREEN} | |
_____ .__ .__ .__ | |
_/ ____\|__| ______| |__ |__| | |
\ __\ | | / ___/| | \ | | | |
| | | | \___ \ | Y \| | |
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
<!-- Simple webpage for Django UI example test --> | |
<html> | |
<head> | |
</head> | |
<body> | |
<p id="test">Hello World!</p> | |
</body> | |
</html> |
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
#!/bin/bash | |
# A simple django project deployment script for jenkins | |
BUILD_ROOT="/srv/www/django/d_project/" | |
MNGR=${BUILD_ROOT}"manage.py" | |
# source python env | |
echo "Sourcing python env..." | |
source ${BUILD_ROOT}"py-env/bin/activate" | |
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 | |
""" | |
Using Fermat's little theorem to calculate nCk mod m, for k < m and m is prime | |
Two versions: | |
1. Pre-Compute factorials and multiplicative inverses in O(n*logn) --> later lookup in O(1) | |
2. Compute directly --> no lookup --> each time O(n) | |
""" |
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
#!/bin/bash | |
SENSITIVE_FILES="roles/ssh/templates/sshd_config.j2.enc" | |
if [ "$1" != "clean" ] && [ "$1" != "decrypt" ] | |
then | |
echo "only 'clean' or 'decrypt' are allowed" | |
exit 1 | |
fi |
OlderNewer