Skip to content

Instantly share code, notes, and snippets.

@Nikaoto
Nikaoto / micro.js
Last active October 24, 2022 18:04
js micro framework
// Copied from https://news.ycombinator.com/item?id=23590750
const $t = document.createTextNode.bind(document);
const $e = (t = 'div', p = {},c = []) => {
let el = document.createElement(t);
Object.assign(el,p);
el.append(...c);
return el;
}
@Nikaoto
Nikaoto / resize-cover.sh
Last active April 6, 2019 15:53
Resize image to cover a 128x128 square ('128^>' resizes the larger side to 128)
convert image.jpg -resize '128^>' -extent 128x128 newimage.jpg
@Nikaoto
Nikaoto / createTableWithFK.sql
Created January 24, 2019 14:38
MariaDB foreign key example
create table certificates (
user_row_id int not null unique,
first_name varchar(40) not null,
last_name varchar(50) not null,
email varchar(50) not null,
birth_date date not null,
test_datetime datetime not null,
CONSTRAINT `fk_user_row_id` -- create fk constraint
foreign key (user_row_id) references users (id) -- define constraint
@Nikaoto
Nikaoto / stoneBird.js
Last active July 27, 2020 09:28
Remove every tweet, retweet & like
setInterval(function() {
// Remove retweets
for (let e of document.querySelectorAll('[data-testid="unretweet"')) {
e.click();
// Click undo retweet popup
for (let u of document.querySelectorAll('div[data-testid="unretweetConfirm"')) {
u.click();
}
// Remove tweet div
e.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(e);
@Nikaoto
Nikaoto / CircleTransformation.java
Created July 8, 2017 13:39
A custom Tranformation for picasso which takes a rectangular drawable and its width & height and returns a circular one. Scales smoothly to the view size.
package com.example
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import com.squareup.picasso.Transformation;
@Nikaoto
Nikaoto / CopyBytes.kt
Last active July 27, 2020 09:31
A function that copies data from input to output (in Kotlin and Java)
//A Kotlin object (singleton) that handles the copying with mulitple different arguments
object CopyBytes {
@Throws(IOException::class)
fun copy(input: InputStream, output: OutputStream) {
//Creating byte array
val buffer = ByteArray(1024)
var length = input.read(buffer)
//Transferring data