sudo iptables -A INPUT -p tcp --dport $PORT -j ACCEPT
This file contains hidden or 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
| REMOTE_PORT=5432 | |
| LOCAL_PORT=5432 | |
| ssh -L $REMOTE_PORT:localhost:$LOCAL_PORT $REMOTE_HOST -N |
This file contains hidden or 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
| HOST_1="192.168.1.10" | |
| HOST_2="192.168.1.11" | |
| HOST_1(){ | |
| echo "HOST_1 config..." | |
| iptables -A INPUT -p tcp --dport 5432 -j ACCEPT | |
| } | |
| HOST_2(){ | |
| echo "HOST_2 config..." |
This file contains hidden or 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 python | |
| # Following the tutorial at: http://api.mongodb.com/python/current/tutorial.html# | |
| from pymongo import MongoClient | |
| # Client connection | |
| client = MongoClient('localhost', 27017) | |
| # DB Name | |
| db = client.test |
This file contains hidden or 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 set_pos(i, p, v): | |
| return i ^ 2**p if v else i - 2**p | |
| def get_pos(i, p): | |
| pos_b = 2**(p-1) | |
| res = ((i ^ ((2**9-1) ^ pos_b)) & pos_b) | |
| return 1 if res > 0 else 0 |
This file contains hidden or 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
| // From https://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format/4673436#4673436 | |
| if (!String.prototype.format) { | |
| String.prototype.format = function() { | |
| var args = arguments; | |
| return this.replace(/{(\d+)}/g, function(match, number) { | |
| return typeof args[number] != 'undefined' | |
| ? args[number] | |
| : match | |
| ; | |
| }); |
This file contains hidden or 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
| DB_HOST=$1 | |
| DB_PORT=$2 | |
| DB_NAME=$3 | |
| DB_USER=$4 | |
| DB_SUPERUSER=$5 | |
| psql -h $DB_HOST -p $DB_PORT -U $DB_SUPERUSER -c "ALTER DATABASE $DB_NAME OWNER TO $DB_USER;" | |
| for i in $(psql -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_SUPERUSER \ | |
| -c "select tablename from pg_tables where schemaname = 'public'"); do |
This file contains hidden or 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
| #include <stdio.h> | |
| int main(int argc, char** argv){ | |
| int* tmp = (int *) (argv - 1); | |
| printf("argc = %d;\n", argc); | |
| printf("memo = %d;\n", *tmp); | |
| return 0; | |
| } |
This file contains hidden or 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
| ## Core latex/pdflatex auxiliary files: | |
| *.aux | |
| *.lof | |
| *.log | |
| *.lot | |
| *.fls | |
| *.out | |
| *.toc | |
| *.fmt |
This file contains hidden or 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 | |
| PATH_TO_FIND="$1" | |
| TEXT_TO_FIND="$2" | |
| find $1 -type f | | |
| while read f; do | |
| if [ $(grep $2 "$f" | wc -l) -gt 0 ]; then | |
| echo $f | |
| else | |
| if [ $(echo "$f" | grep $2 | wc -l) -gt 0 ]; then | |
| echo $f |