Skip to content

Instantly share code, notes, and snippets.

@S-YOU
S-YOU / Apple push notification
Created September 15, 2018 01:22 — forked from netoxico/Apple push notification
Apple push notification with python
#!/usr/bin/env python
import ssl
import json
import socket
import struct
import binascii
def send_push_message(token, payload):
# the certificate file generated from Provisioning Portal
@S-YOU
S-YOU / udp-loader.go
Created July 10, 2018 13:01 — forked from jtblin/udp-loader.go
UDP server performance optimisation
package main
import (
"crypto/rand"
"flag"
"log"
mrand "math/rand"
"net"
"os"
"os/signal"
@S-YOU
S-YOU / polymorphism_proxy.cr
Created June 21, 2018 11:24 — forked from fukaoi/polymorphism_proxy.cr
Crystal Polymorphism example code
class A
def disp : String
"call A"
end
end
class B
def disp : String
"call B"
end
@S-YOU
S-YOU / monomorphism_proxy.cr
Created June 21, 2018 11:24 — forked from fukaoi/monomorphism_proxy.cr
Crystal Monomorphism example code
abstract class Parent #同じシグネチャなので、abstractを通して、制約をつける
abstract def disp
end
class A < Parent
def disp : String
"call A"
end
end
module Indexable(T)
def threadpool_map(workers : Int = 8, chunk_size : Int? = nil, &func : T -> R) forall T, R
mutex = Thread::Mutex.new
cs = chunk_size || (self.size**0.5).ceil.to_i
Array(R).build(self.size) do |result|
index = 0
threads = Array.new(workers) {
Thread.new do
a = b = 0
loop do
@S-YOU
S-YOU / bfc.rb
Created May 3, 2018 19:02 — forked from makenowjust/bfc.rb
brainfuck compiler written in Ruby
EHSIZE = 0x34
PHSIZE = 0x20
PH_FILESZ_OFF = 0x10
PH_MEMSZ_OFF = 0x14
CODE_OFF = EHSIZE + PHSIZE
REAL_CODE_OFF = 0x08000000 + CODE_OFF
elf_header =
# e_ident[0] = 0x7F # EI_MAGIC1
# e_ident[1] = "E" # EI_MAGIC2
@S-YOU
S-YOU / defaultGatewayIoctlSet.c
Created March 10, 2018 15:42 — forked from lbuchy/defaultGatewayIoctlSet.c
Add default gateway route using ioctl
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <net/route.h>
#include <sys/types.h>
#include <sys/ioctl.h>
int main(char** args) {
int sockfd;
@S-YOU
S-YOU / hello.ll
Created January 7, 2018 06:47 — forked from ishikawa/hello.ll
LLVM 'Hello, World!' example from http://llvm.org/docs/LangRef.html#module-structure
; ModuleID = 'hello'
@.str = private constant [14 x i8] c"Hello, World!\00"
declare i32 @puts(i8* nocapture) nounwind
define i32 @main() {
%1 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0))
ret i32 0
}
# Based on http://matthiaseisen.com/articles/graphviz/
import graphviz as gv
styles = {
'graph': {
'label': 'Network Map',
'fontsize': '16',
'fontcolor': 'white',