Skip to content

Instantly share code, notes, and snippets.

View roodkcab's full-sized avatar

roodkcab roodkcab

View GitHub Profile
cmake_minimum_required(VERSION 3.16)
project(${PROJ})
set(CMAKE_CXX_STANDARD 20)
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable(${PROJ} main.cpp)
target_link_libraries( practice ${OpenCV_LIBS} )
#!/bin/bash
openssl genrsa -out rootkey.pem 2048
openssl req -x509 -new -key rootkey.pem -out root.crt
openssl genrsa -out clientkey.pem 2048
openssl req -new -key clientkey.pem -out client.csr
openssl x509 -req -in client.csr -CA root.crt -CAkey rootkey.pem -CAcreateserial -days 3650 -out client.crt
openssl genrsa -out serverkey.pem 2048
openssl req -new -key serverkey.pem -out server.csr
openssl x509 -req -in server.csr -CA root.crt -CAkey rootkey.pem -CAcreateserial -days 3650 -out server.crt
openssl pkcs12 -export -in client.crt -inkey clientkey.pem -out client.pkcs12
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include <resolv.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <openssl/ssl.h>
@roodkcab
roodkcab / evp_bytestokey.swift
Last active June 12, 2020 09:11
EVP_BytesToKey swif3
func evpBytesToKey(password:String, keyLen:Int, ivLen:Int) -> ([UInt8], [UInt8]) {
var m = [Data]()
guard let passwd = password.data(using: String.Encoding.utf8) else {
return ([], []);
}
while m.reduce(0, {$0 + $1.count}) < keyLen + ivLen {
let data = m.count > 0 ? m.last! + passwd : passwd
m.append(data.md5Digest())
}
let final = m.reduce(Data(), +)
@roodkcab
roodkcab / main.go
Last active June 3, 2016 15:20
sudolikeaboss
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>
int
StartApp(void) {
[NSAutoreleasePool new];
[NSApplication sharedApplication];
@roodkcab
roodkcab / redux-tag.html
Last active May 21, 2016 03:34
redux-tag
<!DOCTYPE html>
<html>
<head>
<title>Redux basic example</title>
<script src="https://npmcdn.com/jquery@2.2.4"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.1/immutable.js"></script>
<script src="https://npmcdn.com/redux@latest/dist/redux.min.js"></script>
</head>
<body>
<style>
@roodkcab
roodkcab / gist:f1757a7aa7ab8ec67483
Created May 27, 2015 15:39
UIWebView JSContext
- (void)observeJSContext
{
CFRunLoopRef runLoop = CFRunLoopGetCurrent();
// This is a idle mode of RunLoop, when UIScrollView scrolls, it jumps into "UITrackingRunLoopMode"
// and won't perform any cache task to keep a smooth scroll.
CFStringRef runLoopMode = kCFRunLoopDefaultMode;
CFRunLoopObserverRef observer = CFRunLoopObserverCreateWithHandler
(kCFAllocatorDefault, kCFRunLoopBeforeWaiting, true, 0, ^(CFRunLoopObserverRef observer, CFRunLoopActivity _) {
@roodkcab
roodkcab / rac_sms_send_btn
Last active August 29, 2015 14:09
发送短信验证码按钮点击倒数计时
send.rac_command = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
NSDate *start = [NSDate date];
[send setAttributedTitle:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%f s", 5.f]
attributes:@{
NSFontAttributeName:[UIFont fontWithName:@"STHeitiSC-Medium" size:16],
NSForegroundColorAttributeName:[UIColor blackColor]
}] forState:UIControlStateNormal];
return [send rac_liftSelector:@selector(setAttributedTitle:forState:)
withSignals:
[[[[RACSignal interval:1 onScheduler:[RACScheduler currentScheduler]]
@roodkcab
roodkcab / dagger_alarm_install
Created June 12, 2013 09:10
dagger_alarm_install.sh
#/bin/bash
if ! which git >/dev/null; then
sudo yum install git
fi
htname="alarm"
git clone https://github.com/wxkingstar/dagger.git $htname
cd $htname
rm -rf ./InstallDaggerEnvironment.sh ./app ./js ./css ./images ./system ./model ./install ./index.php ./config
git ls-files --deleted -z | git update-index --assume-unchanged -z --stdin
git submodule add https://github.com/shuoshi/dagger_alarm.git ./alarm