Skip to content

Instantly share code, notes, and snippets.

View ixqbar's full-sized avatar
💭
I may be slow to respond.

Well ixqbar

💭
I may be slow to respond.
View GitHub Profile
@ixqbar
ixqbar / command.md
Created April 13, 2019 11:17
命令行快捷
Ctrl-a,将光标移到行首
Ctrl-e,将光标移到末尾
Ctrl-u,删除整行
Ctrl-k,向后删除,从光标开始直至行尾
Alt-Backspace,光标向前删除一个单词
Alt-f,将光标移到后一个单词
Alt-b,将光标移到前一个单词
Ctrl-p,上一条命令
@ixqbar
ixqbar / copy.md
Created February 12, 2019 09:30
copy
(function(){
    function executeCopy(text) {
        var input = document.createElement('textarea');
        document.body.appendChild(input);
        input.value = text;
        input.focus();
        input.select();
 document.execCommand('Copy');
```
<?php
$content = <<<SSS
<p>这是个测试文件</p><p><img src="http://pic2.ooopic.com/12/40/58/18bOOOPIC9c.jpg" /> </p>
<p>我们是图片</p>
<p><img src="/upload/20180616/1c73423b8269f2414f17217bea141836.jpg"/> </p>
<p>这是一个忧伤的故事</p><p><img src="http://img5.duitang.com/uploads/item/201206/15/20120615031447_R5EcS.jpeg" /> </p>
<p>谁是天下最帅的男人</p>
<p><img src="http://pic3.nipic.com/20090702/918855_174429094_2.jpg"/> </p>
@ixqbar
ixqbar / php-error.md
Created September 4, 2018 02:36
php-error
function registerErrorHandler(callable $callable)
{
	set_error_handler(function (int $err_no, string $err_msg, string $err_file = '', int $err_line = 0, array $err_context = []) use ($callable) {
		call_user_func($callable, sprintf('%s in file %s at line %s', $err_msg, $err_file, $err_line));
	});

	set_exception_handler(function (Throwable $e) use ($callable) {
		call_user_func($callable, $e->getMessage() . ',FILE:' . $e->getFile() . ',LINE:' . $e->getLine() . ',Trace:' . $e->getTraceAsString());
	});
@ixqbar
ixqbar / golang-neterror.md
Created August 21, 2018 06:16
golang之net.Error

func isCaredNetError(err error) bool {
    netErr, ok := err.(net.Error)
    if !ok {
        return false
    }
@ixqbar
ixqbar / img_resize.js
Created August 18, 2018 09:13 — forked from makevoid/img_resize.js
Resize Images with Canvas on the clientside
var settings = {
max_width: 600,
max_height: 200
}
resize_image = function(img){
var ctx = canvas.getContext("2d")
var canvasCopy = document.createElement("canvas")
var copyContext = canvasCopy.getContext("2d")
@ixqbar
ixqbar / backup.go
Created July 11, 2017 10:33 — forked from barthr/backup.go
Backup all your github repositories
package main
import (
"context"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
@ixqbar
ixqbar / ip_blacklist.lua
Created May 9, 2017 02:00 — forked from chrisboulton/ip_blacklist.lua
Redis based IP blacklist for Nginx (LUA)
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip:
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip:
@ixqbar
ixqbar / android.md
Created February 20, 2017 08:42
Android
private boolean isMyServiceRunning(Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
 return false;