Skip to content

Instantly share code, notes, and snippets.

View un4ckn0wl3z's full-sized avatar
🖕
An idiot admires complexity; a genius admires simplicity

Anuwat Khongchuai un4ckn0wl3z

🖕
An idiot admires complexity; a genius admires simplicity
View GitHub Profile
@magro
magro / HelloMorphia.java
Created December 16, 2010 00:01
A hello world that shows how to use morphia with an immutable id type
import java.net.UnknownHostException;
import org.apache.commons.lang.builder.ToStringBuilder;
import com.google.code.morphia.Datastore;
import com.google.code.morphia.Morphia;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
import com.google.code.morphia.converters.SimpleValueConverter;
import com.google.code.morphia.converters.TypeConverter;
@NtRaiseHardError
NtRaiseHardError / ClipboardMonitor.c
Last active May 31, 2020 07:13
PoC code to demonstrate clipboard monitoring in Windows using an event-based listener.
// PoC code to demonstrate clipboard monitoring in Windows
// using an event-based listener.
#include <stdio.h>
#include <Windows.h>
#define CLASS_NAME L"MY_CLASS"
#define WINDOW_NAME L"MY_WINDOW"
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
HANDLE hClipData = NULL;
@noemi-dresden
noemi-dresden / docker-compose.yml
Created March 28, 2019 19:44
Complete compose file for monitoring spark on prometheus
version: "3.1"
services:
spark-master:
image: bde2020/spark-master:2.4.0-hadoop2.7
container_name: spark-master
ports:
- "8080:8080"
- "7077:7077"
environment:
- INIT_DAEMON_STEP=setup_spark
@ernsheong
ernsheong / ropc_kong.md
Last active August 25, 2021 07:37
Implementing OAuth2 Resource Owner Password Credentials Grant with Kong

Implementing OAuth2 Resource Owner Password Credentials Grant with Kong

The documentation is okay, but it has some holes, and I had to read it many many times and play with the API myself to "get it" in terms of implementation. So here is a guide that I hope will help someone along the way.

DISCLAIMER: This is by no means the canonical or the most secure way to do this. Below are my findings upon my reading of the docs and the spec. But I might be wrong, very wrong.

This gist is meant to complement the documentation in https://getkong.org/plugins/oauth2-authentication/.

The Resource Owner Password Credentials Grant makes sense if we want to authenticate users who are using our trusted 1st party applications of our own service. (However, you might not want to trust your JavaScript SPA with your refresh token, and maybe you need to store that refresh token in the server on behalf of the SPA if you are paranoid about security. Disclaimer: I am not a security expert)

redirect traffic incoming on a specific port to a different IP address / another server

2.2.2.2:4000 -> 1.1.1.1:3000

Solution

iptables -t nat -A PREROUTING -p tcp --dport 4000 -j DNAT --to-destination 1.1.1.1:3000
iptables -t nat -A POSTROUTING -p tcp -d 2.2.2.2 --dport 4000 -j SNAT --to-source 1.1.1.1
iptables -t nat -A POSTROUTING -j MASQUERADE
@iMartyn
iMartyn / mini-port-forward.bash
Created December 20, 2017 17:34
Port-forward minikube ports to localhost ports
#!/bin/bash
MINIKUBE_IP=$(minikube ip)
MINIKUBE_KEY_LOCATION=${HOME}/.minikube/machines/minikube/id_rsa
STARTING_PORT=8080
CURRENT_PORT=${STARTING_PORT}
for servicename in $*; do
HIGH_PORT=$(kubectl get svc ${servicename} -o custom-columns=':spec.ports[*].nodePort' | tail -n1)
if echo $HIGH_PORT | grep -q ,; then
@nisar1
nisar1 / downloading an entire web site with wget.txt
Created March 25, 2014 06:11
downloading an entire web site with wget
$ wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains website.org \
--no-parent \
www.website.org/tutorials/html/
@djad442
djad442 / state.dart
Created November 29, 2020 12:55
use of state mixin in getx
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:dio/dio.dart';
void main() {
runApp(GetMaterialApp(
initialRoute: '/home',
getPages: [
GetPage(
name: '/home',
@isaurssaurav
isaurssaurav / minikubeportforwarding
Last active January 18, 2023 18:04
Port forwarding of VM (minikube) to host machine
The ssh way
Assuming that you have ssh on your ubuntu box.
Minikube user: docker password: tcuser
First run kubectl proxy & to expose the dashboard on http://localhost:8001
Then expose the dashboard using ssh's port forwarding, executing:
ssh -R 30000:127.0.0.1:8001 $USER@192.168.0.20
@ceme
ceme / bash_curl_loop
Last active January 19, 2023 13:07
bash curl loop
while true; do sleep 1; curl http://www.google.com; echo -e '\n\n\n\n'$(date);done