Skip to content

Instantly share code, notes, and snippets.

View gnull's full-sized avatar
💭
I moved from Github to Sourcehut and suggest you do the same

Ivan Oleynikov gnull

💭
I moved from Github to Sourcehut and suggest you do the same
View GitHub Profile
@gnull
gnull / stm32f10x_crc.c
Created April 12, 2015 20:04
Microcontrollers Course Homework
#define bytes_to_long(a,b,c,d) ( ((d) << 24) | ((c) << 16) | ((b) << 8) | (a) )
/**
* @brief Computes the 32-bit CRC of a given buffer of data word(32-bit).
* @param pBuffer: pointer to the buffer containing the data to be computed
* @param BufferLength: length of the buffer to be computed
* @retval 32-bit CRC
*/
uint32_t CRC_CalcBlockCRC(uint8_t pBuffer[], uint32_t BufferLength)
@gnull
gnull / queue.c
Created April 14, 2015 12:44
MC homework #2
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#ifndef QUEUE_MAXLEN
#define QUEUE_MAXLEN 0x10
#endif
#define E_EMPTY -1
#define E_FULL -2
@gnull
gnull / farm.p6
Created June 5, 2016 20:08
Perl6 segfaulting code.
#!/usr/bin/env perl6
use v6;
use JSON::Tiny;
sub MAIN(Str $exploitd = './exploitd/', Str $config-file = './farm.json') {
my $config = from-json slurp $config-file;
my $flagre = $config<flag_regex> || '\w+';
@gnull
gnull / trace.txt
Created June 5, 2016 21:14
Perl6 stack trace
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x756fb)[0xb72c96fb]
/lib/i386-linux-gnu/libc.so.6(+0x76440)[0xb72ca440]
/lib/i386-linux-gnu/libc.so.6(closedir+0x28)[0xb72f41f8]
/home/gnull/prefix/lib/libmoar.so(MVM_dir_close+0x41)[0xb74b9321]
/home/gnull/prefix/lib/libmoar.so(MVM_interp_run+0xa9d4)[0xb747e6a4]
/home/gnull/prefix/lib/libmoar.so(+0xac0d2)[0xb74980d2]
/home/gnull/prefix/lib/libmoar.so(+0x17e6f0)[0xb756a6f0]
/lib/i386-linux-gnu/libpthread.so.0(+0x6a0d)[0xb71fda0d]
/lib/i386-linux-gnu/libc.so.6(clone+0x5e)[0xb732dece]
@gnull
gnull / MaybeSum.hs
Created February 14, 2017 19:47
Sum of two Maybe values in CLaSH
module Maybe where
import Data.Functor
import Control.Applicative
import CLaSH.Prelude
sol :: Maybe Int -> Maybe Int -> Maybe Int
sol a b = (+) <$> a <*> b
@gnull
gnull / lazy-async.hs
Created April 19, 2017 17:00
Haskell lazy async
import Control.Concurrent.Async
import Control.Monad
sites = ["http://www.google.com",
"http://www.bing.com",
"http://www.yahoo.com",
"http://www.wikipedia.com/wiki/Spade",
"http://www.wikipedia.com/wiki/Shovel"]
printRepeat :: String -> IO [String]
@gnull
gnull / lolcat.hs
Created May 27, 2017 13:34 — forked from shiroginne/lolcat.hs
simple lolcat powered by haskell
import Data.Word
freq = 0.3
spread = 8.0
unbase :: Integral int => int -> Word8 -> Word8 -> Word8 -> int
unbase base r g b = (fi r*base+fi g)*base+fi b
where fi = fromIntegral
-- | Approximate a 24-bit Rgb colour with a colour in the xterm256 6x6x6 colour cube, returning its index.
#!/bin/sh -efux
# This file works only with IPv4. The variables in capitals are the parameters
# you can adjust to your needs
# The name of the modem network interface as shown in `ip a`
INTERFACE=wwp0s20f0u3i12
# The access point address. This is the same value as the one you typically
# have in the internet settings of your mobile phone.
#!/bin/sh -xefu
# https://stackoverflow.com/questions/61385594/create-pdf-where-each-page-is-a-merge-of-image-and-a-svg-file
# https://stackoverflow.com/questions/501723/overlay-one-pdf-or-ps-file-on-top-of-another
# https://superuser.com/questions/381125/how-do-i-convert-an-svg-to-a-pdf-on-linux
# http://notesofaprogrammer.blogspot.com/2017/03/converting-svg-to-pdf-on-linux-command.html
mkdir -p res/ready
for i in $(seq 1 242); do