Skip to content

Instantly share code, notes, and snippets.

View audinue's full-sized avatar

Audi Nugraha audinue

  • Surabaya, Jawa Timur, Indonesia
View GitHub Profile
.range {
position: relative;
height: 24px;
display: flex;
flex-direction: column;
justify-content: center;
cursor: default;
user-select: none;
}
.range:before {
<?php
$file = 'path-to-file';
$size = filesize($file);
$start = 0;
$end = $size - 1;
if (preg_match('/bytes=(\d+)-(\d*)/i', $_SERVER['HTTP_RANGE'] ?? '', $matches)) {
$start = $matches[1];
if (!empty($matches[2])) {
$end = $matches[2];
}
#include <windows.h>
void main() {
SendMessage(0xFFFF, 0x112, 0xF170, 2);
}
@audinue
audinue / build.cmd
Created March 24, 2024 11:31
Echo server & client in C.
@echo off
tcc echo_server.c
tcc echo_client.c
var neighbors = [
[ 0, 1, 0],
[ 1, 0, 0],
[ 0, -1, 0],
[-1, 0, 0],
[ 0, 0, 1],
[ 0, 0, -1]
]
var cornerTopLeftFront = [-0.5, 0.5, 0.5]
@audinue
audinue / test.js
Created November 30, 2023 17:30
Keyed diff
let { Window } = require('./happy-dom')
let window = new Window()
let document = window.document
test(
'No change',
['A', 'B', 'C', 'D'],
['A', 'B', 'C', 'D']
)
[
{
"id": "1",
"title": "Post A",
"category": {
"id": "1",
"name": "Category A"
},
"comments": [
{
@audinue
audinue / index.coffee
Created October 8, 2023 01:12
PUG + Stylus + CoffeeScript server
port = 3000
express = require 'express'
serveStatic = require 'serve-static'
serveIndex = require 'serve-index'
router = require './router'
express()
.use router
.use serveStatic('.')
.use serveIndex('.')
@audinue
audinue / kvstore.php
Last active September 25, 2023 00:05
<?php
function kvstore ($file, $init = NULL) {
static $stores = [];
$store = @$stores[$file];
if (!$store) {
$prev = @file_get_contents($file);
if (!$prev) {
if ($init) {
$prev = json_encode((object) $init());

database

Simple flat file NoSQL database.

initialize a database

$db = database('blog.json');