This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <libarchive/archive.h> | |
#include <libarchive/archive_entry.h> | |
#include <stdio.h> | |
int main(int argc, char** argv) { | |
struct archive* a = archive_read_new(); | |
struct archive_entry* e; | |
int ret, i; | |
char buf[1024]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <archive.h> | |
#include <archive_entry.h> | |
#define LOG(...) { printf(__VA_ARGS__); puts(""); } | |
int main() { | |
const char* file_name = "test.pkg"; | |
struct archive* a = archive_read_new(); | |
archive_read_support_filter_gzip(a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <limits.h> | |
unsigned char block2[4096] = { | |
0xc1, 0x6f, 0x9c, 0xaa, 0xb5, 0x0d, 0xb2, 0x20, | |
0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
highest = 0 | |
highest_score = 0 | |
Dir["/proc/*"].each() do |pidstr| | |
next if not pidstr =~ /^\/proc\/([0-9]+)$/ | |
pid = $1.to_i | |
score = IO.readlines("/proc/#{pid}/oom_score").join().to_i | |
if score > highest_score |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
int global_var = 0; | |
int main() { | |
int fd = open("/proc/self/mem", O_RDWR); | |
if(!fd) { | |
printf("can't open /proc/self/mem as O_RDWR\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#define NAMESPACE_ENDIANCONVERSION_BEGIN namespace EndianConversion { | |
#define NAMESPACE_ENDIANCONVERSION_END } | |
#include <stdint.h> | |
// __BYTE_ORDER__ is a gcc macro | |
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | |
#define __LESWAP(n, x) x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.ByteString.Lazy as BL | |
import Data.Binary.Get | |
import Data.Word | |
import Data.Bits | |
import Data.Char | |
readArray :: Get [Word8] | |
readArray = do | |
empty <- isEmpty | |
if empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.ByteString.Lazy as BL | |
import Data.Binary.Get | |
import Data.Word | |
readArray :: Get [Word8] | |
readArray = do | |
empty <- isEmpty | |
if empty | |
then return [] | |
else do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns s512.core | |
(:require [clojure.java.io :as io]) | |
(:gen-class)) | |
(set! *warn-on-reflection* true) | |
(defn data-file [] | |
(io/file "out.bin")) | |
(defn data-stream [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
checkd :: [Int] -> Int -> Int | |
checkd [] n = n | |
checkd (prime:primes) n = | |
if (elem n primes || n `mod` prime == 0) then | |
prime | |
else | |
checkd primes n | |
preplist :: [Int] -> Int -> [Int] | |
preplist curlist n = filter (\ x -> x < (n `div` 2 + 1)) curlist |
NewerOlder