Skip to content

Instantly share code, notes, and snippets.

View lagagain's full-sized avatar

lagagain lagagain

View GitHub Profile
@lagagain
lagagain / Callable.py
Last active December 31, 2019 00:45
Implement Pipe function in Python3
class CallableWrapper:
def __init__(self, wrap):
self.wrap = wrap
def __call__(self, f=None, *args, **kargs):
if f == None:
return self.wrap
result = f(self.wrap, *args, **kargs)
class __callable(type(result), Callable):
pass
return __callable(result, *args, **kargs)
class Solution:
prime_numbers = [2,3,5,7,11,13,17,19,23,29,31]
def countPrimes(self, n: int) -> int:
return Solution.countPrime(n)
@staticmethod
def countPrime(n: int):
if n <= 2: return 0
m = Solution.prime_numbers[-1]
while n > m:
@lagagain
lagagain / class_method.lisp
Created December 1, 2019 15:13
[Practice] Common Lisp: OOP method
(defclass C1 nil
((a :type fixnum
:reader get-a
:writer set-a
:initarg :a)))
(defparameter *i1* (make-instance 'C1 :a 1))
(defparameter *i2* (make-instance 'C1 :a 2))
(defparameter *i3* (make-instance 'C1 :a 1))
@lagagain
lagagain / SimpleHTTPServer.py
Created July 1, 2019 16:09
An Example for HTTP Server with Built-in python3
from http.server import HTTPServer
from http.server import BaseHTTPRequestHandler
class MyHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
print(self.path)
print(self.command)
self.wfile.write(b"Hello World")
server = HTTPServer(("0.0.0.0",8000), MyHTTPRequestHandler)
@lagagain
lagagain / form.blade.php
Last active July 1, 2019 14:49
[Simple Example] Laravel Receive Multiple value
<form action="">
<input name="select[]" type="checkbox" value="01"/>
<input name="select[]" type="checkbox" value="02"/>
<input name="select[]" type="checkbox" value="03"/>
<input name="select[]" type="checkbox" value="04"/>
<input name="select[]" type="checkbox" value="05"/>
<input name="pick_one" type="radio" value="01"/>
<input name="pick_one" type="radio" value="02"/>
<input name="pick_one" type="radio" value="03"/>
@lagagain
lagagain / LICENSE
Created May 7, 2019 14:03
A simple panter with HTML 5
Copyright (c) 2019, lagagain
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
(require 'abcl-contrib)
(require 'abcl-asdf)
(require 'jss)
(defpackage id.lag.tesabcl
(:use cl abcl-contrib abcl-asdf jss java))
(in-package id.lag.tesabcl)
(jcall "println" #"java.lang.System.out" "Hello, World")
b0d1630... 04/14/19 13:31 public
+ d9aa1d7... 04/13/19 23:14 public classmethod and staticmethod implement for python3.6
+ d71a4fd... 04/12/19 09:33 public
c2c8790... 03/21/19 11:12 public
+ 648c7e1... 03/12/19 23:06 public JAVA GUI / ABCL GUI
4f0b15e... 02/21/19 09:49 public
5be04a4... 02/08/19 18:13 private
+ 2d30a57... 02/08/19 18:11 private EOSIO-contract eoshop
e1d8bdb... 12/11/18 20:40 public 自制@裝飾器
c145d35... 12/11/18 19:51 public [practice] [Common Lisp] CFFI - c-printf example (Common Lisp)
@lagagain
lagagain / test.py
Last active April 13, 2019 16:20
classmethod and staticmethod implement for python3.6
def myClassmethod(m, *arg, **karg):
def _m(cls, *arg, **karg):
cls = cls if isinstance(cls, type(int)) else cls.__class__
return m(cls, *arg, **karg)
return _m
def myStaticmethod(m, *arg, **karg):
def _m(*arg, **karg):
if len(arg) > 0:
if m.__name__ in dir(arg[0].__class__):
(in-package :cl-user)
(defpackage :testread
(:use cl))
(in-package :testread)
(defparameter *old-readtable* (copy-readtable) "")
(defparameter *new-readtable* (copy-readtable) "")
(defparameter *syms* (make-hash-table))