Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE PackageImports, StandaloneDeriving #-}
import Text.HTML.TagSoup
import Data.Maybe (fromJust)
import Data.Monoid
import Control.Monad
import Control.Applicative
import "mtl" Control.Monad.Trans
import Network.Curl
import Codec.Text.IConv
import Codec.Binary.UTF8.String (decodeString)
#![no_main]
extern crate libc;
use std::ptr;
use std::io::File;
use std::io::fs;
use std::io::BufferedReader;
use std::c_str::CString;
use libc::funcs::posix88::unistd::getuid;
#![no_main]
extern crate libc;
use std::ptr;
use std::io::File;
use std::io::fs;
use std::io::BufferedReader;
use std::c_str::CString;
use libc::funcs::posix88::unistd::getuid;
Starting with version 0.13 PCM audio support was introduced using
PortAudio library. The PortAudio2 version 19 or higher must be
installed on the system to use this feature
(http://portaudio.com/docs/v19-doxydocs/tutorial_start.html).
It's possible to use the library supplied with the emulator. For Unix-like
systems, the priority is given to the installed library. The library is
optional (only needed for PCM audio).
In version 0.16 it has become possible to export and import images in the most
common image formats. To save a copy of the screen, select the
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, TemplateHaskell #-}
import System.Locale
import Data.DateTime
import Data.Time
import Data.Monoid
import Data.Maybe (fromJust,isJust)
import Data.Functor.Identity
import Data.Text (Text)
import Data.Map.Lazy (Map)
import qualified Data.Map.Lazy as Map
@polachok
polachok / nginx.hs
Created August 8, 2015 01:36
I ♡ attoparsec
{-# LANGUAGE OverloadedStrings, DeriveDataTypeable, TemplateHaskell, DeriveGeneric #-}
import Data.Text(Text)
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import Data.Attoparsec.Text
import Control.Applicative
import Control.Monad
import Data.Aeson(encode,ToJSON)
import Data.Typeable(Typeable)
{-# LANGUAGE OverloadedStrings, DeriveDataTypeable, TemplateHaskell, DeriveGeneric, GADTs, ScopedTypeVariables, TypeFamilies, FlexibleContexts, MultiParamTypeClasses, DataKinds, FlexibleInstances, StandaloneDeriving #-}
import Data.Text(Text)
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import Data.Attoparsec.Text
import Control.Applicative
import Control.Monad
import Data.Aeson(encode,ToJSON)
import Data.Typeable(Typeable)
@polachok
polachok / ttt.py
Last active October 13, 2015 23:38
Read quota directly
from collections import namedtuple
import struct
Block = namedtuple('Block', 'next_free prev_free entries pad1 pad2')
Quota = namedtuple('Quota', 'id ihardlimit isoftlimit curinodes bhardlimit bsoftlimit curspace btime itime')
def read_quota(f):
return Quota._make(struct.unpack('<IIIIIIQQQ', f.read(48)))
def report_block(f, i):
@polachok
polachok / hyper-unix.rs
Created October 26, 2015 19:08
hyper over unix socket
use hyper::net::{NetworkStream,NetworkListener};
use hyper::{Server};
use hyper::server::Request;
use hyper::server::Response;
use hyper::server::Listening;
use hyper::net::Fresh;
use hyper;
use unix_socket::{UnixStream,UnixListener};
use std::io;
use std::path::Path;
@polachok
polachok / gist:ab0937985d57b0398ad8
Last active July 7, 2023 13:50
Building statically linked binaries with rust

glibc is not statically linkable (because reasons, mainly nss), so you have to link against another libc. Fortunately, rust developers made binary builds of std linked with musl libc available in beta and nightly channels. Which means that all you need is:

  • std linked with musl

    • http://static.rust-lang.org/dist/$(date -v -1d +'%Y-%m-%d')/rust-std-beta-x86_64-unknown-linux-musl.tar.gz
  • "normal" std for build scripts

    • http://static.rust-lang.org/dist/$(date -v -1d +'%Y-%m-%d')/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz