Skip to content

Instantly share code, notes, and snippets.

@Setitch
Setitch / rsabd.py
Last active August 29, 2015 14:14 — forked from ryancdotorg/rsabd.py
#!/usr/bin/env python
import sys
import gmpy
import curve25519
from struct import pack
from hashlib import sha256
from binascii import hexlify, unhexlify
#!/bin/bash
## Install ISPConfig3 on Ubuntu 16.04 64Bits
## Author: Nilton OS blog.linuxpro.com.br
## Updated: Seti the Dragon - chibi.pl
## old: http://blog.linuxpro.com.br/posts/instalando-ispconfig3-no-ubuntu-1404.html
## old: http://www.howtoforge.com/perfect-server-ubuntu-14.04-apache2-php-mysql-pureftpd-bind-dovecot-ispconfig-3-p2
##
## new: https://www.howtoforge.com/tutorial/perfect-server-ubuntu-16.04-with-apache-php-myqsl-pureftpd-bind-postfix-doveot-and-ispconfig/
apt-get update
c_default="\e[37m"
@Setitch
Setitch / CsExpression.g3
Created March 3, 2016 19:49 — forked from mlehmk/CsExpression.g3
ExpressionMaker
grammar CsExpression;
options {
language=CSharp3;
TokenLabelType=CommonToken;
output=AST;
ASTLabelType=CommonTree;
}
@lexer::namespace{ExpressionParser}
#!/bin/sh
# based on https://www.felix021.com/blog/read.php?2187 with some fixes to really compile the project
sudo apt install -y libssl-dev libev-dev libjansson-dev libmpdec-dev libmysqlclient-dev libcurl4-gnutls-dev libldap2-dev libgss-dev librtmp-dev libsasl2-dev
# librdkafka: 0.11.3+; DO NOT INSTALL BY APT: version too old (0.8.x);
# if you do, remove them by: sudo apt remove librdkafka1 librdkafka-dev
wget https://github.com/edenhill/librdkafka/archive/v0.11.3.tar.gz -O librdkafka-0.11.3.tar.gz
@Setitch
Setitch / auto-datatables
Last active December 25, 2022 08:10
Include file in scripts - and each table on page (if able) will be transformated into datatable. Usage example::: fetch('https://gist.githubusercontent.com/Setitch/82dfe9ccada7c1d8ca2bbb1c93081098/raw/db69b4da58ad3316941c4b7562ff97a7d299a90e/auto-datatables').then(success => { success.text().then((read) => { script = document.createElement('scri…
(function () {
/** Sources are MIT, they were generated by DataTables builder **/
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s
@Setitch
Setitch / time-attack-mitigator.ts
Created November 17, 2022 16:23
Time Attack Mittigator - function that exeutes the job, with minimum time needed for answer, even if the job finished earlier
/**
* This function will execute the job, but return the value from it when at least `timeout` amount of milliseconds passed
* @param {() => Promise<T>} job
* @param {number} timeout
* @returns {Promise<T>}
*/
export async function TimeAttackMitigator<T>(job: () => Promise<T>, timeout = 700): Promise<T> {
return new Promise<T>((resolve, reject) => {
let canResolve = false;
@Setitch
Setitch / bad-request.interceptor.ts
Created November 23, 2022 13:09
NestJS - class-valitdator interceptor returning more flattened answers
import { BadRequestException, CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
import { ValidationError } from 'class-validator';
import { catchError, Observable, throwError } from 'rxjs';
@Injectable()
export class BadRequestInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
return next
.handle()
@Setitch
Setitch / bad-request.interceptor.ts
Created November 24, 2022 13:42
BadRequest Interceptor for NodeJS to flatten (make easy script readable) validation errors from class-validator
import { BadRequestException, CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
import { ValidationError } from 'class-validator';
import { catchError, Observable, throwError } from 'rxjs';
@Injectable()
export class BadRequestInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
return next
.handle()
@Setitch
Setitch / to-array.transformer.decorator.ts
Created February 6, 2023 13:37
NestJS - Transformer for Query params to be transformed into array before validation of dto's (or undefined)
import { Transform } from 'class-transformer';
export const ToArray = () => {
const toPlain = Transform(
({value}) => {
return value;
},
{
toPlainOnly: true,
}
@Setitch
Setitch / to-integer.transformer.decorator.ts
Created February 6, 2023 13:43
NestJS - Transformer for Query params to be transformed into Integer before validation of dto's (or undefined)
import { Transform } from 'class-transformer';
export const ToInteger = () => {
const toPlain = Transform(
({value}) => {
return value;
},
{
toPlainOnly: true,
}