Skip to content

Instantly share code, notes, and snippets.

View lovejoy's full-sized avatar
🤔
我思故我在

lovejoy lovejoy

🤔
我思故我在
View GitHub Profile
@lovejoy
lovejoy / gist:3b3cb6cc0028ac57b08f7848205ac4fc
Created March 10, 2021 08:01
匹配一个字符串不匹配另外一个字符串的正则pcre
^(?:(?!不匹配字符).)*匹配字符(?:(?!不匹配字符).)*$
@lovejoy
lovejoy / gormvsxorm.txt
Created May 1, 2020 03:12
gorm vs xorm
2000 times - Insert
gorm: 9.60s 4800617 ns/op 5407 B/op 119 allocs/op
xorm: 12.63s 6315205 ns/op 2365 B/op 56 allocs/op
2000 times - BulkInsert 100 row
xorm: 23.89s 11945333 ns/op 253812 B/op 4250 allocs/op
gorm: Don't support bulk insert - https://github.com/jinzhu/gorm/issues/255
2000 times - Update
xorm: 0.39s 195846 ns/op 2529 B/op 87 allocs/op
@lovejoy
lovejoy / getent-passwd.c
Created June 10, 2019 07:46
getent-passwd
#define _GNU_SOURCE
#include <pwd.h>
#include <stdio.h>
#define BUFLEN 4096
int
main(void)
{
struct passwd pw, *pwp;
char buf[BUFLEN];
@lovejoy
lovejoy / cuda_check.py
Created December 10, 2018 02:43 — forked from f0k/cuda_check.py
Simple python script to obtain CUDA device information
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Outputs some information on CUDA-enabled devices on your computer,
including current memory usage.
It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1
from C to Python with ctypes, so it can run without compiling anything. Note
that this is a direct translation with no attempt to make the code Pythonic.
@lovejoy
lovejoy / main.go
Last active May 7, 2017 10:19
目录树结构
package main
import (
"encoding/json"
"fmt"
"github.com/davecgh/go-spew/spew"
"strings"
)
type Nodes struct {
@lovejoy
lovejoy / safe_remove.sh
Created April 7, 2016 09:08
安全删除
#!/bin/bash
mkdir -p ~/.trash/
for target in $*;do
# rm参数无视
if [[ "$target" =~ "^-" ]];then
continue;
fi
@lovejoy
lovejoy / b=$$a.sh
Created October 14, 2015 07:11
xxx=a b=$a的效果
mname="MOD_NAME$modnum"
mod_name="${!mname}"
#!/usr/bin/perl
#######################################################
# sendEmail
# Written by: Brandon Zehm <caspian@dotconf.net>
#
# License:
#
# This code is *NOT* to be used for sending SPAM email!
# If you are using this software to send spam email
# STOP RIGHT NOW, your license to use this software is
@lovejoy
lovejoy / gist:5942549
Created July 7, 2013 06:32
/etc/profile
# /etc/profile
#Set our umask
umask 022
# Set our default path
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
export PATH
# Load profiles from /etc/profile.d
@lovejoy
lovejoy / gist:5608115
Created May 19, 2013 16:12
openwrt 看各个ip速度的脚本
#!/bin/sh
echo "Collecting data..."
echo ""
cat /proc/net/arp | grep : | grep ^192 | grep -v 00:00:00:00:00:00| awk '{print $1}'> mac-arp
iptables -N UPLOAD
iptables -N DOWNLOAD
while read line;do iptables -I FORWARD 1 -s $line -j UPLOAD;done < mac-arp
while read line;do iptables -I FORWARD 1 -d $line -j DOWNLOAD;done < mac-arp
sleep 1