Skip to content

Instantly share code, notes, and snippets.

Avatar

Yo-An Lin c9s

View GitHub Profile
@c9s
c9s / maxapi.sh
Last active Oct 2, 2020
MAX Exchange API client in Bash
View maxapi.sh
#!/bin/bash
base_url="https://max-api.maicoin.com"
ts=$(date "+%s")
server_ts=$(curl -s $base_url/api/v2/timestamp)
offset=$(( $server_ts - $ts ))
function nonce()
{
View kubeconfig-dump
#!/bin/bash
set -e
##
# Usage:
#
# $0 [cluster name] [user name] [output dir]
##
usage()
@c9s
c9s / active.md
Created Jul 24, 2018 — forked from paulmillr/active.md
Most active GitHub users (by contributions). http://twitter.com/paulmillr
View active.md

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Tue, 06 Dec 2016 17:06:46 GMT till Wed, 06 Dec 2017 17:06:46 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
  .filter(user => user.followers > 1000)
View .gvimrc
" vim:fdm=marker:et:fdl=0:
"
" Author: Yo-An Lin <yoanlin93 {at} gmail.com>
" URL: http://c9s.blogspot.com/
"
" Font {{{
" set gfn=Dejavu\ Sans\ Mono\ 9
" set gfn=Andale\ Mono:h14
":set guifont=Screen15,\ 7x13,font\\,with\\,commas
if has('gui_mac')
@c9s
c9s / debian-8-opencv-gpu
Last active Sep 26, 2017
This script allows you to install Nvidia CUDA 8 and OpenCV with GPU support
View debian-8-opencv-gpu
#!/bin/bash
# update the base system packages
apt-get update && apt-get upgrade -y
# Update source list for cuda and python3.6
cat <<ENDLIST >> /etc/apt/sources.list
# non-free to nvidia-cuda-toolkit
deb http://ftp.de.debian.org/debian stretch non-free
deb http://ftp.de.debian.org/debian stretch contrib
View index.html
<!doctype html>
<html>
<head>
<title>Socket.IO chat</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
View chunk_migrate.php
<?php
public function migrate(Chunk $chunk, Shard $dstShard, array $schemas)
{
$shardId = $chunk->getShardId();
if ($dstShard->id === $shardId) {
throw new InvalidArgumentException("{$dstShard->id} == $shardId");
}
try {
View queryAPI.php
<?php
public function testRepoFetchColumn()
{
$this->assertResultSuccess(Book::create([ 'title' => 'Book 1' ]));
$this->assertResultSuccess(Book::create([ 'title' => 'Book 2' ]));
// create one book with duplicated title
$this->assertResultSuccess(Book::create([ 'title' => 'Book 2' ]));
View Sharding_OrderModel_loadByKeys.php
<?php
/**
* An alias for BaseRepo::loadByKeys
*/
protected static function loadByKeys(array $args, $byKeys = null)
{
if (static::SHARD_MAPPING_ID) {
return static::shards()->first(function(BaseRepo $repo, Shard $shard) use ($arg, $byKeys) {
return $repo->loadByKeys($args, $byKeys);
View AuthorBase.php
<?php
namespace AuthorBooks\Model;
require_once __DIR__ . '/AuthorSchemaProxy.php';
use Maghead\Schema\SchemaLoader;
use Maghead\Result;
use Maghead\Inflator;
use SQLBuilder\Bind;
use SQLBuilder\ArgumentArray;
use SQLBuilder\Universal\Query\InsertQuery;
use SQLBuilder\Driver\BaseDriver;
You can’t perform that action at this time.