Skip to content

Instantly share code, notes, and snippets.

View antonxo's full-sized avatar
🏠
Working from home

Anton antonxo

🏠
Working from home
View GitHub Profile
@antonxo
antonxo / main.go
Created January 11, 2024 17:05
Verify Google Sign-in token in Golang
package main
import (
"context"
"fmt"
"google.golang.org/api/idtoken"
"log"
"net/http"
)
@antonxo
antonxo / CMakeLists.txt
Created December 19, 2019 07:19
CMakeLists.txt simple example (link executable with existing library)
cmake_minimum_required(VERSION 3.6)
project(ft_ls)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wextra -g")
link_directories(libft) # libraries
include_directories(inc libft/includes) # headers
set(SOURCE_FILES
inc/ft_ls.h
src/main.c
src/ft_ls.c
src/parse_input.c
@antonxo
antonxo / CMakeLists.txt
Created December 19, 2019 07:17
CMakeLists.txt example (compiles libraries on the go)
cmake_minimum_required(VERSION 3.6)
project(RT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wextra -DUNITY_INCLUDE_CONFIG_H")
# project sources
set(PARSER_SOURCES
inc/rt_prsr.h
src/parser/rt_prsr_peek.c
src/parser/rt_prsr_node.c
src/parser/rt_prsr_parse.c
src/parser/rt_prsr_alias.c
@antonxo
antonxo / prg.js
Created June 25, 2019 13:03
Post/Redirect/Get alternative with JS, clear POST data after refresh/back to avoid form resubmission.
//insert in your html with POST form
<script>
if (window.history.replaceState) {
window.history.replaceState(null, null, window.location.href);
}
</script>
@antonxo
antonxo / Ubuntu customization
Last active September 7, 2019 09:05
Ubuntu customization
- sudo apt remove apport apport-gtk - remove annoying "app crashed" reports that don't do anything;
- sudo apt install tlp tlp-rdw - extend battery life;
- gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize' - click to minimize dock app;
- sudo apt install gnome-tweak-tool - extend customization options;
- mini system monitor widget:
step 1: sudo apt-get install gir1.2-gtop-2.0 gir1.2-networkmanager-1.0 gir1.2-clutter-1.0
step 2: https://extensions.gnome.org/extension/120/system-monitor/ install
@antonxo
antonxo / keybindings.json
Last active August 11, 2021 14:23
Useful VS Code key bindings
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "alt+j",
"command": "editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
{
"key": "ctrl+d",
"command": "-editor.action.addSelectionToNextFindMatch",
@antonxo
antonxo / merge_sort.c
Last active May 13, 2019 15:06
[C] Sort a singly linked list using Mergesort with a custom callback function
t_lst *merge(t_lst *left, t_lst *right, int (*fp) (t_lst *l, t_lst *r))
{
t_lst *head;
head = NULL;
if (left == NULL)
return (right);
if (right == NULL)
return (left);
if (fp(left, right)) //callback sort function
@antonxo
antonxo / swap.c
Created May 12, 2019 20:45
[C] A function to swap two adjacent nodes in a doubly-linked list.
void ls_swap(t_list **a)
{
t_list *tmp;
tmp = (*a);
(*a) = (*a)->next;
tmp->next = (*a)->next;
if (tmp->next)
tmp->next->prev = tmp;
(*a)->prev = tmp->prev;