Skip to content

Instantly share code, notes, and snippets.

@mulatinho
mulatinho / csrfValidation.js
Last active December 5, 2018 00:29
csrfValidation - nodejs bypass csrf and get data from server
/*
* csrfValidation.js
*
* use:
* $ npm i cheerio
* $ node ./csrfValidation <hostname> (e.g. www.googleauth.com/csrfFormAuth)
*
* written by Alexandre Mulatinho
*
*/
@mulatinho
mulatinho / test-chai.js
Created November 4, 2017 21:22
test-chai.js
var app = require('../main.js');
var request = require('supertest');
var chai = require("chai");
describe('A list of tests', function() {
describe('#GET /questions', function() {
it('should get a list of questions', function(done) {
request(app) .get('/questions')
.end(function(err, res) {
expect(res.statusCode).to.equal(200);
@mulatinho
mulatinho / test-chai.js
Created November 4, 2017 21:21
test-chai.js
var app = require('../main.js');
var request = require('supertest');
var chai = require("chai");
describe('A list of tests', function() {
describe('#GET /questions', function() {
it('should get a list of questions', function(done) {
request(app) .get('/questions')
.end(function(err, res) {
expect(res.statusCode).to.equal(200);
@mulatinho
mulatinho / uploadToS3.js
Last active April 25, 2017 19:41
uploading to amazon S3 without AWS-SDK or any other module but native
/* Upload to Amazon S3 without AWS-SDK or other modules
* Alexandre Mulatinho <alex at mulatinho.net> 2016
*
* You will need to change:
* - YOUR_FILENAME_HERE
* - YOUR_BUCKET_HERE
* - AWS_SECRET_KEY_HERE
* - AWS_ACCESS_KEY_HERE */
var https = require("https");
@mulatinho
mulatinho / s3upload.sh
Last active October 26, 2016 12:59
upload files to S3 using shell script
#!/bin/bash
# amazon s3 upload file code
# written by Alexandre Mulatinho < alex @ mulatinho . net >
# Wed Oct 26 09:30:54 BRT 2016
# use -> ./s3upload.sh hostAmazon yourBucketName yourFilename
[ ! "$3" ] && echo "use: $0 <host> <bucket> <file>" && exit 1
dateNow="`TZ=Africa/Bumako date "+%a, %0e %b %Y %T %z"`"
host="$1"
@mulatinho
mulatinho / challenge001.sh
Last active August 25, 2016 20:11
challenge001.sh
#!/bin/bash
# https://alex.mulatinho.net/2016/08/17/desafio-shell-script-001/
# Alexandre Mulatinho - http://alex.mulatinho.net - 20160820
#
# run tests:
# $ ( TESTES=$(( (RANDOM % 20) + 1 )); echo $TESTES; \
# for i in `seq 1 $TESTES`; \
# do N=$(( (RANDOM % 5) + 1 )) ; echo -n "$N "; \
# for x in `seq 1 $N`; do DIA=$(( (RANDOM % 31) + 1)); echo -n "$DIA "; done; \
# echo; done; echo $(( (RANDOM % 12) +1 )) ) | ./challenge001.sh
initial - representa o valor inicial investido;
interest - a taxa de rendimento médio mensal;
months - o número de meses em que o investimento será realizado;
$ initial=50000; interest=1.00961; months=60; for i in `seq 1 $months`; do initial=`echo "scale=2; $initial * $interest"|bc`; printf "month %2d, r$ %12.2f\n" $i $initial; done
month 1, r$ 50480.50
month 2, r$ 50965.62
month 3, r$ 51455.40
month 4, r$ 51949.88
month 5, r$ 52449.12
@mulatinho
mulatinho / cpf.swift
Last active February 17, 2017 02:43
Validação de CPF no Swift
// algoritmo: res1 = sum(digits[0-9] * 10...2) % 11; res2 = sum(digits[0-10] * 11...2) % 11
// if (digit10 == res1 && digit11 && res2) { cpf valido }
func checkIfCPFisValid(obj: AnyObject?) -> Bool
{
var input: String = ""
if let object = obj as? UITextField {
input = object.text!
}
class AreUFuknWithMe {
let rake = 0.26;
var total: Double = 0;
let bills: [Double] = [ 1, 1.87, 2, 4.3, 6.57 ];
init() {
var x = 0;
for (; x<4; x++) {
println("Duh")
# source /etc/profile.d/32dev.sh
# export ARCH=i486
# source *info; wget -c $DOWNLOAD; sh *SlackBuild
# installpkg /tmp/OpenAL-1.16.0-i486-1_SBo.tgz