Skip to content

Instantly share code, notes, and snippets.

View kran's full-sized avatar
🌴
On vacation

Chao’s kran

🌴
On vacation
View GitHub Profile
@kran
kran / ethers.nashorn.js
Last active December 16, 2024 06:21
ethers.nashorn.js
/**
* <dependency>
* <groupId>org.bouncycastle</groupId>
* <artifactId>bcprov-jdk18on</artifactId>
* <version>1.79</version>
* </dependency>
*/
(function() {
const version = "6.13.1";
const WordSize = 32;
@kran
kran / Doge.java
Last active January 4, 2025 13:35
a little helper, setting up a cozy HTTP server framework that handles requests, manages routes
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import java.io.*;
import java.net.InetSocketAddress;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@kran
kran / Duck.java
Last active December 20, 2024 06:01
apache dbutils wrapper
import org.apache.commons.dbutils.*;
import org.apache.commons.dbutils.handlers.*;
import javax.sql.DataSource;
import java.math.BigInteger;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import java.util.AbstractMap.SimpleEntry;
import java.util.function.Function;
@kran
kran / blogger-forx.xml
Last active April 20, 2022 21:08
blogger theme ported from typecho theme (forx)
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:b="http://www.google.com/2005/gml/b" xmlns:data="http://www.google.com/2005/gml/data" xmlns:expr="http://www.google.com/2005/gml/expr">
&lt;!--<head>--&gt;&lt;head&gt;
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<meta name="renderer" content="webkit" />
<b:include data="blog" name="all-head-content"/>
@kran
kran / gridly.css
Created September 2, 2014 07:28
css for postach
@import url('http://fonts.useso.com/css?family=Droid+Sans:400,700|Vollkorn:400italic');
/**
* Page styles
*/
/*---------------------------------------------------
LESS Elements 0.9.1
---------------------------------------------------
A set of useful LESS mixins
More info at: http://lesselements.com
MODIFIED BY: Brandon Brown
<?php namespace Tmb;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Validation\Validator;
class BaseModel extends Eloquent
{
/**
* Error message bag
// answer to http://weibo.com/1915548291/z2UtyzuvQ
// see also http://www.cnblogs.com/baiyanhuang/archive/2012/11/11/2764914.html
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <fstream>
#include <iostream>
@kran
kran / theme.html
Created January 6, 2014 15:30
postach.io theme
<!DOCTYPE html>
<html lang="en-US" prefix="og: http://ogp.me/ns#">
<head>
<meta charset="utf-8">
<title>{% if is_home %}{{ site.author }}{% elif is_post %}{{ post.title }}{% elif is_link %}{{ link.title }}{% elif is_page %}{{ page.title }}{% endif %} | {{ site.name }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
@kran
kran / macvim.vim
Created October 28, 2013 12:37
macvim.vim
" MacVim colorscheme
"
" Maintainer: Bjorn Winckler <[email protected]>
" Last Change: 2008 May 9
"
" This is the default MacVim color scheme. It supports both light and dark
" backgrounds (see :h 'background').
"
@kran
kran / lua-resty-router.lua
Last active April 30, 2017 00:37
router for openresty, dev state
local ngx = require"ngx"
local setmetatable = setmetatable
local insert = table.insert
local pairs = pairs
local ipairs = ipairs
local type = type
local strlen = string.len
local substr = string.sub
local pp = require'prettyprint'
local match = string.match