This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class bit_set { | |
private: | |
uint8_t *data; | |
public: | |
explicit bit_set(int size) { | |
// (size + 7) / 8 is ceiling of size / 8 | |
data = new uint8_t[(size + 7) / 8](); | |
} | |
void set(int index) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple FFMPEG scripts I use to convert videos or audios | |
# The ones with h264_nvenc codec only work with NVidia graphic cards. You also need to install the drives to use them | |
# The hevc_nvenc codec is pretty fast but the output file size is terrible. So I won't include that in. (Special thanks to Erfan Mojibi) | |
# The libx265 provides better quality to file size. So we can increase the crf in it (source: https://trac.ffmpeg.org/wiki/Encode/H.265#ConstantRateFactorCRF) | |
# The tag is provided by @alirezahabib | |
# Simple convert from webm to mp4. ACC audio codec at 128kb/s. Change 24 to change the quality (higher is worse) | |
ffmpeg -i in.webm -r 10 -vf "scale=-2:720" -c:v h264_nvenc -cq:v 24 -profile:v high -c:a aac -b:a 128k -strict experimental out.mp4 | |
ffmpeg -i in.webm -r 10 -vf "scale=-2:720" -c:v libx264 -crf 24 -c:a aac -b:a 128k -strict experimental out.mp4 | |
ffmpeg -i in.webm -r 10 -vf "scale=-2:720" -c:v libx265 -crf 28 -c:a aac -b:a 128k -tag:v hvc1 -strict experimental out.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util | |
import ( | |
"encoding/csv" | |
"fmt" | |
"io" | |
"reflect" | |
) | |
// StreamCsv converts an array of an struct to csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::net::{TcpStream}; | |
use std::io::{Write, BufReader, BufRead}; | |
/// Connects to api.ipify.org and returns your IP address | |
/// Note that this method does not use any proxies | |
fn get_ip() -> Result<String, String> { | |
// at first, try to to connect to ipify | |
match TcpStream::connect("api.ipify.org:80") { | |
Ok(mut stream) => { | |
// create the request header; This is a const value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A simple script to generate C testcases based on inputs for Quera | |
# Place your input files in a folder called "raw-input" with the format of *.txt | |
# Then run the program with the code filename as the argument and then this script will generate | |
# the answers based on your program | |
# Compile the program | |
gcc -O3 -o program "$1" -lm # I include the math library as well | |
# Create the output folders if needed | |
mkdir -p "in" "out" | |
# Loop all test cases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Maze example: | |
1e11111111111 | |
1*0*0*0*0*0*1 | |
1110111111101 | |
1*1*0*1*0*1*1 | |
1011111010101 | |
1*0*0*0*1*0*1 | |
11111111111e1 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
javac %1 | |
set /A Counter=1 | |
set ClassName=%1 | |
set ClassName=%ClassName:~0,-5% | |
:loop | |
set "i=in%Counter%.txt" | |
set "o=out%Counter%.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Quera Scoreboard Remover | |
// @version 2 | |
// @description Remove the scoreboard from quera | |
// @author Hirbod Behnam | |
// @match https://quera.ir/course/assignments/* | |
// @grant none | |
// ==/UserScript== | |
(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <string.h> | |
static uint32_t rotl(uint32_t a, uint32_t b) { | |
return (a << b) | (a >> (32 - b)); | |
} | |
static void qr(uint32_t x[], uint32_t a, uint32_t b, uint32_t c, uint32_t d) { | |
x[a] = x[a] + x[b]; | |
x[d] = rotl(x[d] ^ x[a], 16); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name PDF Dark Mode | |
// @namespace http://tampermonkey.net/ | |
// @version 1 | |
// @description A tampermonkey script to enable dark mode even on local files. | |
// @author Hirbod Behnam | |
// @match *://*/*.pdf | |
// @grant none | |
// ==/UserScript== |