Skip to content

Instantly share code, notes, and snippets.

View sword-jin's full-sized avatar

Sword sword-jin

View GitHub Profile
#coding=utf-8
# @Author: yangenneng
# @Time: 2018-01-17 15:42
# @Abstract:多元线性回归(Multiple Regression)算法
from numpy import genfromtxt
import numpy as np
from sklearn import linear_model
datapath=r"D:\Python\PyCharm-WorkSpace\MachineLearningDemo\MultipleRegression\data\data.csv"
@sword-jin
sword-jin / cloudSettings
Last active March 13, 2018 15:10
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-03-13T15:10:29.622Z","extensionVersion":"v2.9.0"}
@sword-jin
sword-jin / new_gist_file_0
Created February 7, 2017 14:48
Vue 代码块
https://jsfiddle.net/yyx990803/kyt43L2r/
@sword-jin
sword-jin / index.php
Created December 3, 2016 12:38
File download with php, node, python (文件下载)
<?php
$url = 'http://img3.imgtn.bdimg.com/it/u=214931719,1608091472&fm=21&gp=0.jpg';
$headers = [
'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $headers['User-Agent']);
<?php
class App
{
public function build($className)
{
if ($className instanceof Closure) {
return $className();
}
// 创建反射类
@sword-jin
sword-jin / test_get_count_of_post_comment
Created September 11, 2016 08:38
learn eloquent query.
$posts = Post::leftJoin('comments', 'comments.post_id', '=', 'posts.id')
->selectRaw(
'posts.*,
count(comments.id) as comments_count'
)
->groupBy('posts.id')
->orderBy('comments_count', 'desc')
->get();
@sword-jin
sword-jin / index.php
Created September 5, 2016 05:20
collection macro chunkInto
Collection::macro('chunkInto', function ($slices) {
$slices = max(min($slices, $this->count()), 1);
if ($slices == 1) {
return collect([$this]);
}
$take = round($this->count() / $slices);
return collect([$this->take($take)])
@sword-jin
sword-jin / index.php
Created September 3, 2016 03:51
Collaction starand rank (1224)
<?php
use Illuminate\Support\Collection;
require __dir__ . '/vendor/autoload.php';
Collection::macro('pipe', function ($callback) {
return $callback($this);
});
@sword-jin
sword-jin / deploy.sh
Created August 27, 2016 14:58
github page deploy
#!/bin/bash
git stash save
git checkout -B gh-pages
git add -f build
git commit -am "Rebuild website"
git filter-branch -f --prune-empty --subdirectory-filter build
git push -f origin gh-pages
git checkout -
git stash pop
@sword-jin
sword-jin / readme.md
Created June 26, 2016 09:10
php5.6 php7.0 切换

From php5.6 to php7.0 :

Apache:

sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart

CLI:

sudo ln -sfn /usr/bin/php7.0 /etc/alternatives/php