Skip to content

Instantly share code, notes, and snippets.

@jekamax
jekamax / OOMarkdown.bas
Last active Apr 6, 2020
Macro allow using of markdown syntax while writing in LibreOffice or OpenOffice
View OOMarkdown.bas
'*** Markdown formatter for Libre(open)Office ****
' (pre-alpha-demo)
' Author: Jeka twoweeksgame@gmail.com
' License: No any warranties blah blah blah...
' Send me real postcard if you Like to use it
'
' Features: format headers verbatim blocks and formulas
' according to Markdown syntax
'
' Install: Open Tools->Macros->Organize Macros->LibreOffice Basic
@thisismitch
thisismitch / haproxy.cfg
Last active Apr 6, 2020
Let's Encrypt Auto-Renewal script for HAProxy
View haproxy.cfg
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
View initial.py
class GMM:
""" Gaussian Mixture Model
Parameters
-----------
k: int , number of gaussian distributions
seed: int, will be randomly set if None
max_iter: int, number of iterations to run algorithm, default: 200
View course_2_assessment_3.py
# 1. The dictionary Junior shows a schedule for a junior year semester.
# The key is the course name and the value is the number of credits.
# Find the total number of credits taken this semester and assign it to the variable credits.
# Do not hardcode this – use dictionary accumulation!
Junior = {'SI 206':4, 'SI 310':4, 'BL 300':3, 'TO 313':3, 'BCOM 350':1, 'MO 300':3}
credits = 0
for v in Junior.values():
credits += v
print(credits)
View VMware Workstation 15.x.x serial key
Serial Keys:
FU512-2DG1H-M85QZ-U7Z5T-PY8ZD
CU3MA-2LG1N-48EGQ-9GNGZ-QG0UD
GV7N2-DQZ00-4897Y-27ZNX-NV0TD
YZ718-4REEQ-08DHQ-JNYQC-ZQRD0
GZ3N0-6CX0L-H80UP-FPM59-NKAD4
YY31H-6EYEJ-480VZ-VXXZC-QF2E0
ZG51K-25FE1-H81ZP-95XGT-WV2C0
VG30H-2AX11-H88FQ-CQXGZ-M6AY4
@vlucas
vlucas / encryption.js
Last active Apr 6, 2020
Stronger Encryption and Decryption in Node.js
View encryption.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@jarek-przygodzki
jarek-przygodzki / debug-jvm-in-docker.md
Last active Apr 6, 2020
Debugging any JVM in a Docker container
View debug-jvm-in-docker.md
# docker run
-e "JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" \
-p 5005:5005

# docker-compose
    environment:
      - "JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
    ports:
      -  5005:5005
@micjabbour
micjabbour / main.cpp
Last active Apr 6, 2020
C++ WinAPI - get first physical drive serial number
View main.cpp
#include <windows.h>
#include <memory>
#include <string>
//returns the serial number of the first physical drive in a std::string or an empty std::string in case of failure
//based on http://codexpert.ro/blog/2013/10/26/get-physical-drive-serial-number-part-1/
std::string getFirstHddSerialNumber() {
//get a handle to the first physical drive
HANDLE h = CreateFileW(L"\\\\.\\PhysicalDrive0", 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if(h == INVALID_HANDLE_VALUE) return {};
@kshailen
kshailen / Connecting_postgress_RDS_from_local_via_bastion.md
Last active Apr 6, 2020
Ways to connect to postgress RDS instance from bastion host and from local host
View Connecting_postgress_RDS_from_local_via_bastion.md

When it comes to databases and AWS VPC, best practice is to place your database in private subnet. By definition, private subnet in AWS is not reachable from the Internet because no Internet gateway is attached to private subnet. This is the way you protect your data. This kind of configuration is good for security but bad for data management.

How can you easily access and manage your secured data?

basic_RDS_bastion_architecture

There are two basic ways to acees it.

  1. Access postgres RDS from bastion host. There are following requirements for this.
@cutiko
cutiko / LoginActivity.java
Last active Apr 6, 2020
How to customize firebase-ui-auth for Android
View LoginActivity.java
public class LoginActivity extends AppCompatActivity {
private static final int RC_SIGN_IN = 343;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
You can’t perform that action at this time.