Skip to content

Instantly share code, notes, and snippets.

View PegasisForever's full-sized avatar

Pegasis PegasisForever

View GitHub Profile
@PegasisForever
PegasisForever / AES.kt
Created November 29, 2019 07:36
an AES utility
package modes.server
import java.security.MessageDigest
import javax.crypto.Cipher
import javax.crypto.spec.SecretKeySpec
object AES {
private val encryptCipher: Cipher
private val decryptCipher: Cipher
@PegasisForever
PegasisForever / bitcoin_notifyer.python
Created December 5, 2019 12:03
Create a beep sound when bitcoin price drops
import requests
import winsound
def get_latest_crypto_price():
response = requests.get('https://api.coinmarketcap.com/v1/ticker/bitcoin')
response_json = response.json()
return float(response_json[0]['price_usd'])
last_price = 100000
while True:
@PegasisForever
PegasisForever / script.sh
Created December 18, 2019 04:50
A script to enable MacOS 10.15 Catalina run inside VirturalBox
VBoxManage modifyvm "MacOS Catalina" --cpuid-set 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "MacOS Catalina" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "MacOS Catalina" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "MacOS Catalina" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "MacOS Catalina" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "MacOS Catalina" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
@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
@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;
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 / 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 {} +
.tostr : To string
ANY → str($expr$)
#[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;
@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.
*