Skip to content

Instantly share code, notes, and snippets.

@googya
googya / linear_regression.exs
Created February 13, 2022 10:15
Programming Machine Learnng: Pizza predict
Mix.install([
{:nx, "~> 0.1.0"},
])
input = """
13 26 9 44
2 14 6 23
14 20 3 28
23 25 9 60
13 24 8 42
1 12 2 5
# migrating from https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git/git.plugin.zsh
# Aliases
alias g='git'
#compdef g=git
alias gst='git status'
#compdef _git gst=git-status
alias gd='git diff'
#compdef _git gd=git-diff
alias gdc='git diff --cached'
CREATE TABLE `a` (
`id` INT(100) UNSIGNED NOT NULL AUTO_INCREMENT,
`userid` VARCHAR(11) DEFAULT NULL,
`subject` VARCHAR(11) DEFAULT NULL,
`score` INT(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=INNODB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
INSERT INTO `a` (`id`, `userid`, `subject`, `score`)
VALUES
const fs = require('fs');
function check_result() {
return fs.existsSync('foo.txt');
}
function* infiniteSequence() {
let num = 1
while (true) {
yield num
@googya
googya / snippets.md
Last active August 30, 2020 05:57
code snippets

sending mail using sendcloud

response = RestClient.post "http://api.sendcloud.net/apiv2/mail/send", :attachments => File.new('all.sql','rb'),:apiUser => 'metalist',:apiKey => 'key',:from => "leslie_wen@qq.com",:fromName => "noname",:to => "leslie_wen@qq.com",:subject => "users assets",:html => 'users assets: attachments'
require './mysql-connector-java-5.1.47-bin.jar'
require "rubygems"
require "java"
require "csv"
begin
# Prep the connection
Java::com.mysql.jdbc.Driver
userurl = "jdbc:mysql://10.52.3.224:3306/market"
@googya
googya / wireguard_install.md
Last active October 7, 2022 01:43
install wireguard on centos

on server

add private key

wg genkey  | tee my_private | wg pubkey > my_public # both for Client and Server
ip link add wg0 type wireguard
ip addr add 192.168.2.2/24 dev wg0
wg set wg0 private-key ./my_private # server's private key
ip link set wg0 up
#!/usr/bin/env ruby
require 'cocoa'
Cocoa::NSAutoreleasePool.new
app = Cocoa::NSApplication.sharedApplication
app.setActivationPolicy Cocoa::NSApplicationActivationPolicyRegular
app.activateIgnoringOtherApps true
-module(server1).
-export([start/2, rpc/2]).
start(Name, Mod) ->
register(Name, spawn(fun() -> loop(Name, Mod, Mod:init()) end)).
rpc(Name, Request) ->
io:format(" self at rpc is ~p~n", [self()]),
io:format(" Name at rpc is ~p~n", [Name]),
Name ! { self(), Request },
@googya
googya / red_package.rb
Created November 9, 2018 10:43
简单抢红包实现
require 'bigdecimal'
def getRandomMoney(remainSize, remainMoney)
if remainSize == 1
remainSize -= 1
return remainMoney.floor(2)
end
min = 0.01
max = remainMoney / remainSize * 2.0