Skip to content

Instantly share code, notes, and snippets.

Hello and welcome!
@18601673727
18601673727 / javascript
Created December 3, 2016 18:11
.eslintrc
{
"plugins": [
"react",
"you-dont-need-lodash-underscore"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
sed -i 's/downloads.openwrt.org/openwrt.proxy.ustclug.org/' /etc/opkg/distfeeds.conf
path=/opt/docker/etc/nginx/vhost.conf
endpoint="fastcgi_read_timeout"
patch="fastcgi_buffer_size 128k;fastcgi_buffers 32 32k;"
if grep -q "$patch" $path ; then
echo 'already patched, skip!'
else
echo 'no patch found, now patch'
sed -i "/$endpoint/i $patch" $path
fi
@18601673727
18601673727 / gist:f0a21e57161a97c91399
Created October 31, 2014 08:11
Convert svn to git
#!/usr/bin/env bash
authors=$(svn log -q | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq)
for author in ${authors}; do
echo "${author} = NAME <USER@DOMAIN>";
done
@18601673727
18601673727 / gist:773db55577eae221cbc0
Created September 18, 2014 08:12
Json to Tree conversion.
var tree = [];
var transData = function (a, idStr, pidStr, childrenStr){
var r = [], hash = {}, id = idStr, pid = pidStr, children = childrenStr, i = 0, j = 0, len = a.length;
for(; i < len; i++){
hash[a[i][id]] = a[i];
}
for(; j < len; j++){
var aVal = a[j], hashVP = hash[aVal[pid]];
if (hashVP) {
@18601673727
18601673727 / gist:f397688dddaff1128eaf
Created July 10, 2014 08:33
An laravel resource controller integrated with Dingo\Api and League\Fractal
<?php
class PostsController extends Controller
{
protected $api;
protected $auth;
public function __construct(Dingo\Api\Dispatcher $api, Dingo\Api\Auth\Shield $auth)
{
$this->api = $api;
@18601673727
18601673727 / gist:6a6555d6fd0f78b540fd
Created July 10, 2014 08:30
an laravel typical route with fractal.
Route::get('posts/{ids}', function ($ids) {
$ids = explode(',', $ids);
return Post::whereIn('id', $ids)->get();
})->where('ids', '[\d,]+');
Route::get('posts', function () {
return Response::api()->withCollection(Post::all(), new PostTransformer);
});