Skip to content

Instantly share code, notes, and snippets.

View PegasisForever's full-sized avatar

Pegasis PegasisForever

View GitHub Profile
@PegasisForever
PegasisForever / nextcloud-uploader.py
Last active July 25, 2023 22:08
upload files to nextcloud and get shareable link
#!/usr/bin/python3
import sys
import os
import requests
import time
from requests.auth import HTTPBasicAuth
import xml.etree.ElementTree as ET
function averageColor(a, b) {
let ar = parseInt(a.substr(0, 2), 16)
ar *= ar
let ag = parseInt(a.substr(2, 2), 16)
ag *= ag
let ab = parseInt(a.substr(4, 2), 16)
ab *= ab
let br = parseInt(b.substr(0, 2), 16)
br *= br
let bg = parseInt(b.substr(2, 2), 16)
@PegasisForever
PegasisForever / BetterAnimatedList.dart
Last active October 28, 2021 13:35
An animated list that can animate items automatically when data changes.
/*
* Copyright (c) Pegasis 2019. Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use, copy, modify,
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
* to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies
* or substantial portions of the Software.
*
@PegasisForever
PegasisForever / main.dart
Created November 23, 2019 17:52
Example usage of BetterAnimatedList
/*
* Copyright (c) Pegasis 2019. Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use, copy, modify,
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
* to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies
* or substantial portions of the Software.
*
#[macro_use]
extern crate log;
use rand::Rng;
use rand::prelude::ThreadRng;
use serde::Serialize;
use std::env;
use std::thread;
use std::time::SystemTime;
use reqwest::blocking::Client;
.tostr : To string
ANY → str($expr$)
@PegasisForever
PegasisForever / gist:d44c8f1c2a709a184cf5cd0988cde3f2
Created April 18, 2020 15:35
set default group and group permission
sudo find . -type d -exec chgrp webmanager {} +
sudo find . -type d -exec chmod g+s {} +
sudo find . -type d -exec setfacl -m default:group::rwx {} +
import java.util.*
class TreeNode(var `val`: Int) {
var left: TreeNode? = null
var right: TreeNode? = null
}
typealias LeetNode = TreeNode
fun LeetNode.toNode(): Node<Int> {
return Node(`val`).apply {
@PegasisForever
PegasisForever / Main.java
Last active January 14, 2020 03:42
An example of graph in java
import java.util.ArrayList;
//Definition of Node
class Node {
String name; // Name of the node
ArrayList<Node> connectedNodes = new ArrayList<>(); // All nodes connected to this node
// Constructor, called when use `new Node("name")`
Node(String n) {
name = n;
@PegasisForever
PegasisForever / add_srt.sh
Created December 24, 2019 07:12
a script that renders srt file to a mp4 file using ffmpeg
ffmpeg -i input.mp4 -filter:v subtitles=subtitle.srt -c:a copy -c:v libx264 -crf 22 -preset veryfast output.mp4