Skip to content

Instantly share code, notes, and snippets.

View crusj's full-sized avatar
🎯
Focusing

大风吹 crusj

🎯
Focusing
View GitHub Profile
@crusj
crusj / install-vim-8-with-python-ruby-lua-ubuntu.sh
Last active July 12, 2019 03:02 — forked from erickpatrick/install-vim-8-with-python-ruby-lua-ubuntu.sh
Install Vim 8 with Python, Python 3, Ruby (2.5) and Lua support on Ubuntu
# remove current vim
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common
# removes current link for vim
sudo rm -rf /usr/local/share/vim /usr/bin/vim
# add ppa for newest version of ruby (currently, as of 06/06/2017, ruby v2.4)
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
@crusj
crusj / copyToClipboard.js
Created July 12, 2019 03:19
浏览器复制内容到剪切板
var temp = $("<input type='text' value='" + mediaId + "'/>");
temp.appendTo('body');
temp.select();//选中元素
if(document.execCommand('copy')){
layer.msg('media_id已复制到剪切板!');
}else{
layer.msg('复制到剪切板失败!');
}
temp.remove();
@crusj
crusj / level.php
Last active July 12, 2019 05:55
将有层级关系的php数组转换为层级数组
<?php
//需要数据的键与子项目id相同
$arr = [
1 => [
"id" => 1,
"pid" => 0,
"value" => 1
],
2 => [
"id" => 2,

property attributes

property type

  • int
  • real
  • string
  • list
  • qml object type
  • qml basic type
set normal (set_color normal)
set magenta (set_color magenta)
set yellow (set_color yellow)
set green (set_color green)
set red (set_color red)
set gray (set_color -o black)
# Fish git prompt
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
@crusj
crusj / code.sh
Created July 23, 2019 01:13
解决ubuntu中文乱码
sudo apt-get install fonts-droid-fallback ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming
@crusj
crusj / AbstractFactory.php
Last active August 27, 2019 01:42
利用phpdoc以及反射实现对象工厂
<?php
/**
* author jianglong
* date 2019/8/13 上午9:10
*/
/**
* Class AbstractFactory
*
@crusj
crusj / date.php
Created August 23, 2019 06:42
php月份按周分段,以及判断当前时间是当月的第几周
<?php
class Date {
//月转化为周
private function month2Week(int $year, int $month): array
{
$start = 1;
$end = date('d', strtotime(date("{$year}-{$month}-01") . ' + 1 month - 1 day'));
$days = range($start, $end);
return array_chunk($days, 7);
}
@crusj
crusj / Camel2Snake.php
Last active August 27, 2019 01:32
php变量驼峰转snake
<?php
trait Camel2Snake
{
public function camel2Snake(string $camel): string
{
return strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $camel));
}
}
@crusj
crusj / FileLock.php
Created August 27, 2019 01:45
PHP文件锁,防止争抢
<?php
/**
* author jianglong
* date 2019/8/5 下午5:00
*/
/**
* 文件锁
* Trait FileLock