Skip to content

Instantly share code, notes, and snippets.

;; outlet: https://github.com/jlongster/outlet
(define (atom? exp)
(or (number? exp)
(string? exp)
(boolean? exp)
(null? exp)
(symbol? exp)))
@outshaker
outshaker / duplicate_Set-Cookie_header_demo.php
Created June 22, 2021 03:38
session 產生重複 set-Cookie 標頭 的範例
@outshaker
outshaker / detect_session_status.php
Created June 22, 2021 03:34
測試 session 狀態變化
<?php
// source from: [php判断session是否处于开启状态_阳水平的博客-CSDN博客](https://blog.csdn.net/zhezhebie/article/details/102678031)
function is_session_started() {
if ( php_sapi_name() !== 'cli' ) {
if ( version_compare(phpversion(), '5.4.0', '>=') ) {
return session_status() === PHP_SESSION_ACTIVE ? "TRUE" : "FALSE";
} else {
return session_id() === '' ? "FALSE" : "TRUE";
}
}
@outshaker
outshaker / sexp.py
Created October 1, 2019 19:19 — forked from pib/sexp.py
A simple Python s-expression parser.
from string import whitespace
atom_end = set('()"\'') | set(whitespace)
def parse(sexp):
stack, i, length = [[]], 0, len(sexp)
while i < length:
c = sexp[i]
print c, stack
function go_out()
{
var _loc1_ = undefined;
var _loc5_ = catx;
var _loc4_ = caty;
_loc1_ = 0;
while(_loc1_ < 6)
{
var _loc3_ = !(_loc4_ % 2)?_loc5_ + addx0[_loc1_]:_loc5_ + addx1[_loc1_];
var _loc2_ = _loc4_ + addy0[_loc1_];
@outshaker
outshaker / linear_regression_test.py
Last active January 22, 2019 05:13
make a linear regression of y = a*x^2 + b
#make a linear regression of y = a*x^2 + b
#fix error of calculus
p=[(1,1), (2,2), (3,3), (4,4)]
x=[t[0] for t in p]
y=[t[1] for t in p]
x2y = [(x[i] **2) * y[i] for i in range(0,4)]
sigmaX4 = sum(list(map(lambda x:x ** 4, x)))
sigmaX2 = sum(list(map(lambda x:x ** 2, x)))
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x=[1,2,3]
>>> s=''
>>> for i in x:
print(i)
1
2