Skip to content

Instantly share code, notes, and snippets.

View noname007's full-sized avatar
🎯
Focusing

soul11201 noname007

🎯
Focusing
View GitHub Profile
Golang 面试题 (4) N个协程交替打印1-100
启动N个协程,共用一个外部变量计数器,计数器范围是1到100
开启N个有缓冲chan,chans[i]塞入数据代表协程i可以进行打印了,打印的数字就是计数器的数
协程i一直阻塞,直到chan[i]通道有数据可以拉,才打印
@noname007
noname007 / sig_fork.c
Created June 21, 2024 09:01
fork when exec signal handler
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/wait.h>
#include <stdlib.h>
void alrm_handler(int signo)
{
printf("%d pid:%d\n", signo, getpid());
@noname007
noname007 / ssl_smtp_example.go
Created October 17, 2023 06:15 — forked from chrisgillis/ssl_smtp_example.go
Golang SSL SMTP Example
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
@noname007
noname007 / mail.go
Created October 8, 2023 12:17 — forked from xeoncross/mail.go
Simple SMTP mail sender in golang that can send email directly to anyone. Super basic, but great for sending notice emails. Upgrades to STARTTLS if it can.
package main
import (
"encoding/base64"
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"strings"
@noname007
noname007 / rsync_backup.py
Created December 7, 2020 06:28 — forked from seebk/rsync_backup.py
Python rsync backup script
#!/usr/bin/python3
#######################################################
# Python rsync Backup script
# Sebastian Kraft, 24.06.2013
#
#######################################################
#-----------------------------------------------------
# Config
@noname007
noname007 / vimium-emacs.md
Created July 27, 2020 08:38 — forked from dmgerman/vimium-emacs.md
Emacs-Style Key Bindings for Vimium

My Vimium Key Bindings (Emacs-Style)

This is a full set of key bindings (as of Vimium v1.45); covering all Vimium functionality. I have tried to map all Vimium functionality to comparable Emacs functionality (whenever possible). In cases where there is no equivalent, those commands are prefixed by <c-g> (indicating <c-g>oogle Chrome; and because <c-g> does not conflict with other Emacs shortcuts at all).

Commented Shortcuts: There are a few Emacs-style shortcuts that are simply not possible in Vimium. All of my shortcuts (including those which were not possible; i.e. where I used a decent alternative) have been commented below. This should help to clarify my rationale.

_Compatibility: All of these shortcuts were tested on Mac OS X (Mavericks). Please note that all of my shortcuts operate under the assumption that your Emacs Meta key is the Alt/Option key. This really was my only choice, because the key is already used in Chrome for shortcuts that c

@noname007
noname007 / up.sh
Last active August 21, 2019 08:43
#!/bin/bash
#https://blog.csdn.net/mydriverc2/article/details/79011438
set -x
cmd="$@"
r=$(ps aux|grep "${cmd}" | grep -v "$0"|grep -v 'grep')
@noname007
noname007 / Zend_bench.php.log
Created February 14, 2019 13:34 — forked from rybakit/Zend_bench.php.log
php8 jit msgpack.php benchmarks
$ sapi/cli/php Zend/bench.php
------------------------
Total 0.497
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so Zend/bench.php
------------------------
Total 0.488
$ sapi/cli/php -dextension_dir=`pwd`/modules -dzend_extension=opcache.so -dopcache.enable_cli=1 -dopcache.file_update_protection=0 -dopcache.jit_buffer_size=1M Zend/bench.php
------------------------
@noname007
noname007 / process_binary_stream.php
Created December 7, 2018 11:30
二进制流,字符串化后处理,反解回二进制流对应的 base_64_encode
<?php
$hex_str = 'e123476343f37e7ecfd8401b60897de9bcc1621e5ede9755e9c442fc9a16d41ee82e344f18135866ba1360f587346711255d8c40e5a5fb45958833f67c7487ac1ff5833716fcc6b7b0781d6fe38c1cb95f4ceeb99b17f62a927777a07103af379dc24d3e2ce0540838ee8f3549b3fb58083fbf7058d1cf6d7c15e9da03bf3709c61a79c2b2c858f327ed6755df7883c2130e9ba4b36fc366b7b72d0459c2ea326af189887ef213432e820beadc321791aa9fd708bbb3ab9c556e54beb8e15f88f07542030de04e0bbbf0537825f6d6761c919a93500099c83f8d00f7ba8b2b2e408e9f820c9390b8d1dba667c047b7adb3e3d2c3fdfd721f5998f80c5509299b';
$len = strlen($hex);
$a = [];
for($i = 0; $i < $len; $i += 2)
{
<?php
trait A
{
public function b()
{
echo __METHOD__;
}
}