Skip to content

Instantly share code, notes, and snippets.

View Voltra's full-sized avatar
🎯
Focusing

Voltra

🎯
Focusing
View GitHub Profile
@Voltra
Voltra / sender.c
Created June 11, 2020 20:19
C code sample
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "./sender.h"
#include "../macros.h"
#include "../utils.h"
#include "../tools/addr.h"
#include "../access.h"
@Voltra
Voltra / AuthController.js
Created June 11, 2020 20:24
Adonis code sample
"use strict";
const User = use("App/Models/User");
class AuthController {
static get defaultRoute(){
return "tab.search";
}
static get userRoute(){
@Voltra
Voltra / FormField.scss
Created June 11, 2020 20:34
SCSS Sample code
@use "~@scss/theme" as *;
@use "~@scss/mixins/margin" as *;
@use "~@scss/mixins/flex" as *;
@use "~@scss/mixins/border" as *;
@use "~@scss/mixins/colors" as *;
@use "~@scss/modules/error" as *;
$bwidth: 3px;
$radius: 1em;
@Voltra
Voltra / TapiCmsForm.vue
Created June 11, 2020 20:37
Vue sample code
<template>
<CmsForm
ref="form"
class="tap-form"
:title="title"
:cancelText="cancelText"
:submitText="submitText"
:canDelete="canDelete"
entityDesignator="ce taraud"
@cancel="onCancel"
@Voltra
Voltra / vscode.plugins.md
Last active September 15, 2021 16:51
Temp vscode config

Visual Studio Code

  • global

    • visual studio intellicode
    • live server
    • git lens -- git supercharged
    • bracket pair colorizer
    • remote - wsl
  • path intellisense

@Voltra
Voltra / mixins.scss
Last active December 30, 2021 09:37
Dark Mode mixin
@use "sass:selector";
@mixin darkMode($applySelf: false) {
$selector: &;
@if ($applySelf) {
@content;
}
@at-root {
@Voltra
Voltra / index.js
Created January 5, 2022 12:38
Magic lambdas in JS
const DeepProxy = require("proxy-deep")
const _ = new DeepProxy({}, {
_pushOp(op) {
},
get(target, path, receiver){
return this.nest(function() {});
},
apply(target, thisArg, [obj]){
@Voltra
Voltra / lenses.js
Created January 22, 2022 21:42
PoC of immutable state manipulation via simple lenses (and React integration for the lolz)
import { useState, useMemo, useCallback, Dispatch, SetStateAction } from "react";
type InitialState<S> = (() => S) | S;
type Nullable<T> = T|null|undefined;
type Lens<Store = unknown, Value = unknown> = (store: Nullable<Store>) => ({
get(): Nullable<Value>;
set(newValue: Nullable<Value>): Nullable<Store>;
@Voltra
Voltra / index.ts
Last active June 20, 2022 18:22
JS extension methods
export type ArrayPartitionResult<T> = [left: T[], right: T[]];
const partitionArr = function<T>(this: T[], predicate: (item: T, i: number, arr: T[]) => boolean): ArrayPartitionResult<T> {
return this.reduce((partitions: ArrayPartitionResult<T>, item: T, i: number): ArrayPartitionResult<T> => {
const partitionIndex = predicate(item, i, this) ? 0 : 1;
partitions[partitionIndex].push(item);
return partitions;
}, [[], []] as ArrayPartitionResult<T>);
};
@Voltra
Voltra / fp.ts
Created July 5, 2022 20:43
fp.ts
export interface Semigroup<T, Self> {
concat(b: Semigroup<T, Self>): Semigroup<T, Self>;
sconcat(b: Semigroup<T, Self>): Semigroup<T, Self>;
stimes(n: number): Semigroup<T, Self>;
}
const decorateSemigroup = <T, Self>(sg: Partial<Semigroup<T, Self>>): Semigroup<T, Self> => {
sg.stimes = function(this: Semigroup<T, Self>, n: number): Semigroup<T, Self> {
let ret = this;