Skip to content

Instantly share code, notes, and snippets.

View osa1's full-sized avatar

Ömer Sinan Ağacan osa1

View GitHub Profile
@osa1
osa1 / demo.c
Last active March 26, 2025 19:07
ncurses alt, ctrl etc. key events
// It turns out people don't really know how to handle Alt+ch, or F[1, 12] keys
// etc. in ncurses apps. Even StackOverflow is full of wrong answers and ideas.
// The key idea is to skip ncurses' key handling and read stuff from the stdin
// buffer manually. Here's a demo. Run this and start typing. ESC to exit.
//
// To compile:
//
// $ gcc demo.c -o demo -lncurses -std=gnu11
#include <ncurses.h>
@osa1
osa1 / lib.rs
Last active September 30, 2016 15:56
mod macros;
#[macro_use]
pub mod reply;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
}
@osa1
osa1 / dataflow.hs
Last active October 10, 2016 19:41
monotone framework
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ViewPatterns #-}
-- | Definition of a lattice, as described in section 4.2.
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
typedef struct CursorCursorProd_struct {
char *field0;
char *field1;
} CursorCursorProd;
@osa1
osa1 / gist:f3585ddab933d15d62d370f8dc4bb91b
Last active February 5, 2019 11:04
vim configure params
# vim
./configure --with-features=huge \
--enable-gui=qt \
--prefix=/home/omer \
--enable-pythoninterp \
--enable-python3interp \
--enable-rubyinterp \
--enable-perlinterp \
--with-python-config-dir=/usr/lib64/python2.7/config \
--with-python3-config-dir=/usr/lib64/python3.4/config-3.4m/
@osa1
osa1 / events.hs
Last active November 1, 2016 14:43
{-# OPTIONS_GHC -Wall #-}
-- Idea: A good runtime system makes event-based systems easier to implement.
--------------------------------------------------------------------------------
import Control.Concurrent (threadDelay)
import qualified Control.Concurrent.Async as A
import Control.Concurrent.MVar (MVar, newEmptyMVar, putMVar, takeMVar)
import Control.Monad (unless, void)
#include <stdint.h>
#include <stdio.h>
// Most strictly aligned component has alignment 1, so all fields should be
// alignment by 1
struct S1
{
uint8_t f1;
uint8_t f2;
};
@osa1
osa1 / isp.js
Created December 17, 2016 09:46
JS that my ISP injects to my requests
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
try {
var title = document.title.toLowerCase();
var domain = window.location.hostname.toLowerCase();
var referrer = document.referrer.toLowerCase();
var useragent = navigator.userAgent.toLowerCase();
title = domain + title + referrer;
title += title + " " + window.self.document.all[0];
@osa1
osa1 / extensible-effects.hs
Last active February 12, 2017 09:06
fine-grained IO effects using extensible-effects and freer
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
module GetlinePutline where
@osa1
osa1 / stateful.hs
Last active February 13, 2017 20:20
Running state effect using IORef
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeOperators #-}
module Lib where
import Control.Monad.Freer
import Control.Monad.Freer.Internal