Skip to content

Instantly share code, notes, and snippets.

View Vicfred's full-sized avatar
:octocat:
I like mathemagic and computering

Vicfred Vicfred

:octocat:
I like mathemagic and computering
View GitHub Profile
@Vicfred
Vicfred / zig.md
Last active June 26, 2023 02:39
zig tricks

read int

const std = @import("std");

pub fn main() !void {
    const stdout = std.io.getStdOut();
    const reader = std.io.getStdIn().reader();

    var buffer: [1024]u8 = undefined;
 while (try reader.readUntilDelimiterOrEof(&buffer, '\n')) |line| {
@Vicfred
Vicfred / screenshot_lock_wallpaper.md
Last active September 15, 2024 03:55
screenshot_lock_wallpaper

ss.sh

#!/bin/bash
scrot '/tmp/%F_%T_$wx$h.png' -e 'xclip -selection clipboard -target image/png -i $f' -s

add this to awesome rc.lua to globalkeys variable

awful.key({ }, "Print", function () awful.util.spawn("/home/vicfred/.misato/ss.sh") end),

lock.sh

@Vicfred
Vicfred / pelican.md
Created January 30, 2023 05:03
pelican static site
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install pelican
pip freeze > requirements.txt
git init
@Vicfred
Vicfred / rc.lua
Last active August 29, 2022 08:03
awesome
-- If LuaRocks is installed, make sure that packages installed through it are
-- found (e.g. lgi). If LuaRocks is not installed, do nothing.
pcall(require, "luarocks.loader")
-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
@Vicfred
Vicfred / allstrings.cpp
Created August 1, 2022 03:12
allstrings.cpp
set<string> valid{"a", "b", "c", "?"};
for(const auto& i : valid) {
for(const auto& j : valid) {
for(const auto& k : valid) {
for(const auto& l : valid) {
for(const auto& m : valid) {
for(const auto& n : valid) {
for(const auto& o : valid) {
string str = i + j + k + l + m + n + o;
good.insert(str);
@Vicfred
Vicfred / coins.cpp
Created April 3, 2022 03:23
3 coins
#include <random>
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
cout.precision(15);
random_device rd;
@Vicfred
Vicfred / e.cpp
Last active March 3, 2022 19:07
e
#include <iostream>
#include <cmath>
using namespace std;
long long factorial(int x) {
long long result = 1LL;
for(int i = 1; i <= x; ++i) {
result = result * i;
}
@Vicfred
Vicfred / puffy.moe.conf
Created September 27, 2021 00:22
django + uwsgi + nginx + postgresql
# /etc/nginx/sites-available/puffy.moe.conf
server {
listen 80;
server_name puffy.moe www.puffy.moe;
error_log /var/log/nginx/puffy.moe.error.log;
access_log off;
location / {
include uwsgi_params;
@Vicfred
Vicfred / prompt.sh
Last active September 20, 2021 00:14
bash prompt
# User specific aliases and functions
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi
# Gentoo (/etc/bash/bashrc)
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1