Skip to content

Instantly share code, notes, and snippets.

@jsn
jsn / ashton.c
Created February 25, 2017 15:13
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define MAX_STRING 100001
static char s[MAX_STRING] ;
static unsigned sl ;
#include <stdio.h>
#ifndef NBITS
#define NBITS 42
#endif
static unsigned long long states[NBITS + 1][7][2 * NBITS] ;
/* step s r */
static inline int next_s(int s, int b) {
#include <stdio.h>
#include <stdlib.h>
#define N 26
#define LEN (N * 2 + 1)
static int s[LEN] ;
static void print_s(void) {
for (int i = 0; i < LEN; i ++)
@jsn
jsn / subs.rb
Created July 9, 2017 20:25
Mokum reciprocative autosubscriber
#! /usr/bin/env ruby
require 'uri'
require 'net/http'
require 'json'
class Mukom < Net::HTTP
BASE = URI.parse 'https://mokum.place/api/v1/'
attr_accessor :api_key
@jsn
jsn / s.cr
Created October 19, 2017 18:20
crystal lang *Server bug
# compile with --release, connect with netcat: nc localhost 12300, try multiple times
require "socket"
TCPServer.new(12300, reuse_port: true).accept.puts "hi"
@jsn
jsn / ws.cr
Created October 22, 2017 12:47
require "http/server"
handler = HTTP::WebSocketHandler.new do |session|
session.on_message do |message|
puts "Received #{message}"
pp session.@ws.send message
end
end
HTTP::Server.new(8081, [handler, HTTP::LogHandler.new]).listen
@jsn
jsn / a.cr
Created October 30, 2017 18:37
def check(l)
abba = false
l.scan(/([a-z])([a-z])\2\1/) do |rm|
next if $1 == $2
return false if rm.pre_match =~ /\[[^\]]*$/
abba = true
end
!!abba
end
jason@jsn cr $ head -n 1000 z.cr z2.cr
==> z.cr <==
class Z
def self.f
puts "in class method"
return Time.now
end
@@x : Time = f()
jason@jsn cr $ crystal z2.cr
in class method for x
2018-02-09 03:17:03 +03:00
before
in class method for y
in class
out of class
after
jason@jsn cr $ head -n 1000 z.cr z2.cr
==> z.cr <==
jason@jsn cr $ head -n1000 z.cr z2.cr
==> z.cr <==
def q
puts "in q"
1
end
Q = q()
class Z