Skip to content

Instantly share code, notes, and snippets.

View hfhimage's full-sized avatar

hfhimage hfhimage

View GitHub Profile
@hfhimage
hfhimage / ticker.go
Last active September 16, 2022 09:26
go 定时器
ticker := time.NewTicker(frequency)
defer ticker.Stop()
for range ticker.C {
// do your stuff
}
@hfhimage
hfhimage / bookmark.js
Created March 29, 2014 11:55
浏览器书签插件
(function(){
var d=document,
z=d.createElement('scr'+'ipt'),
b=d.body,
l=d.location;
try{
if(!b)throw(0);
z.innerHTML = "location.href = km_path + '/users/login?ref_url=' + encodeURI(location.href);";
b.appendChild(z);
}catch(e){
@hfhimage
hfhimage / delete.sql
Created January 24, 2014 07:09
mysql 删除重复数据 mysql 4 不支持嵌套的删除语法, 因此得需要通过创建临时表绕过
DROP TABLE IF EXISTS tmp_dels;
CREATE TABLE tmp_dels AS SELECT subscribe_tags.id FROM subscribe_tags, ( SELECT max(id) AS id, nick, tag_id FROM subscribe_tags GROUP BY nick, tag_id HAVING count(1) > 1 ) t WHERE subscribe_tags.nick = t.nick AND subscribe_tags.tag_id = t.tag_id AND subscribe_tags.id < t.id;
DELETE FROM subscribe_tags WHERE id IN (SELECT id FROM tmp_dels);
DROP TABLE IF EXISTS tmp_dels;
@hfhimage
hfhimage / replace_new_line.php
Created January 3, 2014 09:54
php 替换换行符
<?php
$order = array("\r\n", "\n", "\r");
$replace = '';
$str=str_replace($order, $replace, $str);
?>
@hfhimage
hfhimage / alter_table.sql
Last active December 29, 2015 17:29
修改数据库
查看列:desc 表名;
修改表名:alter table t_book rename to bbb;
添加列:alter table 表名 add column 列名 varchar(30);
删除列:alter table 表名 drop column 列名;
修改列名MySQL: alter table bbb change nnnnn hh int;
修改列名SQLServer:exec sp_rename't_student.name','nn','column';
修改列名Oracle:lter table bbb rename column nnnnn to hh int;
修改列属性:alter table t_book modify name varchar(22);
@hfhimage
hfhimage / rand.sql
Created November 12, 2013 10:56
取出随机顺序得到记录
SELECT * FROM your_table ORDER BY RAND()
@hfhimage
hfhimage / iconv.php
Created November 11, 2013 07:11
php iconv 函数
date --date='1 years ago' +%Y
@hfhimage
hfhimage / xshell solarized dark theme.xcs
Created November 2, 2013 05:57
xshell solarized dark theme
[Names]
count=1
name0=Solarized Dark
[Solarized Dark]
text(bold)=839496
magenta(bold)=dd3682
text=839496
white(bold)=fdf6e3
green=859900
red(bold)=cb4b16
@hfhimage
hfhimage / netstat.bat
Created October 7, 2013 12:52
windows下查看端口占用情况
netstat -abno
@hfhimage
hfhimage / autocomplete.sql
Created September 30, 2013 01:51
ir 提示补全 sql
CREATE TABLE `search_info_new` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键,自增',
`query` varchar(256) CHARACTER SET utf8 DEFAULT NULL COMMENT '备注',
`created_by` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建此记录的人',
`created` datetime DEFAULT NULL COMMENT '创建此记录的时间',
PRIMARY KEY (`id`),
KEY `idx_query` (`query`(255)) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3407821 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;