Skip to content

Instantly share code, notes, and snippets.

View msramalho's full-sized avatar
💻
Coding the Supertheory of Supereverything

Miguel Sozinho Ramalho msramalho

💻
Coding the Supertheory of Supereverything
View GitHub Profile
:-use_module(library(clpfd)).
sequencia(Seq, Custo, N):-
length(Seq, N),
domain(Seq, 1, 4),
automaton(
Seq, _, Seq,
[source(a), source(b), source(c), source(d), sink(a), sink(b), sink(c), sink(d)],
[
arc(a,2,b, [C+5,I+1]),
@msramalho
msramalho / plog_mt2_17_18_p5.pl
Last active January 9, 2018 10:45
rage PoC on the last exercise on the second 17/18 PLOG minitest - motivação: POC
:-use_module(library(clpfd)).
:-use_module(library(lists)).
:-use_module(library(between)).
% emparelhar homens e mulheres, respeitar o delta de diferença máxima de altura, maximizar pares,
% homem é sempre mais alto que mulher
optimal_gym_pairs(MenHeights, WomenHeights, Delta, Pairs):-
same_length(Matrix, MenHeights),
maplist(same_length(WomenHeights), Matrix),
@msramalho
msramalho / ltw_exam_2016_01_19_p3.html
Created January 16, 2018 16:25
Solution for question 3 of the LTW Exam (2016-01-19) - javascript and Ajax
<form id="register" action="register.php" method="post">
<input name="username" type="text">
<input name="password" type="password">
<input type="submit" value="Register">
</form>
<script>
"use strict";
// (a) When the password input loses focus, it is verified if it contains at least 8 characters with at least one of them being a symbol other than a letter, a number or an underscore. If that's not the case, the input's border should become red.
@msramalho
msramalho / miup-2015-b
Created October 11, 2018 18:03
There is a bug
#include <bits/stdc++.h>
using namespace std;
#define MK make_pair
#define PB push_back
#define ALL(v) (v).begin() , (v).end()
#define two(n) ( 1 << (n) )
#define contain(Set,i) ( (Set) & two(i) )
@msramalho
msramalho / Cryptography.java
Created January 13, 2020 22:59
Java Class to manage cryptography keys in Android Keystore using "AES/CBC/PKCS7Padding" - encrypt and decrypt strings
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
import android.util.Base64;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@msramalho
msramalho / README.md
Last active July 14, 2020 18:48
Luanch and reset local Neo4j database on Docker for Windows and Linux

Windows

launch

docker run --publish=7474:7474 --publish=7687:7687 --env NEO4J_AUTH=none --volume=$HOME/Documents/neo4j/data:/data --volume=$HOME/Documents/neo4j/logs:/logs --volume=$HOME/Documents/neo4j/conf:/conf neo4j

reset database

docker run --rm --volume=$HOME/Documents/neo4j/conf:/conf neo4j:4.0 dump-config
@msramalho
msramalho / download_tweet_replies.js
Last active November 16, 2022 22:06
Download all replies to a tweet in a browser, by continuously scrolling on the page, using JavaScript
/**
* Instructions:
* copy past this into a console on twitter.com, in a tweet's page.
* Then keep scrolling until the end of the page, a console.log will show you how many tweets you have saved
* 5 seconds after you stop scrolling or reach the end, a file will be downloaded with all the tweet's info
*/
let get_tweet = (e) => {
try {
let textInstances = e.querySelectorAll("div[dir='auto']");
@msramalho
msramalho / instructions.md
Last active November 7, 2024 09:18
How to get a Facebook long term (non-expiring) access token for a Page
@msramalho
msramalho / json_to_csv.py
Created May 18, 2022 12:52
Python script to convert a JSONfile with an array (or list of lines) into a CSV file
import json, csv, sys
#USAGE: python json_to_csv.py FILENAME.json
# filename to extract is 1st arg
# output file is appended with .csv
IN = sys.argv[1]
OUT = IN + ".csv"