Get a place weather by coordinates

from datetime import datetime
from pytz import timezone
from timezonefinder import TimezoneFinder
from sunnyday import Weather


class Geopoint:
    def __init__(self, latitude, longitude):
        self.latitude = latitude
        self.longitude = longitude

    def closest_parallel(self):
        return round(self.latitude)

    def get_time(self):
        tf = TimezoneFinder()

        tz = tf.timezone_at(lng=self.longitude, lat=self.latitude)

        return datetime.now(tz

Vanilla JS show/hide

// Slide toggle

var linkToggle = document.querySelectorAll(".js-toggle");

for (i = 0; i < linkToggle.length; i++) {
  linkToggle[i].addEventListener("click", function (event) {
    event.preventDefault();

    var container = document.getElementById(this.dataset.container);

    if (!container.classList.contains("active")) {
      container.classList.add("active");
      container.style.height = "auto";

      var height = container.clientHeight + "px";

      container.style.height = "0px";

テストテンプレート

#!/bin/sh

echo 'テsnプレート'

bash basic-template #bash #basic

bash basic-template #bash #basic
#!/bin/sh

あああああああああ

Inheritance

# Ex from : https://www.geeksforgeeks.org/inheritance-in-python/

# parent class
class Person( object ):    
  
        # __init__ is known as the constructor         
        def __init__(self, name, idnumber):   
                self.name = name
                self.idnumber = idnumber
        def display(self):
                print(self.name)
                print(self.idnumber)
  
# child class
class Employee( Person ):           
        def __init__(self, name, idnumber, salary, post):
  

golang jwt

// 生产jwt token
func CreateJwt(ctx *gin.Context) {
    // 获取用户
    user := &model.User{}
    result := &model.Result{
        Code:    200,
        Message: "登录成功",
        Data:    nil,
    }
    if e := ctx.BindJSON(&user); e != nil {
        result.Message = "数据绑定失败"
        result.Code = http.StatusUnauthorized
        ctx.JSON(http.StatusUnauthorized, gin.H{
            "result": result,
        })
    }
    u := user.QueryByUsername()
    if u.Password == user.Password {
        expiresTime

Split by comma and strip whitespace in Python

# Extracted from https://stackoverflow.com/questions/4071396/split-by-comma-and-strip-whitespace-in-python
my_string = "blah, lots  ,  of ,  spaces, here "
result = [x.strip() for x in my_string.split(',')]
# result is ["blah", "lots", "of", "spaces", "here"]

aptisan

php artisan migrate:fresh --seed

查找特定类别文件按照大小进行排序

ls --sort=size -l *.pdf |head  -n 3

Typy zápisů funkce

// Funkce
function pozdrav1(semSePiseParametr1,semSePiseParametr2){
    console.log("Toto je pozdrav 1")
}
// zavolání funkce
pozdrav1()
pozdrav1()
pozdrav1()

// klasická
let pozdrav2 = function(){
    console.log("Toto je pozdrav 2")
}
// zavolání funkce// zavolání funkce
pozdrav2()
pozdrav2()
pozdrav2()

// Šipková notace
let pozdrav3 = () => console.log("Toto je pozdrav 3")
// zavolání funkce
pozdrav3()
pozdrav3()
pozdrav3()

【NODE.JS】使用nvm指定默认的node.js版本

nvm alias default v14.15.1

JSONからHTMLを生成

'use strict';
 
var fs =require('fs'),
    gulp = require('gulp'),
    ejs = require('gulp-ejs'),
    rename = require('gulp-rename');
 
var jsonFile = './src/data/pages.json',
    tempFile = './src/ejs/template.ejs',
    json = JSON.parse(fs.readFileSync(jsonFile, 'utf8')),
    pages = json.pages,
    id;
 
function init (done) {
  for (var i = 0; i < pages.length; i++) {
    id = pages[i].dir;
 
    gulp.src(tempFile)
      .pipe(ejs({
          jsonData: pages[i]
      }))

メールフォーム

<?php
  if($_SERVER["REQUEST_METHOD"] == "POST") {
    $fromAddress = 'kurobe@imter.me';
 
    $name = $_POST['name'];
    $address = $_POST['address'];
 
    $body .= "お問い合わせいただきましてありがとうございます。下記の情報を受け取りました。\nこちらから折り返しご連絡させていただきます。\n\n";
    $body .= "▽会社名\n".$address."\n\n";
 
    $flg = bSENDMAIL3($address,$fromAddress,"お問い合わせいただきましてありがとうございます。",$body);
    $flg = bSENDMAIL3($fromAddress,$fromAddress,"お問い合わせいただきましてありがとうございます。",$body);
 
    if($flg == true) {
      $massage = "メー

line-heightの余白を消す

@mixin lhCrop($font-size, $line-height) {
  &::before,
  &::after {
    content: '';
    display: block;
    height: 0;
    width: 0;
    margin-top: calc((1 - #{remove-unit($line-height / $font-size)}) * 0.5em);
  }
}
 
// 値の単位を除外
@function remove-unit($number) {
  @if type-of($number) != number {
    @error "#{ $number } is not a number.";
    @return false;
  }
  @return $number / ($number * 0 + 1);
}

golang 模式 - 函数模式

[Go 惯用模式:函数选项模式](https://www.toutiao.com/i6948970808236704264/) 主要解决golang的函数参数不能使用默认值的问题 原理: 1. 利用可变参数;以便设置任意参数 2. 利用闭包原理;在设置参数时报要设置的值放进去,但是此时具体把这个设置设置到哪个具体的结构体里面还没确定 3. 在设置函数内遍历可变参数;以便把参数值实际设置到具体的结构体重 步骤: 1. 定义一个包含默认参数的结构实例 2. 针对每个参数定义一个闭包函数 3. 在函数中遍历参数,进行实际设置
// step1
var defaultStuffClient = stuffClient{
    retries: 3,
    timeout: 2,
}

// step2
type StuffClientOption func(*stuffClient)
func WithRetries(r int) StuffClientOption {
    return func(o *stuffClient) {
        o.retries = r
    }
}
func WithTimeout(t int) StuffClientOption {
    return func(o *stuffClient) {
        o.timeout = t
    }
}
type StuffClient interface {
    DoStuff() error
}
type stuffClient struct {
    conn    Connection
    timeout int
    retries int
}
type Connection s

多个集合取共同交集

Get Common Intersection From Multiple Lists
// 如果List里装的是对象,那么对象每一个属性都相同,才会判断为相同!!!



// 使用Stream中的reduce方法
public static void main(String[] args) {
        List<String> list1 = new ArrayList<>();
        list1.add("A");
        list1.add("B");
        list1.add("C");

        List<String> list2 = new ArrayList<>();
        list2.add("C");
        list2.add("B");
        list2.add("D");

        List<String> list3 = new ArrayList<>();
        list3.add("C");

        List<List<String>> bigList = new ArrayList<>();