Skip to content

Instantly share code, notes, and snippets.

@aragaer
aragaer / sock.c
Created September 20, 2018 17:23
setsockopt REUSEPORT
#include <netinet/ip.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
int main() {
int res;
@aragaer
aragaer / wall-changer.py
Last active October 24, 2018 08:55
wall-changer
#!/usr/bin/env python3
import argparse
import os
import random
import shlex
import subprocess
_DIR = os.path.expanduser('~/.wall-changer')
if not os.path.exists(_DIR):
#!/usr/bin/env python3
import sys
from glob import glob
from random import sample
import numpy as np
import tensorflow as tf
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
(with-open-file (*standard-output* "/dev/null" :direction :output
:if-exists :supersede)
(ql:quickload :trivial-gray-streams))
(defvar *heads* (list))
(defvar *tails* (list))
@aragaer
aragaer / prog.c
Last active October 22, 2017 21:13
#define _GNU_SOURCE
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#define CHUNK 4096
@aragaer
aragaer / my_json.py
Last active August 23, 2017 20:14
my_json
#!/usr/bin/env python3
import json
from io import StringIO
from json.decoder import JSONObject
from json.scanner import py_make_scanner
my_json='''{"ok":true,"result":[{"update_id":547677716,
@aragaer
aragaer / xmobar.hs
Created July 27, 2017 20:09
xmonad
Config {
font = "xft:Droid Sans Mono:size=9:bold:antialias=true"
bgColor = "#000000",
fgColor = "#ffffff",
position = Top,
lowerOnStart = True,
commands = [
Run CommandReader "~/Projects/pymodoro/pymodoro.py" "pomodoro"
,Run Kbd [("us", "US"), ("ru", "RU")]
,Run Date "%Y.%m.%d %H:%M:%S" "date" 10
@aragaer
aragaer / energy.py
Created April 2, 2017 13:35
MosEnergoSbyt
#!/usr/bin/env python3
from datetime import date
class tariff():
def __init__(self, costs, start_date, end_date):
self.costs = costs
self.start_date = start_date
self.end_date = end_date
import unittest
from water import water, local_min, solve
class LocalMinTest(unittest.TestCase):
def test_empty(self):
self.assertEqual(local_min([]), [])
def test_single(self):
#!/usr/bin/python
# -*- coding: utf-8 -*-
fromWordstat = open('wordstat.txt')
fromCampaign = open('campaign.txt')
result = open('result.txt', 'w')
fromCampaignList = list(fromCampaign)
for value_list in fromWordstat: